From a222c6aaa1b100cacba30d1d5f0cd09c9fc9b708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Thu, 2 Jan 2020 14:46:32 -0700 Subject: [PATCH 1/3] 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 --- .github/workflows/CI.yml | 2 ++ Makefile.manual | 18 +++++++++++------- src/Makefile.manual | 22 +++++++++++----------- src/tests/Makefile.manual | 12 ++++++------ src/tests/ascii/Makefile.manual | 25 +++++++++++++++---------- src/tests/loadtxt/Makefile.manual | 30 ++++++++++++++++++------------ 6 files changed, 63 insertions(+), 46 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4eb987fc2..82f9caff4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -71,3 +71,5 @@ jobs: if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '9') run: | make -f Makefile.manual + make -f Makefile.manual test + make -f Makefile.manual clean diff --git a/Makefile.manual b/Makefile.manual index a3e59040e..ebde5adb9 100644 --- a/Makefile.manual +++ b/Makefile.manual @@ -1,17 +1,21 @@ # Fortran stdlib Makefile FC = gfortran -FCFLAGS=-O0 +FCFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -.PHONY: all clean +export FC +export FCFLAGS -all: stdlib tests +.PHONY: all clean test -stdlib: - $(MAKE) -f Makefile.manual FC=${FC} FCFLAGS=${FCFLAGS} --directory=src +all: + $(MAKE) -f Makefile.manual --directory=src + $(MAKE) -f Makefile.manual --directory=src/tests -tests: stdlib - $(MAKE) -f Makefile.manual FC=${FC} FCFLAGS=${FCFLAGS} --directory=src/tests +test: + $(MAKE) -f Makefile.manual --directory=src/tests test + @echo + @echo "All tests passed." clean: $(MAKE) -f Makefile.manual clean --directory=src diff --git a/src/Makefile.manual b/src/Makefile.manual index 05640fc34..e877ec59f 100644 --- a/src/Makefile.manual +++ b/src/Makefile.manual @@ -1,20 +1,20 @@ +LIB = libstdlib.a + OBJS = stdlib_experimental_ascii.o \ stdlib_experimental_error.o \ stdlib_experimental_io.o \ + f18estop.o .PHONY: all clean -.SUFFIXES: .f90 .o - -all: $(OBJS) - -.f90.o: - $(FC) $(FCFLAGS) -c $< +.SUFFIXES: $(SUFFIXES) .f90 .o -%.o: %.mod +all: $(LIB) -stdlib_experimental_ascii.o: stdlib_experimental_ascii.f90 -stdlib_experimental_error.o: stdlib_experimental_error.f90 -stdlib_experimental_io.o: stdlib_experimental_io.f90 +$(LIB): $(OBJS) + ar rcs $@ $(OBJS) clean: - $(RM) *.o *.mod + $(RM) $(LIB) $(OBJS) *.mod + +%.o: %.f90 + $(FC) $(FCFLAGS) -c $< diff --git a/src/tests/Makefile.manual b/src/tests/Makefile.manual index 2669a98f8..778f3a81a 100644 --- a/src/tests/Makefile.manual +++ b/src/tests/Makefile.manual @@ -1,13 +1,13 @@ -.PHONY: all clean +.PHONY: all clean test -all: ascii/test_ascii loadtxt/test_loadtxt - -ascii/test_ascii: +all: $(MAKE) -f Makefile.manual --directory=ascii - -loadtxt/test_loadtxt: $(MAKE) -f Makefile.manual --directory=loadtxt +test: + $(MAKE) -f Makefile.manual --directory=ascii test + $(MAKE) -f Makefile.manual --directory=loadtxt test + clean: $(MAKE) -f Makefile.manual --directory=ascii clean $(MAKE) -f Makefile.manual --directory=loadtxt clean diff --git a/src/tests/ascii/Makefile.manual b/src/tests/ascii/Makefile.manual index f2d9e03c6..a31be0380 100644 --- a/src/tests/ascii/Makefile.manual +++ b/src/tests/ascii/Makefile.manual @@ -1,17 +1,22 @@ +PROG = test_ascii +OBJS = test_ascii.o + CPPFLAGS = -I../.. -OBJS = ../../stdlib_experimental_ascii.o \ - ../../stdlib_experimental_error.o +LDFLAGS = -L../.. -lstdlib -.PHONY: all clean -.SUFFIXES: .f90 .o +.PHONY: all clean test +.SUFFIXES: $(SUFFIXES) .f90 .o -all: test_ascii +all: $(PROG) -test_ascii: test_ascii.f90 $(OBJS) - $(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS) +$(PROG): $(OBJS) + $(FC) $(FCFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS) -%.o: %.mod +test: + ./$(PROG) clean: - $(RM) test_ascii - $(RM) *.o *.mod + $(RM) $(PROG) $(OBJS) *.mod + +%.o: %.f90 + $(FC) $(FCFLAGS) $(CPPFLAGS) -c $< diff --git a/src/tests/loadtxt/Makefile.manual b/src/tests/loadtxt/Makefile.manual index 716f41678..d0841de47 100644 --- a/src/tests/loadtxt/Makefile.manual +++ b/src/tests/loadtxt/Makefile.manual @@ -1,20 +1,26 @@ CPPFLAGS = -I../.. -OBJS = ../../stdlib_experimental_error.o \ - ../../stdlib_experimental_io.o +LDFLAGS = -L../.. -lstdlib -.PHONY: all clean -.SUFFIXES: .f90 .o +.PHONY: all clean test +.SUFFIXES: $(SUFFIXES) .f90 .o -all: test_loadtxt test_savetxt +PROGS = test_loadtxt test_savetxt test_loadtxt_qp test_savetxt_qp +OBJS = $(PROGS:=.o) -test_loadtxt: test_loadtxt.f90 $(OBJS) - $(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS) -test_savetxt: test_savetxt.f90 $(OBJS) - $(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS) +all: $(PROGS) -%.o: %.mod +$(PROGS): %: %.o + $(FC) $(FCFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) + +test: + ./test_loadtxt + ./test_loadtxt_qp + ./test_savetxt + ./test_savetxt_qp clean: - $(RM) test_loadtxt test_savetxt - $(RM) *.o *.mod + $(RM) $(PROGS) $(OBJS) tmp.dat tmp_qp.dat + +%.o: %.f90 + $(FC) $(FCFLAGS) $(CPPFLAGS) -c $< From 0d80b89e4ecf31e89bb1fa039e8c7e47e51ebb96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Fri, 3 Jan 2020 11:25:04 -0700 Subject: [PATCH 2/3] Make: rename FCFLAGS to FFLAGS --- Makefile.manual | 4 ++-- src/Makefile.manual | 2 +- src/tests/ascii/Makefile.manual | 4 ++-- src/tests/loadtxt/Makefile.manual | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.manual b/Makefile.manual index ebde5adb9..3fd085ed6 100644 --- a/Makefile.manual +++ b/Makefile.manual @@ -1,10 +1,10 @@ # Fortran stdlib Makefile FC = gfortran -FCFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all +FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all export FC -export FCFLAGS +export FFLAGS .PHONY: all clean test diff --git a/src/Makefile.manual b/src/Makefile.manual index e877ec59f..2d93464d8 100644 --- a/src/Makefile.manual +++ b/src/Makefile.manual @@ -17,4 +17,4 @@ clean: $(RM) $(LIB) $(OBJS) *.mod %.o: %.f90 - $(FC) $(FCFLAGS) -c $< + $(FC) $(FFLAGS) -c $< diff --git a/src/tests/ascii/Makefile.manual b/src/tests/ascii/Makefile.manual index a31be0380..7c0fa049c 100644 --- a/src/tests/ascii/Makefile.manual +++ b/src/tests/ascii/Makefile.manual @@ -10,7 +10,7 @@ LDFLAGS = -L../.. -lstdlib all: $(PROG) $(PROG): $(OBJS) - $(FC) $(FCFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS) + $(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS) test: ./$(PROG) @@ -19,4 +19,4 @@ clean: $(RM) $(PROG) $(OBJS) *.mod %.o: %.f90 - $(FC) $(FCFLAGS) $(CPPFLAGS) -c $< + $(FC) $(FFLAGS) $(CPPFLAGS) -c $< diff --git a/src/tests/loadtxt/Makefile.manual b/src/tests/loadtxt/Makefile.manual index d0841de47..90ccf3f68 100644 --- a/src/tests/loadtxt/Makefile.manual +++ b/src/tests/loadtxt/Makefile.manual @@ -11,7 +11,7 @@ OBJS = $(PROGS:=.o) all: $(PROGS) $(PROGS): %: %.o - $(FC) $(FCFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) + $(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) test: ./test_loadtxt @@ -23,4 +23,4 @@ clean: $(RM) $(PROGS) $(OBJS) tmp.dat tmp_qp.dat %.o: %.f90 - $(FC) $(FCFLAGS) $(CPPFLAGS) -c $< + $(FC) $(FFLAGS) $(CPPFLAGS) -c $< From 340051548c74ba9d78175722cdd8ca640a65e0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Fri, 3 Jan 2020 11:25:46 -0700 Subject: [PATCH 3/3] Remove .SUFFIXES as it is obsolete --- src/Makefile.manual | 1 - src/tests/ascii/Makefile.manual | 1 - src/tests/loadtxt/Makefile.manual | 1 - 3 files changed, 3 deletions(-) diff --git a/src/Makefile.manual b/src/Makefile.manual index 2d93464d8..0c27ff41c 100644 --- a/src/Makefile.manual +++ b/src/Makefile.manual @@ -6,7 +6,6 @@ OBJS = stdlib_experimental_ascii.o \ f18estop.o .PHONY: all clean -.SUFFIXES: $(SUFFIXES) .f90 .o all: $(LIB) diff --git a/src/tests/ascii/Makefile.manual b/src/tests/ascii/Makefile.manual index 7c0fa049c..4d555cb19 100644 --- a/src/tests/ascii/Makefile.manual +++ b/src/tests/ascii/Makefile.manual @@ -5,7 +5,6 @@ CPPFLAGS = -I../.. LDFLAGS = -L../.. -lstdlib .PHONY: all clean test -.SUFFIXES: $(SUFFIXES) .f90 .o all: $(PROG) diff --git a/src/tests/loadtxt/Makefile.manual b/src/tests/loadtxt/Makefile.manual index 90ccf3f68..f86861866 100644 --- a/src/tests/loadtxt/Makefile.manual +++ b/src/tests/loadtxt/Makefile.manual @@ -2,7 +2,6 @@ CPPFLAGS = -I../.. LDFLAGS = -L../.. -lstdlib .PHONY: all clean test -.SUFFIXES: $(SUFFIXES) .f90 .o PROGS = test_loadtxt test_savetxt test_loadtxt_qp test_savetxt_qp OBJS = $(PROGS:=.o)