-
-
Notifications
You must be signed in to change notification settings - Fork 370
/
makefile
139 lines (124 loc) · 4.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
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
##
# Stan
# -----------------
#
# To customize your build, set make variables in make/local
## 'help' is the default make target.
help:
-include make/local # user-defined variables
MATH ?= lib/stan_math/
RAPIDJSON ?= lib/rapidjson_1.1.0/
-include $(MATH)make/compiler_flags
-include $(MATH)make/dependencies
-include $(MATH)make/libraries
include make/doxygen # doxygen
include make/cpplint # cpplint
include make/tests # tests
include make/clang-tidy
INC_FIRST = -I $(if $(STAN),$(STAN)/src,src) -I ./src/ -I $(RAPIDJSON)
.PHONY: help
help:
@echo '--------------------------------------------------------------------------------'
@echo 'Note: testing of Stan is typically done with the `runTests.py` python script.'
@echo ' See https://github.com/stan-dev/stan/wiki/Testing-Stan-using-Gnu-Make-and-Python'
@echo ' for more detail on testing.'
@echo ''
@echo 'Stan makefile:'
@$(MAKE) print-compiler-flags
@echo ''
@echo 'Common targets:'
@echo ' Documentation:'
@echo ' - doxygen : Builds the API documentation. The documentation is located'
@echo ' doc/api/'
@echo ' (requires doxygen installation)'
@echo ' Submodule:'
@echo ' - math-revert : Reverts the Stan Math Library git submodule to the hash'
@echo ' recorded in the Stan library'
@echo ' - math-update : Updates the Stan Math Library git submodule branch,'
@echo ' e.g. if the Math branch is `develop`, it will fetch the'
@echo ' the latest version of `develop`'
@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 ' Clang Tidy'
@echo ' - clang-tidy : runs the clang-tidy makefile over the test suite.'
@echo ' Options:'
@echo ' files: (Optional) regex for file names to include in the check'
@echo ' Default runs all the tests in unit'
@echo ' tidy_checks: (Optional) A set of checks'
@echo ' Default runs a hand picked selection of tests'
@echo ''
@echo ' Example: This runs clang-tidy over all the multiply tests in prim'
@echo ''
@echo ' make clang-tidy files=*prim*multiply*'
@echo ''
@echo ' - clang-tidy-fix : same as above but runs with the -fix flag.'
@echo ' For automated fixes, outputs a yaml named'
@echo ' .clang-fixes.yml'
@echo ''
@echo ' Clang Format'
@echo ' - clang-format : runs clang-format over all the .hpp and .cpp files.'
@echo ' in src.'
@echo ''
@echo 'Clean:'
@echo ' - clean : Basic clean. Leaves doc and compiled libraries intact.'
@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 '--------------------------------------------------------------------------------'
##
# Clean up.
##
MODEL_SPECS := $(call findfiles,src/test,*.stan)
.PHONY: clean clean-demo clean-dox clean-models clean-all clean-deps
clean:
$(RM) $(call findfiles,src,*.dSYM) $(call findfiles,src,*.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'
$(RM) $(call findfiles,./,*.d)
clean-all: clean clean-dox clean-deps clean-libraries
$(RM) -r test bin
@echo ' removing .o files'
$(RM) $(call findfiles,src/,*.o)
##
# 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
##
# Debug target that allows you to print a variable
##
print-% : ; @echo $* = $($*)