Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Makefile 15 KB

You have to be logged in to leave a comment. Sign In
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
  1. PROJECT := openpose
  2. CONFIG_FILE := Makefile.config
  3. # Explicitly check for the config file, otherwise make -k will proceed anyway.
  4. ifeq ($(wildcard $(CONFIG_FILE)),)
  5. $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
  6. endif
  7. include $(CONFIG_FILE)
  8. BUILD_DIR_LINK := $(BUILD_DIR)
  9. ifeq ($(RELEASE_BUILD_DIR),)
  10. RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
  11. endif
  12. ifeq ($(DEBUG_BUILD_DIR),)
  13. DEBUG_BUILD_DIR := .$(BUILD_DIR)_debug
  14. endif
  15. DEBUG ?= 0
  16. ifeq ($(DEBUG), 1)
  17. BUILD_DIR := $(DEBUG_BUILD_DIR)
  18. OTHER_BUILD_DIR := $(RELEASE_BUILD_DIR)
  19. else
  20. BUILD_DIR := $(RELEASE_BUILD_DIR)
  21. OTHER_BUILD_DIR := $(DEBUG_BUILD_DIR)
  22. endif
  23. # All of the directories containing code.
  24. SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
  25. -name '*.cpp' | grep -q ." \; -print)
  26. # The target shared library name
  27. LIBRARY_NAME := $(PROJECT)
  28. LIB_BUILD_DIR := $(BUILD_DIR)/lib
  29. STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
  30. DYNAMIC_VERSION_MAJOR := 1
  31. DYNAMIC_VERSION_MINOR := 0
  32. DYNAMIC_VERSION_REVISION := 0-rc2
  33. DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
  34. #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
  35. DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
  36. DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
  37. COMMON_FLAGS += -DOPEN_POSE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
  38. ##############################
  39. # Enable profiler
  40. ##############################
  41. PROFILER_ENABLED ?= 0
  42. ifeq ($(PROFILER_ENABLED), 1)
  43. COMMON_FLAGS += -DPROFILER_ENABLED
  44. endif
  45. ##############################
  46. # Deep net selection
  47. ##############################
  48. DEEP_NET ?= caffe
  49. # TensorFlow
  50. ifeq ($(DEEP_NET), tensorflow)
  51. # COMMON_FLAGS += -DUSE_TENSOR_FLOW
  52. # Torch
  53. else ifeq ($(DEEP_NET), torch)
  54. # COMMON_FLAGS += -DUSE_TORCH
  55. # Caffe
  56. else
  57. COMMON_FLAGS += -DUSE_CAFFE
  58. endif
  59. ##############################
  60. # Get all source files
  61. ##############################
  62. # CXX_SRCS are the source files excluding the test ones.
  63. # CXX_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cpp" -name "*.cpp")
  64. CXX_SRCS := $(shell find src ! -name "test_*.cpp" -name "*.cpp")
  65. # CU_SRCS are the cuda source files
  66. # CU_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cu" -name "*.cu")
  67. CU_SRCS := $(shell find src ! -name "test_*.cu" -name "*.cu")
  68. # EXAMPLE_SRCS are the source files for the example binaries
  69. EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
  70. # BUILD_INCLUDE_DIR contains any generated header files we want to include.
  71. BUILD_INCLUDE_DIR := $(BUILD_DIR)/src
  72. # NONGEN_CXX_SRCS includes all source/header files except those generated
  73. # automatically (e.g., by proto).
  74. NONGEN_CXX_SRCS := $(shell find \
  75. src/$(PROJECT) \
  76. include/$(PROJECT) \
  77. examples \
  78. -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh")
  79. LINT_SCRIPT := scripts/cpp_lint.py
  80. LINT_OUTPUT_DIR := $(BUILD_DIR)/.lint
  81. LINT_EXT := lint.txt
  82. LINT_OUTPUTS := $(addsuffix .$(LINT_EXT), $(addprefix $(LINT_OUTPUT_DIR)/, $(NONGEN_CXX_SRCS)))
  83. EMPTY_LINT_REPORT := $(BUILD_DIR)/.$(LINT_EXT)
  84. NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT)
  85. ##############################
  86. # Derive generated files
  87. ##############################
  88. # The objects corresponding to the source files
  89. # These objects will be linked into the final shared library, so we
  90. # exclude the example objects.
  91. CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o})
  92. CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o})
  93. OBJS := $(CXX_OBJS) $(CU_OBJS)
  94. # example objects
  95. EXAMPLE_OBJS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o})
  96. # Output files for automatic dependency generation
  97. DEPS := ${EXAMPLE_OBJS:.o=.d} ${CXX_OBJS:.o=.d} ${CU_OBJS:.o=.d}
  98. EXAMPLE_BINS := ${EXAMPLE_OBJS:.o=.bin}
  99. ##############################
  100. # Derive compiler warning dump locations
  101. ##############################
  102. WARNS_EXT := warnings.txt
  103. CXX_WARNS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o.$(WARNS_EXT)})
  104. CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o.$(WARNS_EXT)})
  105. EXAMPLE_WARNS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o.$(WARNS_EXT)})
  106. ALL_CXX_WARNS := $(CXX_WARNS) $(EXAMPLE_WARNS)
  107. ALL_CU_WARNS := $(CU_WARNS)
  108. ALL_WARNS := $(ALL_CXX_WARNS) $(ALL_CU_WARNS)
  109. EMPTY_WARN_REPORT := $(BUILD_DIR)/.$(WARNS_EXT)
  110. NONEMPTY_WARN_REPORT := $(BUILD_DIR)/$(WARNS_EXT)
  111. ##############################
  112. # Derive include and lib directories
  113. ##############################
  114. CUDA_INCLUDE_DIR := $(CUDA_DIR)/include
  115. CUDA_LIB_DIR :=
  116. # add <cuda>/lib64 only if it exists
  117. ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")
  118. CUDA_LIB_DIR += $(CUDA_DIR)/lib64
  119. endif
  120. CUDA_LIB_DIR += $(CUDA_DIR)/lib
  121. INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
  122. ifneq ($(CPU_ONLY), 1)
  123. INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
  124. LIBRARY_DIRS += $(CUDA_LIB_DIR)
  125. LIBRARIES := cudart cublas curand
  126. endif
  127. LIBRARIES += glog gflags boost_system boost_filesystem m hdf5_hl hdf5 caffe
  128. # handle IO dependencies
  129. USE_LEVELDB ?= 1
  130. USE_LMDB ?= 1
  131. USE_OPENCV ?= 1
  132. ifeq ($(USE_LEVELDB), 1)
  133. LIBRARIES += leveldb snappy
  134. endif
  135. ifeq ($(USE_LMDB), 1)
  136. LIBRARIES += lmdb
  137. endif
  138. ifeq ($(USE_OPENCV), 1)
  139. LIBRARIES += opencv_core opencv_highgui opencv_imgproc
  140. ifeq ($(OPENCV_VERSION), 3)
  141. LIBRARIES += opencv_imgcodecs opencv_videoio
  142. else
  143. LIBRARIES += opencv_contrib
  144. endif
  145. endif
  146. WARNINGS := -Wall -Wno-sign-compare
  147. ##############################
  148. # Set build directories
  149. ##############################
  150. DISTRIBUTE_DIR ?= distribute
  151. DISTRIBUTE_SUBDIRS := $(DISTRIBUTE_DIR)/bin $(DISTRIBUTE_DIR)/lib
  152. DIST_ALIASES := dist
  153. ifneq ($(strip $(DISTRIBUTE_DIR)),distribute)
  154. DIST_ALIASES += distribute
  155. endif
  156. ALL_BUILD_DIRS := $(sort $(BUILD_DIR) $(addprefix $(BUILD_DIR)/, $(SRC_DIRS)) \
  157. $(addprefix $(BUILD_DIR)/cuda/, $(SRC_DIRS)) \
  158. $(LIB_BUILD_DIR) $(LINT_OUTPUT_DIR))
  159. ##############################
  160. # Set directory for Doxygen-generated documentation
  161. ##############################
  162. DOXYGEN_CONFIG_FILE ?= ./.Doxyfile
  163. # should be the same as OUTPUT_DIRECTORY in the .Doxyfile
  164. DOXYGEN_OUTPUT_DIR ?= ./doxygen
  165. DOXYGEN_COMMAND ?= doxygen
  166. # All the files that might have Doxygen documentation.
  167. DOXYGEN_SOURCES := $(shell find \
  168. src/$(PROJECT) \
  169. include/$(PROJECT) \
  170. examples \
  171. -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh")
  172. DOXYGEN_SOURCES += $(DOXYGEN_CONFIG_FILE)
  173. ##############################
  174. # OpenPose extra code: added flags
  175. ##############################
  176. # Automatic dependency generation (nvcc is handled separately)
  177. CXXFLAGS += -march=native
  178. # Complete build flags.
  179. CXXFLAGS += -fopenmp -Wpedantic -Wall -Wextra
  180. CXXFLAGS += -Wfatal-errors
  181. COMMON_FLAGS += -std=c++11
  182. LINKFLAGS += -fopenmp
  183. ##############################
  184. # Configure build
  185. ##############################
  186. # Determine platform
  187. UNAME := $(shell uname -s)
  188. ifeq ($(UNAME), Linux)
  189. LINUX := 1
  190. else ifeq ($(UNAME), Darwin)
  191. OSX := 1
  192. OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .)
  193. OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .)
  194. endif
  195. # Linux
  196. ifeq ($(LINUX), 1)
  197. CXX ?= /usr/bin/g++
  198. GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.)
  199. # older versions of gcc are too dumb to build boost with -Wuninitalized
  200. ifeq ($(shell echo | awk '{exit $(GCCVERSION) < 4.6;}'), 1)
  201. WARNINGS += -Wno-uninitialized
  202. endif
  203. # boost::thread is reasonably called boost_thread (compare OS X)
  204. # We will also explicitly add stdc++ to the link target.
  205. LIBRARIES += boost_thread stdc++
  206. VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
  207. endif
  208. # OS X:
  209. # clang++ instead of g++
  210. # libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
  211. ifeq ($(OSX), 1)
  212. CXX := /usr/bin/clang++
  213. ifneq ($(CPU_ONLY), 1)
  214. CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]')
  215. ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
  216. CXXFLAGS += -stdlib=libstdc++
  217. LINKFLAGS += -stdlib=libstdc++
  218. endif
  219. # clang throws this warning for cuda headers
  220. WARNINGS += -Wno-unneeded-internal-declaration
  221. # 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)
  222. OSX_10_OR_LATER := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)
  223. OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)
  224. ifeq ($(OSX_10_OR_LATER),true)
  225. ifeq ($(OSX_10_5_OR_LATER),true)
  226. LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)
  227. endif
  228. endif
  229. endif
  230. # boost::thread is called boost_thread-mt to mark multithreading on OS X
  231. LIBRARIES += boost_thread-mt
  232. # we need to explicitly ask for the rpath to be obeyed
  233. ORIGIN := @loader_path
  234. VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
  235. else
  236. ORIGIN := \$$ORIGIN
  237. endif
  238. # Custom compiler
  239. ifdef CUSTOM_CXX
  240. CXX := $(CUSTOM_CXX)
  241. endif
  242. # Static linking
  243. ifneq (,$(findstring clang++,$(CXX)))
  244. STATIC_LINK_COMMAND := -Wl,-force_load $(STATIC_NAME)
  245. else ifneq (,$(findstring g++,$(CXX)))
  246. STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive
  247. else
  248. # The following line must not be indented with a tab, since we are not inside a target
  249. $(error Cannot static link with the $(CXX) compiler)
  250. endif
  251. # Debugging
  252. ifeq ($(DEBUG), 1)
  253. COMMON_FLAGS += -DDEBUG -g -O0
  254. NVCCFLAGS += -G
  255. else
  256. COMMON_FLAGS += -DNDEBUG -O3
  257. endif
  258. # cuDNN acceleration configuration.
  259. ifeq ($(USE_CUDNN), 1)
  260. LIBRARIES += cudnn
  261. COMMON_FLAGS += -DUSE_CUDNN
  262. endif
  263. # configure IO libraries
  264. ifeq ($(USE_OPENCV), 1)
  265. COMMON_FLAGS += -DUSE_OPENCV
  266. endif
  267. ifeq ($(USE_LEVELDB), 1)
  268. COMMON_FLAGS += -DUSE_LEVELDB
  269. endif
  270. ifeq ($(USE_LMDB), 1)
  271. COMMON_FLAGS += -DUSE_LMDB
  272. ifeq ($(ALLOW_LMDB_NOLOCK), 1)
  273. COMMON_FLAGS += -DALLOW_LMDB_NOLOCK
  274. endif
  275. endif
  276. # CPU-only configuration
  277. ifeq ($(CPU_ONLY), 1)
  278. OBJS := $(CXX_OBJS)
  279. ALL_WARNS := $(ALL_CXX_WARNS)
  280. COMMON_FLAGS += -DCPU_ONLY
  281. endif
  282. # BLAS configuration (default = ATLAS)
  283. BLAS ?= atlas
  284. ifeq ($(BLAS), mkl)
  285. # MKL
  286. LIBRARIES += mkl_rt
  287. COMMON_FLAGS += -DUSE_MKL
  288. MKLROOT ?= /opt/intel/mkl
  289. BLAS_INCLUDE ?= $(MKLROOT)/include
  290. BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64
  291. else ifeq ($(BLAS), open)
  292. # OpenBLAS
  293. LIBRARIES += openblas
  294. else
  295. # ATLAS
  296. ifeq ($(LINUX), 1)
  297. ifeq ($(BLAS), atlas)
  298. # Linux simply has cblas and atlas
  299. LIBRARIES += cblas atlas
  300. endif
  301. else ifeq ($(OSX), 1)
  302. # OS X packages atlas as the vecLib framework
  303. LIBRARIES += cblas
  304. # 10.10 has accelerate while 10.9 has veclib
  305. XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/')
  306. XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1)
  307. XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1)
  308. ifeq ($(XCODE_CLT_GEQ_7), 1)
  309. BLAS_INCLUDE ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$(shell ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ | sort | tail -1)/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers
  310. else ifeq ($(XCODE_CLT_GEQ_6), 1)
  311. BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
  312. LDFLAGS += -framework Accelerate
  313. else
  314. BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/
  315. LDFLAGS += -framework vecLib
  316. endif
  317. endif
  318. endif
  319. #'
  320. INCLUDE_DIRS += $(BLAS_INCLUDE)
  321. LIBRARY_DIRS += $(BLAS_LIB)
  322. LIBRARY_DIRS += $(LIB_BUILD_DIR)
  323. # Automatic dependency generation (nvcc is handled separately)
  324. CXXFLAGS += -MMD -MP
  325. # Complete build flags.
  326. COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
  327. CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
  328. NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
  329. LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
  330. USE_PKG_CONFIG ?= 0
  331. ifeq ($(USE_PKG_CONFIG), 1)
  332. PKG_CONFIG := $(shell pkg-config opencv --libs)
  333. else
  334. PKG_CONFIG :=
  335. endif
  336. LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \
  337. $(foreach library,$(LIBRARIES),-l$(library)) -Wl,-rpath=$(CAFFE_DIR)/lib
  338. ##############################
  339. # Define build targets
  340. ##############################
  341. .PHONY: all lib clean docs linecount lint lintclean examples $(DIST_ALIASES) \
  342. warn everything
  343. all: lib examples
  344. lib: $(STATIC_NAME) $(DYNAMIC_NAME)
  345. everything: $(EVERYTHING_TARGETS)
  346. linecount:
  347. cloc --read-lang-def=$(PROJECT).cloc \
  348. src/$(PROJECT) include/$(PROJECT) examples
  349. lint: $(EMPTY_LINT_REPORT)
  350. lintclean:
  351. @ $(RM) -r $(LINT_OUTPUT_DIR) $(EMPTY_LINT_REPORT) $(NONEMPTY_LINT_REPORT)
  352. docs: $(DOXYGEN_OUTPUT_DIR)
  353. @ cd ./docs ; ln -sfn ../$(DOXYGEN_OUTPUT_DIR)/html doxygen
  354. $(DOXYGEN_OUTPUT_DIR): $(DOXYGEN_CONFIG_FILE) $(DOXYGEN_SOURCES)
  355. $(DOXYGEN_COMMAND) $(DOXYGEN_CONFIG_FILE)
  356. $(EMPTY_LINT_REPORT): $(LINT_OUTPUTS) | $(BUILD_DIR)
  357. @ cat $(LINT_OUTPUTS) > $@
  358. @ if [ -s "$@" ]; then \
  359. cat $@; \
  360. mv $@ $(NONEMPTY_LINT_REPORT); \
  361. echo "Found one or more lint errors."; \
  362. exit 1; \
  363. fi; \
  364. $(RM) $(NONEMPTY_LINT_REPORT); \
  365. echo "No lint errors!";
  366. $(LINT_OUTPUTS): $(LINT_OUTPUT_DIR)/%.lint.txt : % $(LINT_SCRIPT) | $(LINT_OUTPUT_DIR)
  367. @ mkdir -p $(dir $@)
  368. @ python $(LINT_SCRIPT) $< 2>&1 \
  369. | grep -v "^Done processing " \
  370. | grep -v "^Total errors found: 0" \
  371. > $@ \
  372. || true
  373. examples: $(EXAMPLE_BINS)
  374. warn: $(EMPTY_WARN_REPORT)
  375. $(EMPTY_WARN_REPORT): $(ALL_WARNS) | $(BUILD_DIR)
  376. @ cat $(ALL_WARNS) > $@
  377. @ if [ -s "$@" ]; then \
  378. cat $@; \
  379. mv $@ $(NONEMPTY_WARN_REPORT); \
  380. echo "Compiler produced one or more warnings."; \
  381. exit 1; \
  382. fi; \
  383. $(RM) $(NONEMPTY_WARN_REPORT); \
  384. echo "No compiler warnings!";
  385. $(ALL_WARNS): %.o.$(WARNS_EXT) : %.o
  386. $(BUILD_DIR_LINK): $(BUILD_DIR)/.linked
  387. # Create a target ".linked" in this BUILD_DIR to tell Make that the "build" link
  388. # is currently correct, then delete the one in the OTHER_BUILD_DIR in case it
  389. # exists and $(DEBUG) is toggled later.
  390. $(BUILD_DIR)/.linked:
  391. @ mkdir -p $(BUILD_DIR)
  392. @ $(RM) $(OTHER_BUILD_DIR)/.linked
  393. @ $(RM) -r $(BUILD_DIR_LINK)
  394. @ ln -s $(BUILD_DIR) $(BUILD_DIR_LINK)
  395. @ touch $@
  396. $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK)
  397. @ mkdir -p $@
  398. $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
  399. @ echo LD -o $@
  400. $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS)
  401. @ cd $(LIB_BUILD_DIR); rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
  402. $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
  403. @ echo AR -o $@
  404. $(Q)ar rcs $@ $(OBJS)
  405. $(BUILD_DIR)/%.o: %.cpp | $(ALL_BUILD_DIRS)
  406. @ echo CXX $<
  407. $(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \
  408. || (cat $@.$(WARNS_EXT); exit 1)
  409. @ cat $@.$(WARNS_EXT)
  410. $(BUILD_DIR)/cuda/%.o: %.cu | $(ALL_BUILD_DIRS)
  411. @ echo NVCC $<
  412. $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -M $< -o ${@:.o=.d} \
  413. -odir $(@D)
  414. $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c $< -o $@ 2> $@.$(WARNS_EXT) \
  415. || (cat $@.$(WARNS_EXT); exit 1)
  416. @ cat $@.$(WARNS_EXT)
  417. $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)
  418. @ echo CXX/LD -o $@
  419. $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
  420. -Wl,-rpath,$(ORIGIN)/../../lib
  421. clean:
  422. @- $(RM) -rf $(ALL_BUILD_DIRS)
  423. @- $(RM) -rf $(OTHER_BUILD_DIR)
  424. @- $(RM) -rf $(BUILD_DIR_LINK)
  425. @- $(RM) -rf $(DISTRIBUTE_DIR)
  426. $(DIST_ALIASES): $(DISTRIBUTE_DIR)
  427. $(DISTRIBUTE_DIR): all
  428. @ mkdir -p $(DISTRIBUTE_SUBDIRS)
  429. # add include
  430. cp -r include $(DISTRIBUTE_DIR)/
  431. # add example binaries
  432. cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin
  433. # add libraries
  434. cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib
  435. install -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib
  436. cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
  437. -include $(DEPS)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...