-
Notifications
You must be signed in to change notification settings - Fork 344
/
Makefile
174 lines (132 loc) · 5.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
168
169
170
171
172
173
174
#########################################################################
#
# This is the master makefile.
# Here we put all the top-level make targets, platform-independent
# rules, etc.
#
# Run 'make help' to list helpful targets.
#
#########################################################################
ifdef NOCMAKE
#########################################################################
# When not using CMake, the top-level Makefile is just a stub that
# merely includes src/make/master.mk
#########################################################################
include src/make/master.mk
else
.PHONY: all debug profile clean realclean nuke doxygen
working_dir := ${shell pwd}
# Figure out which architecture we're on
include ${working_dir}/src/make/detectplatform.mk
# Presence of make variables DEBUG and PROFILE cause us to make special
# builds, which we put in their own areas.
ifdef DEBUG
variant +=.debug
endif
ifdef PROFILE
variant +=.profile
endif
# Set up variables holding the names of platform-dependent directories
top_build_dir := build
build_dir := ${top_build_dir}/${platform}${variant}
top_dist_dir := dist
dist_dir := ${top_dist_dir}/${platform}${variant}
$(info dist_dir = ${dist_dir})
MY_MAKE_FLAGS ?=
MY_CMAKE_FLAGS ?=
ifneq (${VERBOSE},)
MY_MAKE_FLAGS += VERBOSE=${VERBOSE}
endif
ifdef DEBUG
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug
endif
ifneq (${MYCC},)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER:STRING=${MYCC}
endif
ifneq (${MYCXX},)
MY_CMAKE_FLAGS += -DCMAKE_CXX_COMPILER:STRING=${MYCXX}
endif
#$(info MY_CMAKE_FLAGS = ${MY_CMAKE_FLAGS})
#$(info MY_MAKE_FLAGS = ${MY_MAKE_FLAGS})
#########################################################################
#########################################################################
# Top-level documented targets
all: dist
# 'make debug' is implemented via recursive make setting DEBUG
debug:
${MAKE} DEBUG=1 --no-print-directory
# 'make profile' is implemented via recursive make setting PROFILE
profile:
${MAKE} PROFILE=1 --no-print-directory
# 'make cmakesetup' constructs the build directory and runs 'cmake'
# there, generating makefiles to build the project.
cmakesetup:
cmake -E make_directory ${build_dir}
( cd ${build_dir} ; \
cmake -DCMAKE_INSTALL_PREFIX=${working_dir}/${dist_dir} \
${MY_CMAKE_FLAGS} \
-DBOOST_ROOT=${BOOST_HOME} \
../../src )
# 'make cmake' does a basic build (after first setting it up)
cmake: cmakesetup
( cd ${build_dir} ; make ${MY_MAKE_FLAGS} )
# 'make cmakeinstall' builds everthing and installs it in 'dist'
cmakeinstall: cmake
( cd ${build_dir} ; make ${MY_MAKE_FLAGS} install )
# 'make dist' is just a synonym for 'make cmakeinstall'
dist : cmakeinstall
# 'make fast' builds assuming cmake has already run. Use with caution!
fast:
( cd ${build_dir} ; make ${MY_MAKE_FLAGS} install )
# 'make test' does a full build and then runs all tests
test: cmake
( cd ${build_dir} ; make ${MY_MAKE_FLAGS} test )
# 'make package' builds everything and then makes an installable package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package: cmakeinstall
( cd ${build_dir} ; make ${MY_MAKE_FLAGS} package )
# 'make package_source' makes an installable source package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package_source: cmakeinstall
( cd ${build_dir} ; make ${MY_MAKE_FLAGS} package_source )
#clean: testclean
# 'make clean' clears out the build directory for this platform
clean:
cmake -E remove_directory ${build_dir}
# 'make realclean' clears out both build and dist directories for this platform
realclean: clean
cmake -E remove_directory ${dist_dir}
# 'make nuke' blows away the build and dist areas for all platforms
nuke:
cmake -E remove_directory ${top_build_dir}
cmake -E remove_directory ${top_dist_dir}
doxygen:
doxygen src/doc/Doxyfile
#testclean : ${all_tests}
# @ for f in ${all_tests} ; do \
# ( cd $$f ; \
# echo "Cleaning test $$f " ; \
# ./run.py -c ; \
# ) \
# done
#########################################################################
# 'make help' prints important make targets
help:
@echo "Targets:"
@echo " make Build optimized binaries and libraries in ${dist_dir},"
@echo " temporary build files in ${build_dir}"
@echo " make debug Build unoptimized with symbols in ${dist_dir}.debug,"
@echo " temporary build files in ${build_dir}.debug"
@echo " make profile Build for profiling in ${dist_dir}.profile,"
@echo " temporary build files in ${build_dir}.profile"
@echo " make clean Remove the temporary files in ${build_dir}"
@echo " make realclean Remove both ${build_dir} AND ${dist_dir}"
@echo " make nuke Remove ALL of build and dist (not just ${platform})"
@echo " make test Run all tests"
@echo " make doxygen Build the Doxygen docs in ${top_build_dir}/doxygen"
@echo ""
@echo "Helpful modifiers:"
@echo " make VERBOSE=1 ... Show all compilation commands"
@echo " make MYCC=xx MYCXX=yy ... Use custom compilers"
@echo ""
endif