-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
167 lines (134 loc) · 4.08 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
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
CC = gcc
CXX = g++
CFLAGS = \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_WITHOUT_ZONEMALLOC \
-DSTEPWAT \
-g \
-O0 \
-pthread \
-Wcast-align \
-Wformat \
-Wimplicit \
-Wmissing-prototypes \
-Wredundant-decls \
-Wstrict-prototypes \
-Wunused
sw2 = SOILWAT2
lib_sw2 = lib$(sw2).a
path_sw2 = sw_src
path_sw2lib = $(path_sw2)/bin
std_c++14 = -std=c++14
std_c99 = -std=c99
# Note: `-I$(path_sw2)` is required for `#include "external/pcg/pcg_basic.h"`
# in SOILWAT2 headers that are included by STEPWAT2 code
INC_DIRS = \
-I. \
-Isqlite-amalgamation \
-I$(path_sw2) \
-I$(path_sw2)/external/googletest/googletest \
-I$(path_sw2)/external/googletest/googletest/include \
-Itest
sources_core = \
sqlite-amalgamation/sqlite3.c \
ST_environs.c \
ST_grid.c \
ST_indivs.c \
ST_main.c \
ST_mortality.c \
ST_output.c \
ST_params.c \
ST_resgroups.c \
ST_species.c \
ST_sql.c \
ST_stats.c \
sxw.c \
sxw_environs.c \
sxw_resource.c \
sxw_soilwat.c \
sxw_sql.c \
ST_spinup.c \
ST_progressBar.c \
ST_seedDispersal.c \
ST_colonization.c
sources_test = \
$(path_sw2)/external/googletest/googletest/src/gtest-all.cc \
$(path_sw2)/external/googletest/googletest/src/gtest_main.cc \
test/test_ST_mortality.cc
sw2_sources = \
src/SW_Output_outarray.c \
src/SW_Output_outtext.c
objects_core = $(sources_core:%.c=obj/%.o)
objects_core_test = $(sources_core:%.c=obj/%_TEST.o)
objects_test = $(sources_test:%.cc=obj/%.o)
dir_obj = \
obj \
obj/sqlite-amalgamation
dir_test = \
obj/test \
obj/$(path_sw2)/external/googletest/googletest/src
sw_LDFLAGS = $(LDFLAGS) -L. -L$(path_sw2lib)
sw_LDLIBS = -l$(sw2) $(LDLIBS) -lm
all: $(path_sw2lib)/$(lib_sw2) stepwat
$(path_sw2lib)/$(lib_sw2):
# Note: `-I..` is required for `#include "ST_defines.h"`
# in SOILWAT2 headers that are included by SOILWAT2 code
@(cd $(path_sw2) && $(MAKE) lib \
CC="$(CC)" CPPFLAGS="$(CPPFLAGS) -I.." CFLAGS="$(CFLAGS)" set_std="$(std_c99)" AR="$(AR)" \
sw_sources="$(sw2_sources)")
stepwat: $(path_sw2lib)/$(lib_sw2) $(objects_core) | $(dir_obj)
$(CC) $(objects_core) $(CFLAGS) $(std_c99) $(CPPFLAGS) $(sw_LDLIBS) $(sw_LDFLAGS) -o stepwat
-@cp stepwat testing.sagebrush.master
-@cp stepwat testing.sagebrush.master/Stepwat_Inputs
stepwat_test: $(path_sw2lib)/$(lib_sw2) $(objects_core_test) $(objects_test) | $(dir_obj) $(dir_test)
$(CXX) $(objects_core_test) $(objects_test) $(std_c++14) $(CFLAGS) $(CPPFLAGS) $(sw_LDLIBS) $(sw_LDFLAGS) -o stepwat_test
obj/%.o: %.c | $(dir_obj)
$(CC) $(CFLAGS) $(std_c99) $(CPPFLAGS) $(INC_DIRS) -c $< -o $@
obj/%.o: %.cc | $(dir_obj)
$(CXX) $(CFLAGS) $(std_c++14) $(CPPFLAGS) $(INC_DIRS) -c $< -o $@
obj/%_TEST.o: %.c | $(dir_obj) $(dir_test)
$(CC) $(CFLAGS) $(std_c99) $(CPPFLAGS) $(INC_DIRS) -DSTDEBUG -c $< -o $@
#--- Create directories
$(dir_obj) $(dir_test):
-@mkdir -p $@
.PHONY: run_tests
run_tests: stepwat_test
./stepwat_test
.PHONY: bint_testing_nongridded
bint_testing_nongridded: stepwat
testing.sagebrush.master/Stepwat_Inputs/stepwat -d testing.sagebrush.master/Stepwat_Inputs -f files.in -o -i
.PHONY: bint_testing_gridded
bint_testing_gridded: stepwat
testing.sagebrush.master/stepwat -d testing.sagebrush.master -f files.in -g
.PHONY: cleanall
cleanall: clean output_clean
.PHONY: clean
clean: cleanobjs cleanbin documentation_clean
.PHONY: cleanobjs
cleanobjs:
-@find . -type f -name '*.o' -delete
-@(cd $(path_sw2) && $(MAKE) clean_build)
.PHONY: cleanbin
cleanbin:
-@rm -f stepwat
-@rm -f stepwat_test
-@rm -f testing.sagebrush.master/stepwat
-@rm -f testing.sagebrush.master/Stepwat_Inputs/stepwat
.PHONY: output_clean
output_clean:
-@rm -rf testing.sagebrush.master/Output/*
-@rm -rf testing.sagebrush.master/Stepwat_Inputs/Output/*
.PHONY : documentation_clean
documentation_clean :
@rm -rf Documentation/html
.PHONY : documentation
documentation:
@doxygen doxyfile
@if open Documentation/html/index.html; \
then echo "Success"; \
else if echo "Open failed. Attempting fallback method." && xdg-open Documentation/html/index.html; \
then echo "Success"; \
else echo "Failed to open documentation"; \
fi; \
fi