-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (47 loc) · 1.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
VER = 0.1.0
FC = gfortran
PREFIX ?= /usr/local
SRCDIR = src
LIBDIR = lib
INCDIR = include
TESTDIR = test
MODFLAG = -J
FCFLAGS ?= $(MODFLAG)$(INCDIR) -g -Wall -DUSE_DOUBLE
LDFLAGS ?= -L$(HOME)/local/xdrfile/lib
LIBS ?= -lxdrfile
LIBNAME = trjfort
LIB_TRJFORT := $(addsuffix .a, $(addprefix lib, $(LIBNAME)))
LIB_TRJFORT := $(addprefix $(LIBDIR)/, $(LIB_TRJFORT))
OBJS = varpars.o xyz.o xdr.o trjfort.o
OBJS := $(addprefix $(SRCDIR)/, $(OBJS))
TEST1 = test1.out
TESTBINS = $(TEST1)
TESTBINS := $(addprefix $(TESTDIR)/, $(TESTBINS))
TESTOBJS = test.o
TESTOBJS := $(addprefix $(TESTDIR)/, $(TESTOBJS))
.PHONY: all build test install clean
all: build test
# =========================
build: $(LIB_TRJFORT)
$(LIB_TRJFORT): $(OBJS)
ar cr $@ $^
$(OBJS): | $(LIBDIR) $(INCDIR)
$(LIBDIR):
mkdir -p $(LIBDIR)
$(INCDIR):
mkdir -p $(INCDIR)
$(SRCDIR)/trjfort.o: $(addprefix $(SRCDIR)/, varpars.o xyz.o xdr.o)
$(SRCDIR)/xyz.o: $(SRCDIR)/varpars.o
$(SRCDIR)/xdr.o: $(SRCDIR)/varpars.o
# =========================
test: $(TESTBINS)
cd $(TESTDIR) && ./$(TEST1)
$(TESTDIR)/$(TEST1): $(LIB_TRJFORT) $(TESTOBJS)
$(FC) $(FCFLAGS) $^ -o $@ -L$(LIBDIR) -l$(LIBNAME) $(LDFLAGS) $(LIBS)
# =========================
%.o : %.F90
$(FC) -c $(FCFLAGS) $< -o $@
# =========================
clean:
rm -rf $(INCDIR) $(LIBDIR) $(OBJS) $(SRCDIR)/*.mod
rm -rf $(TESTBINS) $(TESTOBJS) $(TESTDIR)/*.mod $(TESTDIR)/*.xyz $(TESTDIR)/*.trr