Skip to content

Commit 5fdfa42

Browse files
committed
Refactor the manual Makefiles
* Compile the quadruple precision loadtxt * Implement "make test" to run tests and run them at the CI * Create a static libstdlib.a library and use it in tests * Use more modern syntax and simplify * Pass in the FC/FCFLAGS variables automatically * Consolidate stdlib tests targets
1 parent 924ee54 commit 5fdfa42

File tree

6 files changed

+63
-47
lines changed

6 files changed

+63
-47
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+
FCFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
55

6-
.PHONY: all clean
6+
export FC
7+
export FCFLAGS
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

+11-12
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 \
3-
stdlib_experimental_io.o \
5+
stdlib_experimental_io.o
46

57
.PHONY: all clean
6-
.SUFFIXES: .f90 .o
7-
8-
all: $(OBJS)
9-
10-
.f90.o:
11-
$(FC) $(FCFLAGS) -c $<
8+
.SUFFIXES: $(SUFFIXES) .f90 .o
129

13-
%.o: %.mod
10+
all: $(LIB)
1411

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) $(FCFLAGS) -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

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
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
8+
.SUFFIXES: $(SUFFIXES) .f90 .o
79

8-
all: test_ascii
10+
all: $(PROG)
911

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

13-
%.o: %.mod
15+
test:
16+
./$(PROG)
1417

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

src/tests/loadtxt/Makefile.manual

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
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
5+
.SUFFIXES: $(SUFFIXES) .f90 .o
76

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

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

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

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

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

0 commit comments

Comments
 (0)