GNUmakefile 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. # System Vars
  26. OS:=$(shell uname -s)
  27. OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
  28. # CPU:=$(shell uname -m) # UNUSED
  29. # Source and Build DIR's
  30. BLENDER_DIR:=$(shell pwd -P)
  31. BUILD_TYPE:=Release
  32. ifndef BUILD_CMAKE_ARGS
  33. BUILD_CMAKE_ARGS:=
  34. endif
  35. ifndef BUILD_DIR
  36. BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
  37. endif
  38. # Allow to use alternative binary (pypy3, etc)
  39. ifndef PYTHON
  40. PYTHON:=python3
  41. endif
  42. # -----------------------------------------------------------------------------
  43. # additional targets for the build configuration
  44. # support 'make debug'
  45. ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
  46. BUILD_DIR:=$(BUILD_DIR)_debug
  47. BUILD_TYPE:=Debug
  48. endif
  49. ifneq "$(findstring full, $(MAKECMDGOALS))" ""
  50. BUILD_DIR:=$(BUILD_DIR)_full
  51. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
  52. endif
  53. ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
  54. BUILD_DIR:=$(BUILD_DIR)_lite
  55. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
  56. endif
  57. ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
  58. BUILD_DIR:=$(BUILD_DIR)_cycles
  59. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
  60. endif
  61. ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
  62. BUILD_DIR:=$(BUILD_DIR)_headless
  63. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
  64. endif
  65. ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
  66. BUILD_DIR:=$(BUILD_DIR)_bpy
  67. BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
  68. endif
  69. # -----------------------------------------------------------------------------
  70. # Get the number of cores for threaded build
  71. ifndef NPROCS
  72. NPROCS:=1
  73. ifeq ($(OS), Linux)
  74. NPROCS:=$(shell nproc)
  75. endif
  76. ifeq ($(OS), Darwin)
  77. NPROCS:=$(shell sysctl -n hw.ncpu)
  78. endif
  79. ifeq ($(OS), FreeBSD)
  80. NPROCS:=$(shell sysctl -n hw.ncpu)
  81. endif
  82. ifeq ($(OS), NetBSD)
  83. NPROCS:=$(shell sysctl -n hw.ncpu)
  84. endif
  85. endif
  86. # -----------------------------------------------------------------------------
  87. # Macro for configuring cmake
  88. CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
  89. -H"$(BLENDER_DIR)" \
  90. -B"$(BUILD_DIR)" \
  91. -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
  92. # -----------------------------------------------------------------------------
  93. # Tool for 'make config'
  94. # X11 spesific
  95. ifdef DISPLAY
  96. CMAKE_CONFIG_TOOL = cmake-gui
  97. else
  98. CMAKE_CONFIG_TOOL = ccmake
  99. endif
  100. # -----------------------------------------------------------------------------
  101. # Build Blender
  102. all: .FORCE
  103. @echo
  104. @echo Configuring Blender in \"$(BUILD_DIR)\" ...
  105. # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
  106. # # $(CMAKE_CONFIG); \
  107. # # fi
  108. # # do this always incase of failed initial build, could be smarter here...
  109. @$(CMAKE_CONFIG)
  110. @echo
  111. @echo Building Blender ...
  112. $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
  113. @echo
  114. @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
  115. @echo Blender successfully built, run from: "$(BUILD_DIR)/bin/blender"
  116. @echo
  117. debug: all
  118. full: all
  119. lite: all
  120. cycles: all
  121. headless: all
  122. bpy: all
  123. # -----------------------------------------------------------------------------
  124. # Configuration (save some cd'ing around)
  125. config: .FORCE
  126. $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
  127. # -----------------------------------------------------------------------------
  128. # Help for build targets
  129. help: .FORCE
  130. @echo ""
  131. @echo "Convenience targets provided for building blender, (multiple at once can be used)"
  132. @echo " * debug - build a debug binary"
  133. @echo " * full - enable all supported dependencies & options"
  134. @echo " * lite - disable non essential features for a smaller binary and faster build"
  135. @echo " * headless - build without an interface (renderfarm or server automation)"
  136. @echo " * cycles - build Cycles standalone only, without Blender"
  137. @echo " * bpy - build as a python module which can be loaded from python directly"
  138. @echo ""
  139. @echo " * config - run cmake configuration tool to set build options"
  140. @echo ""
  141. @echo " Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
  142. @echo " Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
  143. @echo ""
  144. @echo ""
  145. @echo "Project Files for IDE's"
  146. @echo " * project_qtcreator - QtCreator Project Files"
  147. @echo " * project_netbeans - NetBeans Project Files"
  148. @echo " * project_eclipse - Eclipse CDT4 Project Files"
  149. @echo ""
  150. @echo "Package Targets"
  151. @echo " * package_debian - build a debian package"
  152. @echo " * package_pacman - build an arch linux pacman package"
  153. @echo " * package_archive - build an archive package"
  154. @echo ""
  155. @echo "Testing Targets (not associated with building blender)"
  156. @echo " * test - run ctest, currently tests import/export,"
  157. @echo " operator execution and that python modules load"
  158. @echo " * test_cmake - runs our own cmake file checker"
  159. @echo " which detects errors in the cmake file list definitions"
  160. @echo " * test_pep8 - checks all python script are pep8"
  161. @echo " which are tagged to use the stricter formatting"
  162. @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
  163. @echo " * test_style_c - checks C/C++ conforms with blenders style guide:"
  164. @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
  165. @echo " * test_style_c_qtc - same as test_style but outputs QtCreator tasks format"
  166. @echo " * test_style_osl - checks OpenShadingLanguage conforms with blenders style guide:"
  167. @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
  168. @echo " * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide:"
  169. @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
  170. @echo ""
  171. @echo "Static Source Code Checking (not associated with building blender)"
  172. @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
  173. @echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
  174. @echo " * check_splint - run blenders source through splint (C only)"
  175. @echo " * check_sparse - run blenders source through sparse (C only)"
  176. @echo " * check_smatch - run blenders source through smatch (C only)"
  177. @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
  178. @echo " * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
  179. @echo " * check_spelling_osl - check for spelling errors (OSL only)"
  180. @echo " * check_spelling_py - check for spelling errors (Python only)"
  181. @echo " * check_descriptions - check for duplicate/invalid descriptions"
  182. @echo ""
  183. @echo "Utilities (not associated with building blender)"
  184. @echo " * icons - updates PNG icons from SVG files."
  185. @echo " * tgz - create a compressed archive of the source code."
  186. @echo " * update - updates git and all submodules"
  187. @echo ""
  188. @echo "Environment Variables"
  189. @echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
  190. @echo " * BUILD_DIR - override default build path."
  191. @echo " * PYTHON - use this for the Python command (used for checking tools)."
  192. @echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
  193. @echo ""
  194. @echo "Documentation Targets (not associated with building blender)"
  195. @echo " * doc_py - generate sphinx python api docs"
  196. @echo " * doc_doxy - generate doxygen C/C++ docs"
  197. @echo " * doc_dna - generate blender file format reference"
  198. @echo " * doc_man - generate manpage"
  199. @echo ""
  200. @echo "Information"
  201. @echo " * help - this help message"
  202. @echo " * help_features - show a list of optional features when building"
  203. @echo ""
  204. # -----------------------------------------------------------------------------
  205. # Packages
  206. #
  207. package_debian: .FORCE
  208. cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
  209. package_pacman: .FORCE
  210. cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
  211. package_archive: .FORCE
  212. make -C "$(BUILD_DIR)" -s package_archive
  213. @echo archive in "$(BUILD_DIR)/release"
  214. # -----------------------------------------------------------------------------
  215. # Tests
  216. #
  217. test: .FORCE
  218. cd $(BUILD_DIR) ; ctest . --output-on-failure
  219. # run pep8 check check on scripts we distribute.
  220. test_pep8: .FORCE
  221. $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
  222. @echo "written: test_pep8.log"
  223. # run some checks on our cmakefiles.
  224. test_cmake: .FORCE
  225. $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
  226. @echo "written: test_cmake_consistency.log"
  227. # run deprecation tests, see if we have anything to remove.
  228. test_deprecated: .FORCE
  229. $(PYTHON) tests/check_deprecated.py
  230. test_style_c: .FORCE
  231. # run our own checks on C/C++ style
  232. PYTHONIOENCODING=utf_8 $(PYTHON) \
  233. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  234. "$(BLENDER_DIR)/source/blender" \
  235. "$(BLENDER_DIR)/source/creator" \
  236. --no-length-check
  237. test_style_c_qtc: .FORCE
  238. # run our own checks on C/C++ style
  239. USE_QTC_TASK=1 \
  240. PYTHONIOENCODING=utf_8 $(PYTHON) \
  241. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  242. "$(BLENDER_DIR)/source/blender" \
  243. "$(BLENDER_DIR)/source/creator" \
  244. --no-length-check \
  245. > \
  246. "$(BLENDER_DIR)/test_style.tasks"
  247. @echo "written: test_style.tasks"
  248. test_style_osl: .FORCE
  249. # run our own checks on C/C++ style
  250. PYTHONIOENCODING=utf_8 $(PYTHON) \
  251. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  252. "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
  253. "$(BLENDER_DIR)/release/scripts/templates_osl"
  254. test_style_osl_qtc: .FORCE
  255. # run our own checks on C/C++ style
  256. USE_QTC_TASK=1 \
  257. PYTHONIOENCODING=utf_8 $(PYTHON) \
  258. "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
  259. "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
  260. "$(BLENDER_DIR)/release/scripts/templates_osl" \
  261. > \
  262. "$(BLENDER_DIR)/test_style.tasks"
  263. @echo "written: test_style.tasks"
  264. # -----------------------------------------------------------------------------
  265. # Project Files
  266. #
  267. project_qtcreator: .FORCE
  268. $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
  269. project_netbeans: .FORCE
  270. $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
  271. project_eclipse: .FORCE
  272. cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
  273. # -----------------------------------------------------------------------------
  274. # Static Checking
  275. #
  276. check_cppcheck: .FORCE
  277. $(CMAKE_CONFIG)
  278. cd "$(BUILD_DIR)" ; \
  279. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
  280. "$(BLENDER_DIR)/check_cppcheck.txt"
  281. @echo "written: check_cppcheck.txt"
  282. check_clang_array: .FORCE
  283. $(CMAKE_CONFIG)
  284. cd "$(BUILD_DIR)" ; \
  285. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
  286. check_splint: .FORCE
  287. $(CMAKE_CONFIG)
  288. cd "$(BUILD_DIR)" ; \
  289. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
  290. check_sparse: .FORCE
  291. $(CMAKE_CONFIG)
  292. cd "$(BUILD_DIR)" ; \
  293. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
  294. check_smatch: .FORCE
  295. $(CMAKE_CONFIG)
  296. cd "$(BUILD_DIR)" ; \
  297. $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
  298. check_spelling_py: .FORCE
  299. cd "$(BUILD_DIR)" ; \
  300. PYTHONIOENCODING=utf_8 $(PYTHON) \
  301. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  302. "$(BLENDER_DIR)/release/scripts"
  303. check_spelling_c: .FORCE
  304. cd "$(BUILD_DIR)" ; \
  305. PYTHONIOENCODING=utf_8 $(PYTHON) \
  306. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  307. "$(BLENDER_DIR)/source" \
  308. "$(BLENDER_DIR)/intern/cycles" \
  309. "$(BLENDER_DIR)/intern/guardedalloc" \
  310. "$(BLENDER_DIR)/intern/ghost" \
  311. check_spelling_c_qtc: .FORCE
  312. cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
  313. PYTHONIOENCODING=utf_8 $(PYTHON) \
  314. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  315. "$(BLENDER_DIR)/source" \
  316. "$(BLENDER_DIR)/intern/cycles" \
  317. "$(BLENDER_DIR)/intern/guardedalloc" \
  318. "$(BLENDER_DIR)/intern/ghost" \
  319. > \
  320. "$(BLENDER_DIR)/check_spelling_c.tasks"
  321. check_spelling_osl: .FORCE
  322. cd "$(BUILD_DIR)" ;\
  323. PYTHONIOENCODING=utf_8 $(PYTHON) \
  324. "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
  325. "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
  326. check_descriptions: .FORCE
  327. "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python \
  328. "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
  329. # -----------------------------------------------------------------------------
  330. # Utilities
  331. #
  332. tgz: .FORCE
  333. ./build_files/utils/build_tgz.sh
  334. icons: .FORCE
  335. "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
  336. "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
  337. update: .FORCE
  338. if [ -d "../lib" ]; then \
  339. svn update ../lib/* ; \
  340. fi
  341. git pull --rebase
  342. git submodule foreach git pull --rebase origin master
  343. # -----------------------------------------------------------------------------
  344. # Documentation
  345. #
  346. # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
  347. doc_py: .FORCE
  348. "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup \
  349. --python doc/python_api/sphinx_doc_gen.py
  350. cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
  351. @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
  352. doc_doxy: .FORCE
  353. cd doc/doxygen; doxygen Doxyfile
  354. @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
  355. doc_dna: .FORCE
  356. "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup \
  357. --python doc/blender_file_format/BlendFileDnaExporter_25.py
  358. @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
  359. doc_man: .FORCE
  360. $(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
  361. help_features: .FORCE
  362. @$(PYTHON) -c \
  363. "import re; \
  364. print('\n'.join([ \
  365. w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
  366. if not l.lstrip().startswith('#') \
  367. for w in (re.sub(\
  368. r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\".*\")\s*.*', r'\g<1> - \g<2>', l).strip('() \n'),) \
  369. if w.startswith('WITH_')]))" | uniq
  370. clean: .FORCE
  371. $(MAKE) -C "$(BUILD_DIR)" clean
  372. .PHONY: all
  373. .FORCE: