Skip to content

Further Makefile improvements #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/Makefile.manual
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
27 changes: 27 additions & 0 deletions src/tests/Makefile.manual.test.mk
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 2 additions & 19 deletions src/tests/ascii/Makefile.manual
Original file line number Diff line number Diff line change
@@ -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
28 changes: 6 additions & 22 deletions src/tests/loadtxt/Makefile.manual
Original file line number Diff line number Diff line change
@@ -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