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

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

Comments

Loading...