1 # -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
4 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
20 # ##### END GPL LICENSE BLOCK #####
22 # This Makefile does an out-of-source CMake build in ../build_`OS`_`CPU`
25 # This is for users who like to configure & build blender with a single command.
30 OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
31 # CPU:=$(shell uname -m) # UNUSED
34 # Source and Build DIR's
35 BLENDER_DIR:=$(shell pwd -P)
38 ifndef BUILD_CMAKE_ARGS
43 BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
47 # -----------------------------------------------------------------------------
48 # additional targets for the build configuration
50 # support 'make debug'
51 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
52 BUILD_DIR:=$(BUILD_DIR)_debug
55 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
56 BUILD_DIR:=$(BUILD_DIR)_full
57 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
59 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
60 BUILD_DIR:=$(BUILD_DIR)_lite
61 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
63 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
64 BUILD_DIR:=$(BUILD_DIR)_cycles
65 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
67 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
68 BUILD_DIR:=$(BUILD_DIR)_bpy
69 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
71 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
72 BUILD_DIR:=$(BUILD_DIR)_bpy
73 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
77 # -----------------------------------------------------------------------------
78 # Get the number of cores for threaded build
81 NPROCS:=$(shell nproc)
84 NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
87 NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
90 NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
94 # -----------------------------------------------------------------------------
95 # Macro for configuring cmake
97 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
100 -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
103 # -----------------------------------------------------------------------------
104 # Tool for 'make config'
108 CMAKE_CONFIG_TOOL = cmake-gui
110 CMAKE_CONFIG_TOOL = ccmake
114 # -----------------------------------------------------------------------------
118 @echo Configuring Blender ...
120 # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
124 # do this always incase of failed initial build, could be smarter here...
128 @echo Building Blender ...
129 $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
131 @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
132 @echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
143 # -----------------------------------------------------------------------------
144 # Configuration (save some cd'ing around)
146 $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
149 # -----------------------------------------------------------------------------
150 # Help for build targets
153 @echo "Convenience targets provided for building blender, (multiple at once can be used)"
154 @echo " * debug - build a debug binary"
155 @echo " * full - enable all supported dependencies & options"
156 @echo " * lite - disable non essential features for a smaller binary and faster build"
157 @echo " * headless - build without an interface (renderfarm or server automation)"
158 @echo " * cycles - build Cycles standalone only, without Blender"
159 @echo " * bpy - build as a python module which can be loaded from python directly"
161 @echo " * config - run cmake configuration tool to set build options"
163 @echo " Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
164 @echo " Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
167 @echo "Project Files for IDE's"
168 @echo " * project_qtcreator - QtCreator Project Files"
169 @echo " * project_netbeans - NetBeans Project Files"
170 @echo " * project_eclipse - Eclipse CDT4 Project Files"
172 @echo "Package Targets"
173 @echo " * package_debian - build a debian package"
174 @echo " * package_pacman - build an arch linux pacmanpackage"
175 @echo " * package_archive - build an archive package"
177 @echo "Testing Targets (not associated with building blender)"
178 @echo " * test - run ctest, currently tests import/export, operator execution and that python modules load"
179 @echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions"
180 @echo " * test_pep8 - checks all python script are pep8 which are tagged to use the stricter formatting"
181 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
182 @echo " * test_style_c - checks C/C++ conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
183 @echo " * test_style_c_qtc - same as test_style but outputs QtCreator tasks format"
184 @echo " * test_style_osl - checks OpenShadingLanguage conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
185 @echo " * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
187 @echo "Static Source Code Checking (not associated with building blender)"
188 @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
189 @echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
190 @echo " * check_splint - run blenders source through splint (C only)"
191 @echo " * check_sparse - run blenders source through sparse (C only)"
192 @echo " * check_smatch - run blenders source through smatch (C only)"
193 @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
194 @echo " * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
195 @echo " * check_spelling_osl - check for spelling errors (OSL only)"
196 @echo " * check_spelling_py - check for spelling errors (Python only)"
197 @echo " * check_descriptions - check for duplicate/invalid descriptions"
199 @echo "Utilities (not associated with building blender)"
200 @echo " * icons - updates PNG icons from SVG files."
201 @echo " * tgz - create a compressed archive of the source code."
202 @echo " * update - updates git and all submodules"
204 @echo "Documentation Targets (not associated with building blender)"
205 @echo " * doc_py - generate sphinx python api docs"
206 @echo " * doc_doxy - generate doxygen C/C++ docs"
207 @echo " * doc_dna - generate blender file format reference"
208 @echo " * doc_man - generate manpage"
211 @echo " * help - this help message"
212 @echo " * help_features - show a list of optional features when building"
214 # -----------------------------------------------------------------------------
217 package_debian: FORCE
218 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
220 package_pacman: FORCE
221 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
223 package_archive: FORCE
224 make -C "$(BUILD_DIR)" -s package_archive
225 @echo archive in "$(BUILD_DIR)/release"
228 # -----------------------------------------------------------------------------
232 cd $(BUILD_DIR) ; ctest . --output-on-failure
234 # run pep8 check check on scripts we distribute.
236 python3 tests/python/pep8.py > test_pep8.log 2>&1
237 @echo "written: test_pep8.log"
239 # run some checks on our cmakefiles.
241 python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
242 @echo "written: test_cmake_consistency.log"
244 # run deprecation tests, see if we have anything to remove.
245 test_deprecated: FORCE
246 python3 tests/check_deprecated.py
249 # run our own checks on C/C++ style
250 PYTHONIOENCODING=utf_8 python3 \
251 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
252 "$(BLENDER_DIR)/source/blender" \
253 "$(BLENDER_DIR)/source/creator" \
256 test_style_c_qtc: FORCE
257 # run our own checks on C/C++ style
259 PYTHONIOENCODING=utf_8 python3 \
260 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
261 "$(BLENDER_DIR)/source/blender" \
262 "$(BLENDER_DIR)/source/creator" \
265 "$(BLENDER_DIR)/test_style.tasks"
266 @echo "written: test_style.tasks"
269 test_style_osl: FORCE
270 # run our own checks on C/C++ style
271 PYTHONIOENCODING=utf_8 python3 \
272 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
273 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
274 "$(BLENDER_DIR)/release/scripts/templates_osl"
277 test_style_osl_qtc: FORCE
278 # run our own checks on C/C++ style
280 PYTHONIOENCODING=utf_8 python3 \
281 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
282 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
283 "$(BLENDER_DIR)/release/scripts/templates_osl" \
285 "$(BLENDER_DIR)/test_style.tasks"
286 @echo "written: test_style.tasks"
288 # -----------------------------------------------------------------------------
292 project_qtcreator: FORCE
293 python3 build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
295 project_netbeans: FORCE
296 python3 build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
298 project_eclipse: FORCE
299 cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
302 # -----------------------------------------------------------------------------
306 check_cppcheck: FORCE
308 cd "$(BUILD_DIR)" ; \
309 python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
310 "$(BLENDER_DIR)/check_cppcheck.txt"
311 @echo "written: check_cppcheck.txt"
313 check_clang_array: FORCE
315 cd "$(BUILD_DIR)" ; \
316 python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
320 cd "$(BUILD_DIR)" ; \
321 python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
325 cd "$(BUILD_DIR)" ; \
326 python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
330 cd "$(BUILD_DIR)" ; \
331 python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
333 check_spelling_py: FORCE
334 cd "$(BUILD_DIR)" ; \
335 PYTHONIOENCODING=utf_8 python3 \
336 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
337 "$(BLENDER_DIR)/release/scripts"
339 check_spelling_c: FORCE
340 cd "$(BUILD_DIR)" ; \
341 PYTHONIOENCODING=utf_8 python3 \
342 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
343 "$(BLENDER_DIR)/source" \
344 "$(BLENDER_DIR)/intern/cycles" \
345 "$(BLENDER_DIR)/intern/guardedalloc" \
346 "$(BLENDER_DIR)/intern/ghost" \
348 check_spelling_c_qtc: FORCE
349 cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
350 PYTHONIOENCODING=utf_8 python3 \
351 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
352 "$(BLENDER_DIR)/source" \
353 "$(BLENDER_DIR)/intern/cycles" \
354 "$(BLENDER_DIR)/intern/guardedalloc" \
355 "$(BLENDER_DIR)/intern/ghost" \
357 "$(BLENDER_DIR)/check_spelling_c.tasks"
359 check_spelling_osl: FORCE
361 PYTHONIOENCODING=utf_8 python3 \
362 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
363 "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
365 check_descriptions: FORCE
366 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python \
367 "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
369 # -----------------------------------------------------------------------------
374 ./build_files/utils/build_tgz.sh
377 "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
378 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
381 if [ -d "../lib" ]; then \
382 svn update ../lib/* ; \
385 git submodule foreach git pull --rebase origin master
388 # -----------------------------------------------------------------------------
392 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
394 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py
395 cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
396 @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
399 cd doc/doxygen; doxygen Doxyfile
400 @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
403 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py
404 @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
407 python3 doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
413 w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
414 if not l.lstrip().startswith('#') \
416 r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\".*\")\s*.*', r'\g<1> - \g<2>', l).strip('() \n'),) \
417 if w.startswith('WITH_')]))" | uniq
421 $(MAKE) -C "$(BUILD_DIR)" clean