forked from stan-dev/stan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
196 lines (166 loc) · 5.92 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
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
# Makefile for Stan.
##
# The default target of this Makefile is...
help:
## Disable implicit rules.
.SUFFIXES:
##
# Users should only need to set these three variables for use.
# - CC: The compiler to use. Expecting g++ or clang++.
# - O: Optimization level. Valid values are {0, 1, 2, 3}.
# - AR: archiver (must specify for cross-compiling)
# - OS_TYPE: {mac, win, linux}
##
##
# Library locations
##
STAN ?=
MATH ?= lib/stan_math/
-include $(MATH)make/default_compiler_options
CXXFLAGS += -I src -isystem $(MATH) -DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs
LDLIBS_STANC = -Lbin -lstanc
-include $(HOME)/.config/stan/make.local # define local variables
-include make/local # overwrite local variables
CXX = $(CC)
-include $(MATH)make/libraries
##
# Get information about the compiler used.
# - CC_TYPE: {g++, clang++, mingw32-g++, other}
# - CC_MAJOR: major version of CC
# - CC_MINOR: minor version of CC
##
-include $(MATH)make/detect_cc
# OS_TYPE is set automatically by this script
##
# These includes should update the following variables
# based on the OS:
# - CFLAGS
# - GTEST_CXXFLAGS
# - EXE
##
-include $(MATH)make/detect_os
include make/libstan # bin/libstan.a bin/libstanc.a
include make/tests # tests
include make/doxygen # doxygen
include make/manual # manual: manual, doc/stan-reference.pdf
include make/cpplint # cpplint
##
# Dependencies
##
ifneq (,$(filter-out test-headers generate-tests clean% %-test math-% %.d,$(MAKECMDGOALS)))
-include $(addsuffix .d,$(subst $(EXE),,$(MAKECMDGOALS)))
endif
bin/%.o : src/%.cpp
@mkdir -p $(dir $@)
$(COMPILE.cc) -O$O $(OUTPUT_OPTION) $<
##
# Rule for generating dependencies.
##
bin/%.d : src/%.cpp
@mkdir -p $(dir $@)
@set -e; \
rm -f $@; \
$(COMPILE.cc) -O$O $(TARGET_ARCH) -MM $< > $@.$$$$; \
sed -e 's,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1\.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
.PHONY: help
help:
@echo '--------------------------------------------------------------------------------'
@echo 'Stan makefile:'
@echo ' Current configuration:'
@echo ' - OS_TYPE (Operating System): ' $(OS_TYPE)
@echo ' - CC (Compiler): ' $(CC)
@echo ' - Compiler version: ' $(CC_MAJOR).$(CC_MINOR)
@echo ' - O (Optimization Level): ' $(O)
@echo ' - O_STANC (Opt for stanc): ' $(O_STANC)
ifdef TEMPLATE_DEPTH
@echo ' - TEMPLATE_DEPTH: ' $(TEMPLATE_DEPTH)
endif
@echo ' - STAN_HOME ' $(STAN_HOME)
@echo ' Library configuration:'
@echo ' - EIGEN ' $(EIGEN)
@echo ' - BOOST ' $(BOOST)
@echo ' - GTEST ' $(GTEST)
@echo ''
@echo 'Common targets:'
@echo ' Documentation:'
@echo ' - doc : Builds the documention and copies to doc/'
@echo ' (requires LaTeX and bookdown installation)'
@echo ' - doxygen : Builds the API documentation. The documentation is located'
@echo ' doc/api/'
@echo ' (requires doxygen installation)'
@echo ' Submodule:'
@echo ' - math-revert : Resets the Stan Math Library git submodule to the tagged'
@echo ' version'
@echo ' - math-update : Updates the Stan Math Library git submodule to the latest'
@echo ' development version'
@echo ' - math-update/<branch-name> : Updates the Stan Math Library git submodule to'
@echo ' the branch specified'
@echo ''
@echo 'Tests:'
@echo ''
@echo ' Unit tests are built through make by specifying the executable as the target'
@echo ' to make. For a test in src/test/*_test.cpp, the executable is test/*$(EXE).'
@echo ''
@echo ' Header tests'
@echo ' - test-headers : tests all source headers to ensure they are compilable and'
@echo ' include enough header files.'
@echo ''
@echo ' To run a single header test, add "-test" to the end of the file name.'
@echo ' Example: make src/stan/math/constants.hpp-test'
@echo ''
@echo ' Cpplint'
@echo ' - cpplint : runs cpplint.py on source files. requires python 2.7.'
@echo ' cpplint is called using the CPPLINT variable:'
@echo ' CPPLINT = $(CPPLINT)'
@echo ' To set the version of python 2, set the PYTHON2 variable:'
@echo ' PYTHON2 = $(PYTHON2)'
@echo ''
@echo 'Clean:'
@echo ' - clean : Basic clean. Leaves doc and compiled libraries intact.'
@echo ' - clean-manual : Cleans temporary files from building the manual.'
@echo ' - clean-deps : Removes dependency files for tests. If tests stop building,'
@echo ' run this target.'
@echo ' - clean-all : Cleans up all of Stan.'
@echo ''
@echo 'Higher level targets:'
@echo ' - docs : Builds all docs.'
@echo ''
@echo '--------------------------------------------------------------------------------'
##
# Documentation
##
.PHONY: docs
docs: doc doxygen
##
# Clean up.
##
MODEL_SPECS := $(shell find src/test -type f -name '*.stan')
.PHONY: clean clean-demo clean-dox clean-manual clean-models clean-all clean-deps
clean:
$(RM) $(shell find src -type f -name '*.dSYM') $(shell find src -type f -name '*.d.*')
$(RM) $(wildcard $(MODEL_SPECS:%.stan=%.hpp))
$(RM) $(wildcard $(MODEL_SPECS:%.stan=%$(EXE)))
$(RM) $(wildcard $(MODEL_SPECS:%.stan=%.o))
$(RM) $(wildcard $(MODEL_SPECS:%.stan=%.d))
clean-dox:
$(RM) -r doc/api
clean-deps:
@echo ' removing dependency files'
$(shell find . -type f -name '*.d' -exec rm {} +)
clean-all: clean clean-docs clean-deps clean-libraries
$(RM) -r test bin
@echo ' removing .o files'
$(shell find src -type f -name '*.o' -exec rm {} +)
##
# Submodule related tasks
##
.PHONY: math-revert
math-revert:
git submodule update --init --recursive
.PHONY: math-update
math-update:
git submodule init
git submodule update --recursive
math-update/%: math-update
cd $(MATH) && git fetch --all && git checkout $* && git pull