Skip to content
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

Refactor the manual Makefiles #70

Merged
merged 3 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
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 11 additions & 7 deletions Makefile.manual
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# Fortran stdlib Makefile

FC = gfortran
FCFLAGS=-O0
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all

.PHONY: all clean
export FC
export FFLAGS

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
Expand Down
21 changes: 10 additions & 11 deletions src/Makefile.manual
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
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 $<
all: $(LIB)

%.o: %.mod

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) $(FFLAGS) -c $<
12 changes: 6 additions & 6 deletions src/tests/Makefile.manual
Original file line number Diff line number Diff line change
@@ -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
24 changes: 14 additions & 10 deletions src/tests/ascii/Makefile.manual
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
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

all: test_ascii
all: $(PROG)

test_ascii: test_ascii.f90 $(OBJS)
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
$(PROG): $(OBJS)
$(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LDFLAGS)

%.o: %.mod
test:
./$(PROG)

clean:
$(RM) test_ascii
$(RM) *.o *.mod
$(RM) $(PROG) $(OBJS) *.mod

%.o: %.f90
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<
29 changes: 17 additions & 12 deletions src/tests/loadtxt/Makefile.manual
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
CPPFLAGS = -I../..
OBJS = ../../stdlib_experimental_error.o \
../../stdlib_experimental_io.o
LDFLAGS = -L../.. -lstdlib

.PHONY: all clean
.SUFFIXES: .f90 .o
.PHONY: all clean test

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) $(FFLAGS) $(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) $(FFLAGS) $(CPPFLAGS) -c $<