Skip to content

Commit 84c75fb

Browse files
authored
Merge pull request #74 from certik/make2
Further Makefile improvements
2 parents 339299c + 158f48f commit 84c75fb

File tree

4 files changed

+50
-46
lines changed

4 files changed

+50
-46
lines changed

src/Makefile.manual

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
SRC = stdlib_experimental_ascii.f90 \
2+
stdlib_experimental_error.f90 \
3+
stdlib_experimental_io.f90 \
4+
f18estop.f90
5+
16
LIB = libstdlib.a
27

3-
OBJS = stdlib_experimental_ascii.o \
4-
stdlib_experimental_error.o \
5-
stdlib_experimental_io.o \
6-
f18estop.o
8+
9+
10+
OBJS = $(SRC:.f90=.o)
11+
MODS = $(OBJS:.o=.mod)
12+
SMODS = $(OBJS:.o=*.smod)
713

814
.PHONY: all clean
915

@@ -13,7 +19,11 @@ $(LIB): $(OBJS)
1319
ar rcs $@ $(OBJS)
1420

1521
clean:
16-
$(RM) $(LIB) $(OBJS) *.mod
22+
$(RM) $(LIB) $(OBJS) $(MODS) $(SMODS)
1723

1824
%.o: %.f90
1925
$(FC) $(FFLAGS) -c $<
26+
27+
28+
# Fortran module dependencies
29+
f18estop.o: stdlib_experimental_error.o

src/tests/Makefile.manual.test.mk

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Common Makefile rules that are included from each test subdirectory's
2+
# Makefile
3+
4+
CPPFLAGS += -I../..
5+
LDFLAGS += -L../.. -lstdlib
6+
7+
OBJS = $(PROGS_SRC:.f90=.o)
8+
PROGS = $(OBJS:.o=)
9+
TESTPROGS = $(PROGS:=TEST)
10+
11+
.PHONY: all clean test $(TESTPROGS)
12+
13+
all: $(PROGS)
14+
15+
test: $(TESTPROGS)
16+
17+
$(TESTPROGS):
18+
./$(@:TEST=)
19+
20+
clean:
21+
$(RM) $(PROGS) $(OBJS) $(CLEAN_FILES)
22+
23+
%.o: %.f90
24+
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<
25+
26+
$(PROGS): %: %.o
27+
$(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS)

src/tests/ascii/Makefile.manual

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
PROG = test_ascii
2-
OBJS = test_ascii.o
1+
PROGS_SRC = test_ascii.f90
32

4-
CPPFLAGS = -I../..
5-
LDFLAGS = -L../.. -lstdlib
63

7-
.PHONY: all clean test
8-
9-
all: $(PROG)
10-
11-
$(PROG): $(OBJS)
12-
$(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS)
13-
14-
test:
15-
./$(PROG)
16-
17-
clean:
18-
$(RM) $(PROG) $(OBJS) *.mod
19-
20-
%.o: %.f90
21-
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<
4+
include ../Makefile.manual.test.mk

src/tests/loadtxt/Makefile.manual

+6-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
CPPFLAGS = -I../..
2-
LDFLAGS = -L../.. -lstdlib
1+
PROGS_SRC = test_loadtxt.f90 \
2+
test_savetxt.f90 \
3+
test_loadtxt_qp.f90 \
4+
test_savetxt_qp.f90
35

4-
.PHONY: all clean test
6+
CLEAN_FILES = tmp.dat tmp_qp.dat
57

6-
PROGS = test_loadtxt test_savetxt test_loadtxt_qp test_savetxt_qp
7-
OBJS = $(PROGS:=.o)
88

9-
10-
all: $(PROGS)
11-
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
20-
21-
clean:
22-
$(RM) $(PROGS) $(OBJS) tmp.dat tmp_qp.dat
23-
24-
%.o: %.f90
25-
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<
9+
include ../Makefile.manual.test.mk

0 commit comments

Comments
 (0)