-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
216 lines (165 loc) · 6.14 KB
/
Makefile.in
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
MKDIR = mkdir
ROOTDIR = .
SRCDIR = $(ROOTDIR)/src
TARGETDIR ?= $(ROOTDIR)/target
OBJDIR = $(TARGETDIR)/obj
INCLUDEDIR = $(ROOTDIR)/include
SUBDIRS =
TESTSUBDIRS = test/unit
EXES = PiCoPiC
TESTDIR = testingdir
### Common settings
CEXTRA =
CXXEXTRA =
DEFINES =
INCLUDE_PATH = -I$(INCLUDEDIR)
LIBRARY_PATH =
LIBRARIES =
DOXYGEN = doxygen
DOXYGEN_CONFIGS = doc/app.conf doc/lib.conf doc/vis.conf
DOXYGEN_FORMATS = @WITH_DOXYGEN_FORMATS@
DOXYGEN_DIRS = doc/app doc/lib doc/vis
RELEASE = @RELEASE@
SUBPTHS = algo math phys current maxwellSolver collisions outEngine density temperature pusher
### PiCoPiC sources and settings
PiCoPiC_MODULE = PiCoPiC
PiCoPiC_C_SRCS =
PiCoPiC_CXX_SRCS := $(wildcard $(SRCDIR)/*.cpp) $(foreach d, $(SUBPTHS), $(wildcard $(SRCDIR)/$d/*.cpp))
PiCoPiC_LDFLAGS = @LDFLAGS_ADDITIONAL@
PiCoPiC_ARFLAGS =
PiCoPiC_LIBRARY_PATH =
PiCoPiC_LIBRARIES = $(LIBRARIES)
### picojson sources and settings
picojson_SUBDIR := $(ROOTDIR)/lib/picojson
INCLUDE_PATH += -I$(picojson_SUBDIR)
SUBDIRS += $(picojson_SUBDIR)
# PiCoPiC_LIBRARIES += picojson
# LDFLAGS += -L$(picojson_SUBDIR)
### loguru sources and settings
loguru_SUBDIR := $(ROOTDIR)/lib/loguru
INCLUDE_PATH += -I$(loguru_SUBDIR)
LDFLAGS += -L$(loguru_SUBDIR)
PiCoPiC_LIBRARIES += pthread
PiCoPiC_LIBRARIES += dl
loguru_DEFINES := -DLOGURU_WITH_STREAMS=1 -DLOGURU_THREADNAME_WIDTH=12
### link hdf5 and HighFive libraries
ifeq (@ENABLE_HDF5@, true)
PiCoPiC_LIBRARIES += hdf5
highfive_SUBDIR := $(ROOTDIR)/lib/HighFive/include
INCLUDE_PATH += -I$(highfive_SUBDIR)
else
PiCoPiC_CXX_SRCS_TMP := $(PiCoPiC_CXX_SRCS)
PiCoPiC_CXX_SRCS = $(filter-out $(SRCDIR)/outEngine/outEngineHDF5.cpp, $(PiCoPiC_CXX_SRCS_TMP))
endif
ifeq (@ENABLE_MPI@, true)
HDF5_ADDITIONAL_OPTIONS := --enable-parallel --enable-shared
endif
PiCoPiC_OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(PiCoPiC_CXX_SRCS))
PiCoPiC_OBJS += $(loguru_SUBDIR)/loguru.o
LDFLAGS += $(PiCoPiC_LDFLAGS)
### Global source lists
C_SRCS = $(PiCoPiC_C_SRCS)
CXX_SRCS = $(PiCoPiC_CXX_SRCS)
### Tools
ifeq (@ENABLE_MPI@, true)
CC := mpicc
CXX := mpic++
else
CC := gcc
CXX := g++
endif
RC = wrc
AR = ar
CFLAGS ?= @CFLAGS_DEFAULT@
CFLAGS += @CFLAGS_ADDITIONAL@
CXXFLAGS = ${CFLAGS}
### Generic targets
all: build python
build: prepare $(SUBDIRS) $(LIBS) $(EXES)
### Build rules
.PHONY: all clean dummy check-syntax prepare doxygen test test-perf test-h5 test-ext
$(SUBDIRS): dummy
cd $@ && $(MAKE)
$(DOXYGEN_FORMATS): doxygen
@for i in $(DOXYGEN_DIRS); do test -f $(ROOTDIR)/$$i/$@/Makefile && (cd $(ROOTDIR)/$$i/$@ && $(MAKE)) || true; done
# Implicit rules
.SUFFIXES: .cpp .cxx
DEFINCL = $(INCLUDE_PATH) $(DEFINES) $(OPTIONS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -c $(CXXFLAGS) $(CXXEXTRA) $(DEFINCL) -o $@ $<
### rule for loguru subdir
$(loguru_SUBDIR)/%.o: $(loguru_SUBDIR)/%.cpp
$(CXX) -c $(CXXFLAGS) $(CXXEXTRA) $(loguru_DEFINES) -o $@ $<
# Rules for cleaning
CLEAN_FILES = y.tab.c y.tab.h lex.yy.c core *.orig *.rej \
\\\#*\\\# *~ *% .\\\#*
BUILD_DIRS = $(OBJDIR) $(foreach d, $(SUBPTHS), $(OBJDIR)/$d) $(TARGETDIR)
clean: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__) $(TESTSUBDIRS:%=%/__clean__) $(DOXYGEN_FORMATS:%=%/__clean__)
$(RM) $(PiCoPiC_OBJS) $(CLEAN_FILES)
$(RM) $(LIBS) $(EXES) $(EXES:%=%.so)
$(RM) -r $(ROOTDIR)/tools/__pycache__/
$(RM) -r $(DOXYGEN_DIRS)
$(RM) -r $(TARGETDIR)
$(RM) -r $(TESTDIR)
cd $(ROOTDIR)/lib/python/picopic; \
python setup.py clean --all
$(SUBDIRS:%=%/__clean__): dummy
-cd `dirname $@` && $(MAKE) clean
$(DOXYGEN_FORMATS:%=%/__clean__): dummy
-cd `dirname doc/$@` && test -f Makefile && $(MAKE) clean || return 0
$(EXTRASUBDIRS:%=%/__clean__): dummy
-cd `dirname $@` && $(RM) $(CLEAN_FILES)
$(TESTSUBDIRS:%=%/__clean__): dummy
-cd `dirname $@` && $(MAKE) clean
$(PiCoPiC_MODULE): $(PiCoPiC_OBJS)
$(CXX) $(CXXFLAGS) $(CXXEXTRA) $(DEFINCL) $(LDFLAGS) -o $@ $(PiCoPiC_OBJS) $(PiCoPiC_LIBRARY_PATH) $(PiCoPiC_LIBRARIES:%=-l%)
distclean: clean
$(RM) -r *.avi *.png $(BUILD_DIRS) $(RELEASE) $(RELEASE).zip autom4te.cache config.log config.status configure Makefile scripts/*.sh simulation_result/
$(TESTSUBDIRS:%=%/__test__): dummy
cd `dirname $@` && $(MAKE) test
test-unit: $(TESTSUBDIRS:%=%/__test__)
test: clean test-unit
@python3 ./test/functional/test.py
test-perf:
@python3 ./test/performance/test.py -l 5
# test-ext: clean
# @python3 ./test/functional/test.py --type=ext
# test-regression: clean
# @python3 ./test/functional/test.py --type=regression --fastmath
# test-tools: test
# TESTDIR=$(TESTDIR) /bin/bash ./test/functional/tools.sh
test-full: test-unit test-perf test
check-syntax:
$(CXX) $(LIBRARY_PATH) $(INCLUDE_PATH) $(CXXFLAGS) -Wall -Wextra -pedantic -fsyntax-only $(PiCoPiC_CXX_SRCS)
prepare:
@$(MKDIR) -p $(BUILD_DIRS)
doxygen:
for i in $(shell ls doc/*.svg); do convert $$i $$(dirname $$i)/$$(basename $$i .svg).png; done
for i in $(DOXYGEN_CONFIGS); do $(DOXYGEN) $$i; done
doc: doxygen $(DOXYGEN_FORMATS)
# dist: all doc
# cp PiCoPiC $(RELEASE)
# cp -r CHANGELOG.md $(RELEASE)
# cp -r tools $(RELEASE)/tools
# $(MKDIR) -p $(RELEASE)/doc
# cp doc/app/latex/refman.pdf $(RELEASE)/doc/PiCoPiC.pdf
# cp doc/vis/latex/refman.pdf $(RELEASE)/doc/visualization.pdf
# zip -r `basename $(RELEASE)`.zip $(RELEASE)
hdf5: prepare
test -d $(TARGETDIR)/hdf5-@HDF5_VERSION@ || \
(cd $(TARGETDIR); \
wget -qO- "@HDF5_URL@" | tar xjf -; \
cd hdf5-@HDF5_VERSION@; \
./autogen.sh; \
./configure --enable-build-mode=production --prefix=@prefix@ $(HDF5_ADDITIONAL_OPTIONS); \
make)
hdf5-install: hdf5
cd $(TARGETDIR)/hdf5-@HDF5_VERSION@; \
make install
python:
cd $(ROOTDIR)/lib/python/picopic; \
python setup.py install
pack-release:
@tar -czpf PiCoPiC_$(RELEASE).tar.gz ./PiCoPiC ./PiCoPiC.json lib/python/picopic/ tools/ doc/app/html/ doc/app/latex/refman.pdf doc/vis/html/ doc/vis/latex/refman.pdf
.install-hooks:
cp -a tools/git_hooks/pre-commit .git/hooks