-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmakefile
250 lines (193 loc) · 6.58 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
LUAVER = 5.2
export PREFIX = /usr
UNAME := $(shell uname)
LINUX_SUFIX := $(shell ( ldconfig -p 2>/dev/null | grep libmkl_core > /dev/null && echo "mkl" ) || ( ls /opt/MKL/lib/libmkl_core.so 2> /dev/null > /dev/null && echo "mkl" ) || ( ldconfig -p 2>/dev/null | grep libatlas > /dev/null && echo "atlas" ) || echo "")
ifeq ("$(UNAME)","Darwin")
# homebrew
ifneq ("$(wildcard /usr/local/include/lua.h)","")
DARWIN_SUFIX = homebrew
PREFIX = /usr/local
endif
# macports
ifneq ("$(wildcard /opt/local/include/lua.h)","")
DARWIN_SUFIX = macports
PREFIX = /opt/local
endif
endif
INCLUDE := $(PREFIX)/include
LIB := $(PREFIX)/lib
LUALIB := $(PREFIX)/lib/lua/$(LUAVER)
LUAMOD := $(PREFIX)/share/lua/$(LUAVER)
BIN := $(PREFIX)/bin
ALL: auto-release
########################## AUTOMACTIC SECTION ############################
auto-release:
@echo "System $(UNAME)"
@make system-release-$(UNAME)
auto-debug:
@echo "System $(UNAME)"
@make system-debug-$(UNAME)
auto-test-debug:
@echo "System $(UNAME)"
@make system-test-debug-$(UNAME)
# RELEASE
system-release-Linux: check_linux_release
@echo "Sufix $(LINUX_SUFIX)"
@make release-$(LINUX_SUFIX)
system-release-Darwin: check_darwin_release
@echo "Sufix $(DARWIN_SUFIX)"
@make release-$(DARWIN_SUFIX)
# DEBUG
system-debug-Linux: check_linux_release
@echo "Sufix $(LINUX_SUFIX)"
@make debug-$(LINUX_SUFIX)
system-debug-Darwin: check_darwin_release
@echo "Sufix $(DARWIN_SUFIX)"
@make debug-$(DARWIN_SUFIX)
# TEST-DEBUG
system-test-debug-Linux: check_linux_release
@echo "Sufix $(LINUX_SUFIX)"
@make test-debug-$(LINUX_SUFIX)
system-test-debug-Darwin: check_darwin_release
@echo "Sufix $(DARWIN_SUFIX)"
@make test-debug-$(DARWIN_SUFIX)
# CHECK
check_linux_release:
ifeq ("$(LINUX_SUFIX)", "")
@echo "Impossible to detect the proper release!"
@exit 1
endif
check_darwin_release:
ifeq ("$(DARWIN_SUFIX)", "")
@echo "Impossible to detect macports or homebrew!"
@exit 2
endif
#############################################################################
release: auto-release
debug: auto-debug
test: auto-test-debug
document:
rm -Rf doxygen_doc build_doc
lua profile_build_scripts/build_release_atlas.lua document
performance:
april-ann TEST/PERFORMANCE/register_performance.lua TEST/PERFORMANCE/matrix/test.lua
#############################################################################
# TEST with OMP and ATLAS
test-debug-atlas: debug-atlas
lua profile_build_scripts/build_debug_atlas.lua test
# TEST without OMP and ATLAS
test-debug-no-omp: debug-no-omp
lua profile_build_scripts/build_debug_no_omp.lua test
# TEST for DARWIN MACPORTS
test-debug-macports: debug-macports
lua profile_build_scripts/build_debug_macports.lua test
# TEST for DARWIN HOMEBREW
test-debug-homebrew: debug-homebrew
lua profile_build_scripts/build_debug_homebrew.lua test
# TEST with OMP and MKL
test-debug-mkl: debug-mkl
lua profile_build_scripts/build_debug_mkl.lua test
# TEST with CUDA and MKL
test-debug-cuda-mkl: debug-cuda-mkl
lua profile_build_scripts/build_debug_cuda_and_mkl.lua test
# TEST for raspberry-pi (subset of packages)
test-debug-pi: debug-pi
lua profile_build_scripts/build_debug_pi.lua test
#############################################################################
# RELEASE for DARWIN MACPORTS
release-macports:
lua profile_build_scripts/build_release_macports.lua
# RELEASE for DARWIN HOMEBREW
release-homebrew:
lua profile_build_scripts/build_release_homebrew.lua
# RELEASE with OMP and MKL
release-mkl:
lua profile_build_scripts/build_release_mkl.lua
# RELEASE with OMP and ATLAS
release-atlas:
lua profile_build_scripts/build_release_atlas.lua
# RELEASE with CUDA and MKL
release-cuda-mkl:
lua profile_build_scripts/build_release_cuda_and_mkl.lua
# RELEASE for raspberry-pi (subset of pacakges)
release-pi:
lua profile_build_scripts/build_release_pi.lua
# RELEASE without OMP and ATLAS
release-no-omp:
lua profile_build_scripts/build_release_no_omp.lua
#############################################################################
# DEBUG for DARWIN MACPORTS
debug-macports:
lua profile_build_scripts/build_debug_macports.lua
# DEBUG for DARWIN HOMEBREW
debug-homebrew:
lua profile_build_scripts/build_debug_homebrew.lua
# DEBUG with OMP and MKL
debug-mkl:
lua profile_build_scripts/build_debug_mkl.lua
# DEBUG with OMP and ATLAS
debug-atlas:
lua profile_build_scripts/build_debug_atlas.lua
# DEBUG without OMP and ATLAS
debug-no-omp:
lua profile_build_scripts/build_debug_no_omp.lua
# DEBUG with CUDA and MKL
debug-cuda-mkl:
lua profile_build_scripts/build_debug_cuda_and_mkl.lua
# DEBUG for raspberry-pi (subset of packages)
debug-pi:
lua profile_build_scripts/build_debug_pi.lua
#############################################################################
INCLUDE_NO_WS := $(shell echo "$(INCLUDE)" | sed 's/ //g')
LIB_NO_WS := $(shell echo "$(LIB)" | sed 's/ //g')
LUALIB_NO_WS := $(shell echo "$(LUALIB)" | sed 's/ //g')
LUAMOD_NO_WS := $(shell echo "$(LUAMOD)" | sed 's/ //g')
BIN_NO_WS := $(shell echo "$(BIN)" | sed 's/ //g')
check-env-vars:
ifneq ("$(INCLUDE_NO_WS)","$(INCLUDE)")
@echo "Unable to work with whitespaces in PREFIX, INCLUDE, LIB, LUALIB, LUAMOD, BIN env vars"
@exit 3
endif
ifneq ("$(LIB_NO_WS)","$(LIB)")
@echo "Unable to work with whitespaces in PREFIX, INCLUDE, LIB, LUALIB, LUAMOD, BIN env vars"
@exit 4
endif
ifneq ("$(LUALIB_NO_WS)","$(LUALIB)")
@echo "Unable to work with whitespaces in PREFIX, INCLUDE, LIB, LUALIB, LUAMOD, BIN env vars"
@exit 5
endif
ifneq ("$(LUAMOD_NO_WS)","$(LUAMOD)")
@echo "Unable to work with whitespaces in PREFIX, INCLUDE, LIB, LUALIB, LUAMOD, BIN env vars"
@exit 6
endif
ifneq ("$(BIN_NO_WS)","$(BIN)")
@echo "Unable to work with whitespaces in PREFIX, INCLUDE, LIB, LUALIB, LUAMOD, BIN env vars"
@exit 7
endif
clean:
./clean.sh
install: check-env-vars uninstall
@mkdir -p $(LUAMOD)
@mkdir -p $(LUALIB)
rsync -r tools/ $(LUAMOD)/april_tools
@mkdir -p $(INCLUDE)/april-ann
install -m 444 include/april-ann/* $(INCLUDE)/april-ann
install -m 444 include/april-ann.h $(INCLUDE)/april-ann.h
install .april-ann.pc $(LIB)/pkgconfig/april-ann.pc
install lib/libapril-ann.a $(LIB)
install lib/libapril-ann.so $(LIB)
install lib/aprilann.so $(LUALIB)
install bin/april-ann $(BIN)
install lua/bin/lua $(BIN)/lua$(LUAVER)-april
uninstall: check-env-vars
@rm -Rf $(INCLUDE)/april-ann
@rm -Rf $(LUAMOD)/april_tools
@rm -f $(INCLUDE)/april-ann.h
@rm -f $(LUALIB)/aprilann.so
@rm -f $(LIB)/libapril-ann.a
@rm -f $(LIB)/libapril-ann.so
@rm -f $(LIB)/pkgconfig/april-ann.pc
@rm -f $(BIN)/april-ann
@rm -f $(BIN)/lua-$(LUAVER)-april
##############################################################################
.PHONY: all