Skip to content

Commit 339299c

Browse files
authored
Merge pull request #70 from certik/makefiles2
Refactor the manual Makefiles
2 parents 1ed053f + 3400515 commit 339299c

File tree

6 files changed

+60
-46
lines changed

6 files changed

+60
-46
lines changed

.github/workflows/CI.yml

+2
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ jobs:
7171
if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '9')
7272
run: |
7373
make -f Makefile.manual
74+
make -f Makefile.manual test
75+
make -f Makefile.manual clean

Makefile.manual

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Fortran stdlib Makefile
22

33
FC = gfortran
4-
FCFLAGS=-O0
4+
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
55

6-
.PHONY: all clean
6+
export FC
7+
export FFLAGS
78

8-
all: stdlib tests
9+
.PHONY: all clean test
910

10-
stdlib:
11-
$(MAKE) -f Makefile.manual FC=${FC} FCFLAGS=${FCFLAGS} --directory=src
11+
all:
12+
$(MAKE) -f Makefile.manual --directory=src
13+
$(MAKE) -f Makefile.manual --directory=src/tests
1214

13-
tests: stdlib
14-
$(MAKE) -f Makefile.manual FC=${FC} FCFLAGS=${FCFLAGS} --directory=src/tests
15+
test:
16+
$(MAKE) -f Makefile.manual --directory=src/tests test
17+
@echo
18+
@echo "All tests passed."
1519

1620
clean:
1721
$(MAKE) -f Makefile.manual clean --directory=src

src/Makefile.manual

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1+
LIB = libstdlib.a
2+
13
OBJS = stdlib_experimental_ascii.o \
24
stdlib_experimental_error.o \
35
stdlib_experimental_io.o \
6+
f18estop.o
47

58
.PHONY: all clean
6-
.SUFFIXES: .f90 .o
7-
8-
all: $(OBJS)
99

10-
.f90.o:
11-
$(FC) $(FCFLAGS) -c $<
10+
all: $(LIB)
1211

13-
%.o: %.mod
14-
15-
stdlib_experimental_ascii.o: stdlib_experimental_ascii.f90
16-
stdlib_experimental_error.o: stdlib_experimental_error.f90
17-
stdlib_experimental_io.o: stdlib_experimental_io.f90
12+
$(LIB): $(OBJS)
13+
ar rcs $@ $(OBJS)
1814

1915
clean:
20-
$(RM) *.o *.mod
16+
$(RM) $(LIB) $(OBJS) *.mod
17+
18+
%.o: %.f90
19+
$(FC) $(FFLAGS) -c $<

src/tests/Makefile.manual

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
.PHONY: all clean
1+
.PHONY: all clean test
22

3-
all: ascii/test_ascii loadtxt/test_loadtxt
4-
5-
ascii/test_ascii:
3+
all:
64
$(MAKE) -f Makefile.manual --directory=ascii
7-
8-
loadtxt/test_loadtxt:
95
$(MAKE) -f Makefile.manual --directory=loadtxt
106

7+
test:
8+
$(MAKE) -f Makefile.manual --directory=ascii test
9+
$(MAKE) -f Makefile.manual --directory=loadtxt test
10+
1111
clean:
1212
$(MAKE) -f Makefile.manual --directory=ascii clean
1313
$(MAKE) -f Makefile.manual --directory=loadtxt clean

src/tests/ascii/Makefile.manual

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
PROG = test_ascii
2+
OBJS = test_ascii.o
3+
14
CPPFLAGS = -I../..
2-
OBJS = ../../stdlib_experimental_ascii.o \
3-
../../stdlib_experimental_error.o
5+
LDFLAGS = -L../.. -lstdlib
46

5-
.PHONY: all clean
6-
.SUFFIXES: .f90 .o
7+
.PHONY: all clean test
78

8-
all: test_ascii
9+
all: $(PROG)
910

10-
test_ascii: test_ascii.f90 $(OBJS)
11-
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
11+
$(PROG): $(OBJS)
12+
$(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS)
1213

13-
%.o: %.mod
14+
test:
15+
./$(PROG)
1416

1517
clean:
16-
$(RM) test_ascii
17-
$(RM) *.o *.mod
18+
$(RM) $(PROG) $(OBJS) *.mod
19+
20+
%.o: %.f90
21+
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<

src/tests/loadtxt/Makefile.manual

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
CPPFLAGS = -I../..
2-
OBJS = ../../stdlib_experimental_error.o \
3-
../../stdlib_experimental_io.o
2+
LDFLAGS = -L../.. -lstdlib
43

5-
.PHONY: all clean
6-
.SUFFIXES: .f90 .o
4+
.PHONY: all clean test
75

8-
all: test_loadtxt test_savetxt
6+
PROGS = test_loadtxt test_savetxt test_loadtxt_qp test_savetxt_qp
7+
OBJS = $(PROGS:=.o)
98

10-
test_loadtxt: test_loadtxt.f90 $(OBJS)
11-
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
129

13-
test_savetxt: test_savetxt.f90 $(OBJS)
14-
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
10+
all: $(PROGS)
1511

16-
%.o: %.mod
12+
$(PROGS): %: %.o
13+
$(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS)
14+
15+
test:
16+
./test_loadtxt
17+
./test_loadtxt_qp
18+
./test_savetxt
19+
./test_savetxt_qp
1720

1821
clean:
19-
$(RM) test_loadtxt test_savetxt
20-
$(RM) *.o *.mod
22+
$(RM) $(PROGS) $(OBJS) tmp.dat tmp_qp.dat
23+
24+
%.o: %.f90
25+
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<

0 commit comments

Comments
 (0)