-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (87 loc) · 2.97 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
# Generic Makefile
# Brandon Runnels
RESET = '\033[0m'
B_ON = '\033[1m'
FG_RED = '\033[31m'
FG_GREEN = '\033[32m'
FG_YELLOW = '\033[33m'
FG_BLUE = '\033[34m'
CC = g++
CPP_COMPILER_OPTIONS += -c -g3 -ggdb -fopenmp -Wno-deprecated -Wunused-variable -DMUPARSER
CPP_LINKER_OPTIONS += -g3 -ggdb -fopenmp
INC_PYTHON = $(shell python3-config --cflags)
LIB_PYTHON = $(shell python3-config --ldflags)
PYTHON_NAME = py/wield$(shell python3-config --extension-suffix)
ifdef EMACS
PREFIX = $(shell pwd)/
endif
EXCLUDE = $(PREFIX)/src/MainOld.cpp
SRC_MAIN = $(filter-out $(EXCLUDE), $(shell find ./src/ -name '*.cc'))
EXE = bin/wield
SRC = $(filter-out $(EXCLUDE), $(shell find ./src/ -mindepth 2 -name '*.cpp'))
HDR = $(filter-out $(EXCLUDE), $(shell find ./inc/ ./src/ -name '*.h'))
OBJ = $(subst ./src/,./obj/, $(SRC:.cpp=.o))
OBJ_MAIN = $(subst ./src/,./obj/, $(SRC_MAIN:.cc=.o))
INC = -O3 -I./src \
-I./inc \
-I./extern/eigen/
LIB = $(LIB_EXT) -lmuparser
.SECONDARY: $(OBJ) $(OBJ_MAIN)
default: make_directories $(EXE)
all: make_directories $(EXE) python
@echo $(B_ON)$(FG_GREEN)"###"
@echo "### DONE"
@echo "###"$(RESET)
python: make_directories $(PYTHON_NAME)
@echo $(B_ON)$(FG_GREEN)"###"
@echo "### DONE"
@echo "###"$(RESET)
$(PYTHON_NAME): ./py/python.cpp $(SRC) $(HDR)
@echo $(B_ON)$(FG_BLUE)"###"
@echo "### LINKING $@"
@echo "###"$(RESET)
$(CC) -DWIELD_PYTHON $(INC) -I./extern/pybind11/include/ -O3 -Wall -shared -std=c++11 -fPIC $(INC_PYTHON) py/python.cpp -o $@
bin/wield: ./obj/wield.o $(OBJ)
@echo $(B_ON)$(FG_BLUE)"###"
@echo "### LINKING $@"
@echo "###"$(RESET)
@mkdir -p $(dir $@)
$(CC) ${CPP_LINKER_OPTIONS} -o $@ $^ $(LIB)
./obj/%.o: ./src/%.cpp
@echo $(B_ON)$(FG_YELLOW)"###"
@echo "### COMPILING $<"
@echo "###"$(RESET)
@mkdir -p $(dir $@)
$(CC) $(CPP_COMPILER_OPTIONS) $(INC) -o $@ $(PREFIX)$<
./obj/%.o: ./src/%.cc $(HDR)
@echo $(B_ON)$(FG_YELLOW)"###"
@echo "### COMPILING $<"
@echo "###"$(RESET)
$(CC) $(CPP_COMPILER_OPTIONS) $(INC) -o $@ $(PREFIX)$<
make_directories: $(SRC)
git submodule update --init --recursive
mkdir -p $(dir $(OBJ)) $(dir $(OBJ_MAIN)) bin
%.cpp: $(HDR)
%.cc: $(HDR)
%.h :
#
# Unit Tests
#
test: test-csl test-energy1d
TEST_DIRS_CSL = $(shell find tests -mindepth 1 -type d -name "csl*"| sort)
test-csl: $(TEST_DIRS_CSL:=/output.dat)
TEST_DIRS_ENERGY1D = $(shell find tests -mindepth 1 -type d -name "energy1d*"| sort)
test-energy1d: $(TEST_DIRS_ENERGY1D:=/output.dat)
%/output.dat: .FORCE
-@python3 scripts/unit_test.py $(@:output.dat=)
.FORCE:
#
# Utility Targets
#
clean:
@echo $(B_ON)$(FG_RED)"###"
@echo "### Cleaning out ./obj, ./bin, *~, *#"
@echo "###"$(RESET)
rm -rf ${OBJ} ${OBJ_MAIN} ${EXE} ./bin/* *~ *\# $(PYTHON_NAME)
tidy:
rm -rf *~ *\# src/*~ src/*\# dat/*~ dat/*\# inc/*~ inc/*\#