diff --git a/src/Makefile.manual b/src/Makefile.manual index 0c27ff41c..71b6a8a31 100644 --- a/src/Makefile.manual +++ b/src/Makefile.manual @@ -1,9 +1,15 @@ +SRC = stdlib_experimental_ascii.f90 \ + stdlib_experimental_error.f90 \ + stdlib_experimental_io.f90 \ + f18estop.f90 + LIB = libstdlib.a -OBJS = stdlib_experimental_ascii.o \ - stdlib_experimental_error.o \ - stdlib_experimental_io.o \ - f18estop.o + + +OBJS = $(SRC:.f90=.o) +MODS = $(OBJS:.o=.mod) +SMODS = $(OBJS:.o=*.smod) .PHONY: all clean @@ -13,7 +19,11 @@ $(LIB): $(OBJS) ar rcs $@ $(OBJS) clean: - $(RM) $(LIB) $(OBJS) *.mod + $(RM) $(LIB) $(OBJS) $(MODS) $(SMODS) %.o: %.f90 $(FC) $(FFLAGS) -c $< + + +# Fortran module dependencies +f18estop.o: stdlib_experimental_error.o diff --git a/src/tests/Makefile.manual.test.mk b/src/tests/Makefile.manual.test.mk new file mode 100644 index 000000000..ee0eed31e --- /dev/null +++ b/src/tests/Makefile.manual.test.mk @@ -0,0 +1,27 @@ +# Common Makefile rules that are included from each test subdirectory's +# Makefile + +CPPFLAGS += -I../.. +LDFLAGS += -L../.. -lstdlib + +OBJS = $(PROGS_SRC:.f90=.o) +PROGS = $(OBJS:.o=) +TESTPROGS = $(PROGS:=TEST) + +.PHONY: all clean test $(TESTPROGS) + +all: $(PROGS) + +test: $(TESTPROGS) + +$(TESTPROGS): + ./$(@:TEST=) + +clean: + $(RM) $(PROGS) $(OBJS) $(CLEAN_FILES) + +%.o: %.f90 + $(FC) $(FFLAGS) $(CPPFLAGS) -c $< + +$(PROGS): %: %.o + $(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) diff --git a/src/tests/ascii/Makefile.manual b/src/tests/ascii/Makefile.manual index 4d555cb19..8edb7b893 100644 --- a/src/tests/ascii/Makefile.manual +++ b/src/tests/ascii/Makefile.manual @@ -1,21 +1,4 @@ -PROG = test_ascii -OBJS = test_ascii.o +PROGS_SRC = test_ascii.f90 -CPPFLAGS = -I../.. -LDFLAGS = -L../.. -lstdlib -.PHONY: all clean test - -all: $(PROG) - -$(PROG): $(OBJS) - $(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS) - -test: - ./$(PROG) - -clean: - $(RM) $(PROG) $(OBJS) *.mod - -%.o: %.f90 - $(FC) $(FFLAGS) $(CPPFLAGS) -c $< +include ../Makefile.manual.test.mk diff --git a/src/tests/loadtxt/Makefile.manual b/src/tests/loadtxt/Makefile.manual index f86861866..9cd8fe487 100644 --- a/src/tests/loadtxt/Makefile.manual +++ b/src/tests/loadtxt/Makefile.manual @@ -1,25 +1,9 @@ -CPPFLAGS = -I../.. -LDFLAGS = -L../.. -lstdlib +PROGS_SRC = test_loadtxt.f90 \ + test_savetxt.f90 \ + test_loadtxt_qp.f90 \ + test_savetxt_qp.f90 -.PHONY: all clean test +CLEAN_FILES = tmp.dat tmp_qp.dat -PROGS = test_loadtxt test_savetxt test_loadtxt_qp test_savetxt_qp -OBJS = $(PROGS:=.o) - -all: $(PROGS) - -$(PROGS): %: %.o - $(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) - -test: - ./test_loadtxt - ./test_loadtxt_qp - ./test_savetxt - ./test_savetxt_qp - -clean: - $(RM) $(PROGS) $(OBJS) tmp.dat tmp_qp.dat - -%.o: %.f90 - $(FC) $(FFLAGS) $(CPPFLAGS) -c $< +include ../Makefile.manual.test.mk