-
Notifications
You must be signed in to change notification settings - Fork 5
/
makefile
133 lines (104 loc) · 3.73 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
##
## @file makefile
## @brief PINC makefile.
## @author Sigvald Marholm <[email protected]>
##
CC = mpicc
COPT = -O3
CLOCAL = -Ilib/iniparser/src\
-lm -lgsl -lblas -lhdf5 -lfftw3
LLOCAL = -Ilib/iniparser/src\
-lm -lgsl -lblas -lhdf5 -lfftw3
-include local.mk
EXEC = pinc
CADD = # Additional CFLAGS accessible from CLI
CFLAGS = -std=c11 -Wall $(CLOCAL) $(COPT) $(CADD) # Flags for compiling
LFLAGS = -std=c11 -Wall $(LLOCAL) $(COPT) $(CADD) # Flags for linking
SDIR = src
ODIR = src/obj
HDIR = src
LDIR = lib
DDIR = doc
TSDIR = test
TODIR = test/obj
THDIR = test
HEAD_ = core.h io.h aux.h population.h grid.h pusher.h multigrid.h object.h spectral.h units.h
SRC_ = io.c aux.c population.c grid.c pusher.c multigrid.c object.c spectral.c units.c
OBJ_ = $(SRC_:.c=.o)
DOC_ = main.dox
TESTOBJ_= test.o $(SRC_:.c=.test.o)
#TESTOBJ_ = test.o aux.test.o
TESTHEAD_ = test.h
HEAD = $(patsubst %,$(HDIR)/%,$(HEAD_))
SRC = $(patsubst %,$(SDIR)/%,$(SRC_))
OBJ = $(patsubst %,$(ODIR)/%,$(OBJ_))
TESTOBJ = $(patsubst %,$(TODIR)/%,$(TESTOBJ_))
TESTHEAD= $(patsubst %,$(THDIR)/%,$(TESTHEAD_))
LIBOBJ_ = iniparser/libiniparser.a
LIBHEAD_= iniparser/src/iniparser.h
LIBOBJ = $(patsubst %,$(LDIR)/%,$(LIBOBJ_))
LIBHEAD = $(patsubst %,$(LDIR)/%,$(LIBHEAD_))
all: version $(EXEC) cleantestdata doc
local: version $(EXEC).local cleantestdata doc
test: version $(EXEC).test cleantestdata doc
@echo "Running Unit Tests"
@echo $(TEST)
@./$(EXEC) input.ini
$(EXEC).test: $(TODIR)/main.test.o $(OBJ) $(TESTOBJ) $(LIBOBJ)
@echo "Linking Unit Tests"
@$(CC) $^ -o $(EXEC) $(LFLAGS)
@echo "PINC is built"
$(EXEC).local: $(ODIR)/main.local.o $(OBJ) $(LIBOBJ)
@echo "Linking PINC (using main.local.c)"
@$(CC) $^ -o $(EXEC) $(LFLAGS)
@echo "PINC is built"
$(EXEC): $(ODIR)/main.o $(OBJ) $(LIBOBJ)
@echo "Linking PINC"
@$(CC) $^ -o $@ $(LFLAGS)
@echo "PINC is built"
$(ODIR)/%.o: $(SDIR)/%.c $(HEAD)
@echo "Compiling $<"
@echo $(HEAD) | xargs -n1 ./aux/check.sh
@mkdir -p $(ODIR)
@./aux/check.sh $<
@$(CC) -c $< -o $@ $(CFLAGS)
$(TODIR)/%.o: $(TSDIR)/%.c $(HEAD) $(TESTHEAD)
@echo "Compiling $<"
@echo $(TESTHEAD) | xargs -n1 ./aux/check.sh
@mkdir -p $(TODIR)
@./aux/check.sh $<
@$(CC) -c $< -o $@ -Isrc $(CFLAGS)
$(LDIR)/iniparser/libiniparser.a: $(LIBHEAD)
@echo "Building iniparser"
@cd $(LDIR)/iniparser && $(MAKE) libiniparser.a > /dev/null 2>&1
.phony: version
version:
@echo "Embedding git version"
@echo "#define VERSION \"$(shell git describe --abbrev=4 --dirty --always --tags)\"" > $(SDIR)/version.h
$(DDIR)/doxygen/doxyfile.inc: $(DDIR)/doxygen/doxyfile.mk $(THDIR)/test.h $(TSDIR)/test.c $(DDIR)/doxygen/$(DOC_)
@echo INPUT = ../../$(SDIR) ../../$(HDIR) ../../$(TSDIR) ../../$(THDIR) ../../$(DDIR)/doxygen > $(DDIR)/doxygen/doxyfile.inc
@echo FILE_PATTERNS = $(HEAD_) $(SRC_) $(DOC_) test.h test.c >> $(DDIR)/doxygen/doxyfile.inc
doc: $(HEAD) $(SRC) $(DDIR)/doxygen/doxyfile.inc
@echo "Making documentation (run \"make pdf\" to get pdf)"
@cd $(DDIR)/doxygen && doxygen doxyfile.mk > /dev/null 2>&1
@ln -sf doc/html/index.html doc.html
pdf: doc
@echo "Making PDF"
cd $(DDIR)/latex && $(MAKE) # Intentionally verbose to spot LaTeX errors
cleandoc:
@echo "Cleaning documentation"
@rm -f $(DDIR)/doxygen/doxyfile.inc
@rm -fr $(DDIR)/html $(DDIR)/latex
@rm -f doc.html
cleantestdata:
@echo "Cleaning test data"
@mv data/obj.grid.h5 data/temp 2> /dev/null || true
@rm -f data/*.h5 data/parsedump.txt
@mv data/temp data/obj.grid.h5 2> /dev/null || true
clean: cleandoc cleantestdata
@echo "Cleaning compilation files (run \"make veryclean\" to clean more)"
@rm -f *~ $(TODIR)/*.o $(ODIR)/*.o $(SDIR)/*.o $(SDIR)/*~ gmon.out ut
veryclean: clean
@echo "Cleaning executable and iniparser"
@rm -f $(EXEC)
@cd $(LDIR)/iniparser && $(MAKE) veryclean > /dev/null 2>&1