GNUmakefile 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. # -*- mode: gnumakefile; tab-width: 4; indent-tabs-mode: t; -*-
  2. # vim: tabstop=4
  3. #
  4. # ##### BEGIN GPL LICENSE BLOCK #####
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software Foundation,
  18. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. #
  20. # ##### END GPL LICENSE BLOCK #####
  21. # This Makefile does an out-of-source CMake build in ../build_`OS`_`CPU`
  22. # eg:
  23. # ../build_linux_i386
  24. # This is for users who like to configure & build blender with a single command.
  25. define HELP_TEXT
  26. Convenience Targets
  27. Provided for building Blender, (multiple at once can be used).
  28. * debug: Build a debug binary.
  29. * full: Enable all supported dependencies & options.
  30. * lite: Disable non essential features for a smaller binary and faster build.
  31. * headless: Build without an interface (renderfarm or server automation).
  32. * cycles: Build Cycles standalone only, without Blender.
  33. * bpy: Build as a python module which can be loaded from python directly.
  34. * deps: Build library dependencies (intended only for platform maintainers).
  35. * config: Run cmake configuration tool to set build options.
  36. Note: passing the argument 'BUILD_DIR=path' when calling make will override the default build dir.
  37. Note: passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.
  38. Project Files
  39. Generate poject files for development environments.
  40. * project_qtcreator: QtCreator Project Files.
  41. * project_netbeans: NetBeans Project Files.
  42. * project_eclipse: Eclipse CDT4 Project Files.
  43. Package Targets
  44. * package_debian: Build a debian package.
  45. * package_pacman: Build an arch linux pacman package.
  46. * package_archive: Build an archive package.
  47. Testing Targets
  48. Not associated with building Blender.
  49. * test:
  50. Run ctest, currently tests import/export,
  51. operator execution and that python modules load
  52. * test_cmake:
  53. Runs our own cmake file checker
  54. which detects errors in the cmake file list definitions
  55. * test_pep8:
  56. Checks all python script are pep8
  57. which are tagged to use the stricter formatting
  58. * test_deprecated:
  59. Checks for deprecation tags in our code which may need to be removed
  60. * test_style_c:
  61. Checks C/C++ conforms with blenders style guide:
  62. https://wiki.blender.org/wiki/Source/Code_Style
  63. * test_style_c_qtc:
  64. Same as test_style but outputs QtCreator tasks format
  65. * test_style_osl:
  66. Checks OpenShadingLanguage conforms with blenders style guide:
  67. https://wiki.blender.org/wiki/Source/Code_Style
  68. * test_style_osl_qtc:
  69. Checks OpenShadingLanguage conforms with blenders style guide:
  70. https://wiki.blender.org/wiki/Source/Code_Style
  71. Static Source Code Checking
  72. Not associated with building Blender.
  73. * check_cppcheck: Run blender source through cppcheck (C & C++).
  74. * check_clang_array: Run blender source through clang array checking script (C & C++).
  75. * check_splint: Run blenders source through splint (C only).
  76. * check_sparse: Run blenders source through sparse (C only).
  77. * check_smatch: Run blenders source through smatch (C only).
  78. * check_spelling_c: Check for spelling errors (C/C++ only).
  79. * check_spelling_c_qtc: Same as check_spelling_c but outputs QtCreator tasks format.
  80. * check_spelling_osl: Check for spelling errors (OSL only).
  81. * check_spelling_py: Check for spelling errors (Python only).
  82. * check_descriptions: Check for duplicate/invalid descriptions.
  83. Utilities
  84. Not associated with building Blender.
  85. * icons:
  86. Updates PNG icons from SVG files.
  87. Optionally pass in variables: 'BLENDER_BIN', 'INKSCAPE_BIN'
  88. otherwise default paths are used.
  89. Example
  90. make icons INKSCAPE_BIN=/path/to/inkscape
  91. * icons_geom:
  92. Updates Geometry icons from BLEND file.
  93. Optionally pass in variable: 'BLENDER_BIN'
  94. otherwise default paths are used.
  95. Example
  96. make icons_geom BLENDER_BIN=/path/to/blender
  97. * tgz:
  98. Create a compressed archive of the source code.
  99. * update:
  100. updates git and all submodules
  101. * format
  102. Format source code using clang (uses PATHS if passed in). For example::
  103. make format PATHS="source/blender/blenlib source/blender/blenkernel"
  104. Environment Variables
  105. * BUILD_CMAKE_ARGS: Arguments passed to CMake.
  106. * BUILD_DIR: Override default build path.
  107. * PYTHON: Use this for the Python command (used for checking tools).
  108. * NPROCS: Number of processes to use building (auto-detect when omitted).
  109. Documentation Targets
  110. Not associated with building Blender.
  111. * doc_py: Generate sphinx python api docs.
  112. * doc_doxy: Generate doxygen C/C++ docs.
  113. * doc_dna: Generate blender file format reference.
  114. * doc_man: Generate manpage.
  115. Information
  116. * help: This help message.
  117. * help_features: Show a list of optional features when building.
  118. endef
  119. # HELP_TEXT (end)
  120. # System Vars
  121. OS:=$(shell uname -s)
  122. OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
  123. CPU:=$(shell uname -m)
  124. # Source and Build DIR's
  125. BLENDER_DIR:=$(shell pwd -P)
  126. BUILD_TYPE:=Release
  127. ifndef BUILD_CMAKE_ARGS
  128. BUILD_CMAKE_ARGS:=
  129. endif
  130. ifndef BUILD_DIR
  131. BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
  132. endif
  133. # Dependencies DIR's
  134. DEPS_SOURCE_DIR:=$(BLENDER_DIR)/build_files/build_environment
  135. ifndef DEPS_BUILD_DIR
  136. DEPS_BUILD_DIR:=$(BUILD_DIR)/deps
  137. endif
  138. ifndef DEPS_INSTALL_DIR
  139. DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
  140. ifneq ($(OS_NCASE),darwin)
  141. # Add processor type to directory name
  142. DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(CPU)
  143. endif
  144. endif
  145. # Allow to use alternative binary (pypy3, etc)
  146. ifndef PYTHON
  147. PYTHON:=python3
  148. endif
  149. # -----------------------------------------------------------------------------
  150. # additional targets for the build configuration
  151. # support 'make debug'
  152. ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
  153. BUILD_DIR:=$(BUILD_DIR)_debug
  154. BUILD_TYPE:=Debug
  155. endif
  156. ifneq "$(findstring full, $(MAKECMDGOALS))" ""
  157. BUILD_DIR:=$(BUILD_DIR)_full
  158. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
  159. endif
  160. ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
  161. BUILD_DIR:=$(BUILD_DIR)_lite
  162. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
  163. endif
  164. ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
  165. BUILD_DIR:=$(BUILD_DIR)_cycles
  166. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
  167. endif
  168. ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
  169. BUILD_DIR:=$(BUILD_DIR)_headless
  170. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
  171. endif
  172. ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
  173. BUILD_DIR:=$(BUILD_DIR)_bpy
  174. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
  175. endif
  176. # -----------------------------------------------------------------------------
  177. # Blender binary path
  178. # Allow passing in own BLENDER_BIN so developers who don't
  179. # use the default build path can still use utility helpers.
  180. ifeq ($(OS), Darwin)
  181. BLENDER_BIN?="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
  182. else
  183. BLENDER_BIN?="$(BUILD_DIR)/bin/blender"
  184. endif
  185. # -----------------------------------------------------------------------------
  186. # Get the number of cores for threaded build
  187. ifndef NPROCS
  188. NPROCS:=1
  189. ifeq ($(OS), Linux)
  190. NPROCS:=$(shell nproc)
  191. endif
  192. ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
  193. NPROCS:=$(shell sysctl -n hw.ncpu)
  194. endif
  195. endif
  196. # -----------------------------------------------------------------------------
  197. # Macro for configuring cmake
  198. CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
  199. -H"$(BLENDER_DIR)" \
  200. -B"$(BUILD_DIR)" \
  201. -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
  202. # -----------------------------------------------------------------------------
  203. # Tool for 'make config'
  204. # X11 spesific
  205. ifdef DISPLAY
  206. CMAKE_CONFIG_TOOL = cmake-gui
  207. else
  208. CMAKE_CONFIG_TOOL = ccmake
  209. endif
  210. # -----------------------------------------------------------------------------
  211. # Build Blender
  212. all: .FORCE
  213. @echo
  214. @echo Configuring Blender in \"$(BUILD_DIR)\" ...
  215. # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
  216. # # $(CMAKE_CONFIG); \
  217. # # fi
  218. # # do this always incase of failed initial build, could be smarter here...
  219. @$(CMAKE_CONFIG)
  220. @echo
  221. @echo Building Blender ...
  222. $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
  223. @echo
  224. @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
  225. @echo Blender successfully built, run from: $(BLENDER_BIN)
  226. @echo
  227. debug: all
  228. full: all
  229. lite: all
  230. cycles: all
  231. headless: all
  232. bpy: all
  233. # -----------------------------------------------------------------------------
  234. # Build dependencies
  235. DEPS_TARGET = install
  236. ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
  237. DEPS_TARGET = clean
  238. endif
  239. deps: .FORCE
  240. @echo
  241. @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
  242. @cmake -H"$(DEPS_SOURCE_DIR)" \
  243. -B"$(DEPS_BUILD_DIR)" \
  244. -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
  245. @echo
  246. @echo Building dependencies ...
  247. $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
  248. @echo
  249. @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
  250. @echo
  251. # -----------------------------------------------------------------------------
  252. # Configuration (save some cd'ing around)
  253. config: .FORCE
  254. $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
  255. # -----------------------------------------------------------------------------
  256. # Help for build targets
  257. export HELP_TEXT
  258. help: .FORCE
  259. @echo "$$HELP_TEXT"
  260. # -----------------------------------------------------------------------------
  261. # Packages
  262. #
  263. package_debian: .FORCE
  264. cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
  265. package_pacman: .FORCE
  266. cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
  267. package_archive: .FORCE
  268. make -C "$(BUILD_DIR)" -s package_archive
  269. @echo archive in "$(BUILD_DIR)/release"
  270. # -----------------------------------------------------------------------------
  271. # Tests
  272. #
  273. test: .FORCE
  274. cd $(BUILD_DIR) ; ctest . --output-on-failure
  275. # run pep8 check check on scripts we distribute.
  276. test_pep8: .FORCE
  277. $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
  278. @echo "written: test_pep8.log"
  279. # run some checks on our cmakefiles.
  280. test_cmake: .FORCE
  281. $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
  282. @echo "written: test_cmake_consistency.log"
  283. # run deprecation tests, see if we have anything to remove.
  284. test_deprecated: .FORCE
  285. $(PYTHON) tests/check_deprecated.py
  286. test_style_c: .FORCE
  287. # run our own checks on C/C++ style
  288. PYTHONIOENCODING=utf_8 $(PYTHON) \
  289. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  290. "$(BLENDER_DIR)/source/blender" \
  291. "$(BLENDER_DIR)/source/creator" \
  292. --no-length-check
  293. test_style_c_qtc: .FORCE
  294. # run our own checks on C/C++ style
  295. USE_QTC_TASK=1 \
  296. PYTHONIOENCODING=utf_8 $(PYTHON) \
  297. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  298. "$(BLENDER_DIR)/source/blender" \
  299. "$(BLENDER_DIR)/source/creator" \
  300. --no-length-check \
  301. > \
  302. "$(BLENDER_DIR)/test_style.tasks"
  303. @echo "written: test_style.tasks"
  304. test_style_osl: .FORCE
  305. # run our own checks on C/C++ style
  306. PYTHONIOENCODING=utf_8 $(PYTHON) \
  307. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  308. "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
  309. "$(BLENDER_DIR)/release/scripts/templates_osl"
  310. test_style_osl_qtc: .FORCE
  311. # run our own checks on C/C++ style
  312. USE_QTC_TASK=1 \
  313. PYTHONIOENCODING=utf_8 $(PYTHON) \
  314. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  315. "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
  316. "$(BLENDER_DIR)/release/scripts/templates_osl" \
  317. > \
  318. "$(BLENDER_DIR)/test_style.tasks"
  319. @echo "written: test_style.tasks"
  320. # -----------------------------------------------------------------------------
  321. # Project Files
  322. #
  323. project_qtcreator: .FORCE
  324. $(PYTHON) build_files/cmake/cmake_qtcreator_project.py --build-dir "$(BUILD_DIR)"
  325. project_netbeans: .FORCE
  326. $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
  327. project_eclipse: .FORCE
  328. cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
  329. # -----------------------------------------------------------------------------
  330. # Static Checking
  331. #
  332. check_cppcheck: .FORCE
  333. $(CMAKE_CONFIG)
  334. cd "$(BUILD_DIR)" ; \
  335. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
  336. "$(BLENDER_DIR)/check_cppcheck.txt"
  337. @echo "written: check_cppcheck.txt"
  338. check_clang_array: .FORCE
  339. $(CMAKE_CONFIG)
  340. cd "$(BUILD_DIR)" ; \
  341. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
  342. check_splint: .FORCE
  343. $(CMAKE_CONFIG)
  344. cd "$(BUILD_DIR)" ; \
  345. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
  346. check_sparse: .FORCE
  347. $(CMAKE_CONFIG)
  348. cd "$(BUILD_DIR)" ; \
  349. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
  350. check_smatch: .FORCE
  351. $(CMAKE_CONFIG)
  352. cd "$(BUILD_DIR)" ; \
  353. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
  354. check_spelling_py: .FORCE
  355. cd "$(BUILD_DIR)" ; \
  356. PYTHONIOENCODING=utf_8 $(PYTHON) \
  357. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  358. "$(BLENDER_DIR)/release/scripts"
  359. check_spelling_c: .FORCE
  360. cd "$(BUILD_DIR)" ; \
  361. PYTHONIOENCODING=utf_8 $(PYTHON) \
  362. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  363. "$(BLENDER_DIR)/source" \
  364. "$(BLENDER_DIR)/intern/cycles" \
  365. "$(BLENDER_DIR)/intern/guardedalloc" \
  366. "$(BLENDER_DIR)/intern/ghost" \
  367. check_spelling_c_qtc: .FORCE
  368. cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
  369. PYTHONIOENCODING=utf_8 $(PYTHON) \
  370. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  371. "$(BLENDER_DIR)/source" \
  372. "$(BLENDER_DIR)/intern/cycles" \
  373. "$(BLENDER_DIR)/intern/guardedalloc" \
  374. "$(BLENDER_DIR)/intern/ghost" \
  375. > \
  376. "$(BLENDER_DIR)/check_spelling_c.tasks"
  377. check_spelling_osl: .FORCE
  378. cd "$(BUILD_DIR)" ;\
  379. PYTHONIOENCODING=utf_8 $(PYTHON) \
  380. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  381. "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
  382. check_descriptions: .FORCE
  383. $(BLENDER_BIN) --background -noaudio --factory-startup --python \
  384. "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
  385. # -----------------------------------------------------------------------------
  386. # Utilities
  387. #
  388. tgz: .FORCE
  389. ./build_files/utils/build_tgz.sh
  390. INKSCAPE_BIN?="inkscape"
  391. icons: .FORCE
  392. BLENDER_BIN=$(BLENDER_BIN) INKSCAPE_BIN=$(INKSCAPE_BIN) \
  393. "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
  394. BLENDER_BIN=$(BLENDER_BIN) INKSCAPE_BIN=$(INKSCAPE_BIN) \
  395. "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
  396. icons_geom: .FORCE
  397. BLENDER_BIN=$(BLENDER_BIN) \
  398. "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
  399. update: .FORCE
  400. if [ "$(OS_NCASE)" = "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
  401. svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
  402. fi
  403. if [ -d "../lib" ]; then \
  404. svn cleanup ../lib/* ; \
  405. svn update ../lib/* ; \
  406. fi
  407. git pull --rebase
  408. git submodule update --init --recursive
  409. git submodule foreach git checkout master
  410. git submodule foreach git pull --rebase origin master
  411. format: .FORCE
  412. PATH="../lib/${OS_NCASE}/llvm/bin/:$(PATH)" \
  413. python3 source/tools/utils_maintenance/clang_format_paths.py $(PATHS)
  414. # -----------------------------------------------------------------------------
  415. # Documentation
  416. #
  417. # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
  418. doc_py: .FORCE
  419. ASAN_OPTIONS=halt_on_error=0 \
  420. $(BLENDER_BIN) --background -noaudio --factory-startup \
  421. --python doc/python_api/sphinx_doc_gen.py
  422. cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
  423. @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'"
  424. doc_doxy: .FORCE
  425. cd doc/doxygen; doxygen Doxyfile
  426. @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
  427. doc_dna: .FORCE
  428. $(BLENDER_BIN) --background -noaudio --factory-startup \
  429. --python doc/blender_file_format/BlendFileDnaExporter_25.py
  430. @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
  431. doc_man: .FORCE
  432. $(PYTHON) doc/manpage/blender.1.py $(BLENDER_BIN) blender.1
  433. help_features: .FORCE
  434. @$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt"
  435. clean: .FORCE
  436. $(MAKE) -C "$(BUILD_DIR)" clean
  437. .PHONY: all
  438. .FORCE: