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)
46 # Allow to use alternative binary (pypy3, etc)
52 # -----------------------------------------------------------------------------
53 # additional targets for the build configuration
55 # support 'make debug'
56 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
57 BUILD_DIR:=$(BUILD_DIR)_debug
60 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
61 BUILD_DIR:=$(BUILD_DIR)_full
62 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
64 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
65 BUILD_DIR:=$(BUILD_DIR)_lite
66 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
68 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
69 BUILD_DIR:=$(BUILD_DIR)_cycles
70 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
72 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
73 BUILD_DIR:=$(BUILD_DIR)_headless
74 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
76 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
77 BUILD_DIR:=$(BUILD_DIR)_bpy
78 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
82 # -----------------------------------------------------------------------------
83 # Get the number of cores for threaded build
87 NPROCS:=$(shell nproc)
90 NPROCS:=$(shell sysctl -n hw.ncpu)
93 NPROCS:=$(shell sysctl -n hw.ncpu)
96 NPROCS:=$(shell sysctl -n hw.ncpu)
101 # -----------------------------------------------------------------------------
102 # Macro for configuring cmake
104 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
107 -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
110 # -----------------------------------------------------------------------------
111 # Tool for 'make config'
115 CMAKE_CONFIG_TOOL = cmake-gui
117 CMAKE_CONFIG_TOOL = ccmake
121 # -----------------------------------------------------------------------------
125 @echo Configuring Blender in \"$(BUILD_DIR)\" ...
127 # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
128 # # $(CMAKE_CONFIG); \
131 # # do this always incase of failed initial build, could be smarter here...
135 @echo Building Blender ...
136 $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
138 @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
139 @echo Blender successfully built, run from: "$(BUILD_DIR)/bin/blender"
150 # -----------------------------------------------------------------------------
151 # Configuration (save some cd'ing around)
153 $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
156 # -----------------------------------------------------------------------------
157 # Help for build targets
160 @echo "Convenience targets provided for building blender, (multiple at once can be used)"
161 @echo " * debug - build a debug binary"
162 @echo " * full - enable all supported dependencies & options"
163 @echo " * lite - disable non essential features for a smaller binary and faster build"
164 @echo " * headless - build without an interface (renderfarm or server automation)"
165 @echo " * cycles - build Cycles standalone only, without Blender"
166 @echo " * bpy - build as a python module which can be loaded from python directly"
168 @echo " * config - run cmake configuration tool to set build options"
170 @echo " Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
171 @echo " Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
174 @echo "Project Files for IDE's"
175 @echo " * project_qtcreator - QtCreator Project Files"
176 @echo " * project_netbeans - NetBeans Project Files"
177 @echo " * project_eclipse - Eclipse CDT4 Project Files"
179 @echo "Package Targets"
180 @echo " * package_debian - build a debian package"
181 @echo " * package_pacman - build an arch linux pacman package"
182 @echo " * package_archive - build an archive package"
184 @echo "Testing Targets (not associated with building blender)"
185 @echo " * test - run ctest, currently tests import/export, operator execution and that python modules load"
186 @echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions"
187 @echo " * test_pep8 - checks all python script are pep8 which are tagged to use the stricter formatting"
188 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
189 @echo " * test_style_c - checks C/C++ conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
190 @echo " * test_style_c_qtc - same as test_style but outputs QtCreator tasks format"
191 @echo " * test_style_osl - checks OpenShadingLanguage conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
192 @echo " * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
194 @echo "Static Source Code Checking (not associated with building blender)"
195 @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
196 @echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
197 @echo " * check_splint - run blenders source through splint (C only)"
198 @echo " * check_sparse - run blenders source through sparse (C only)"
199 @echo " * check_smatch - run blenders source through smatch (C only)"
200 @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
201 @echo " * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
202 @echo " * check_spelling_osl - check for spelling errors (OSL only)"
203 @echo " * check_spelling_py - check for spelling errors (Python only)"
204 @echo " * check_descriptions - check for duplicate/invalid descriptions"
206 @echo "Utilities (not associated with building blender)"
207 @echo " * icons - updates PNG icons from SVG files."
208 @echo " * tgz - create a compressed archive of the source code."
209 @echo " * update - updates git and all submodules"
211 @echo "Environment Variables"
212 @echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
213 @echo " * BUILD_DIR - override default build path."
214 @echo " * PYTHON - use this for the Python command (used for checking tools)."
215 @echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
217 @echo "Documentation Targets (not associated with building blender)"
218 @echo " * doc_py - generate sphinx python api docs"
219 @echo " * doc_doxy - generate doxygen C/C++ docs"
220 @echo " * doc_dna - generate blender file format reference"
221 @echo " * doc_man - generate manpage"
224 @echo " * help - this help message"
225 @echo " * help_features - show a list of optional features when building"
228 # -----------------------------------------------------------------------------
231 package_debian: .FORCE
232 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
234 package_pacman: .FORCE
235 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
237 package_archive: .FORCE
238 make -C "$(BUILD_DIR)" -s package_archive
239 @echo archive in "$(BUILD_DIR)/release"
242 # -----------------------------------------------------------------------------
246 cd $(BUILD_DIR) ; ctest . --output-on-failure
248 # run pep8 check check on scripts we distribute.
250 $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
251 @echo "written: test_pep8.log"
253 # run some checks on our cmakefiles.
255 $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
256 @echo "written: test_cmake_consistency.log"
258 # run deprecation tests, see if we have anything to remove.
259 test_deprecated: .FORCE
260 $(PYTHON) tests/check_deprecated.py
263 # run our own checks on C/C++ style
264 PYTHONIOENCODING=utf_8 $(PYTHON) \
265 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
266 "$(BLENDER_DIR)/source/blender" \
267 "$(BLENDER_DIR)/source/creator" \
270 test_style_c_qtc: .FORCE
271 # run our own checks on C/C++ style
273 PYTHONIOENCODING=utf_8 $(PYTHON) \
274 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
275 "$(BLENDER_DIR)/source/blender" \
276 "$(BLENDER_DIR)/source/creator" \
279 "$(BLENDER_DIR)/test_style.tasks"
280 @echo "written: test_style.tasks"
283 test_style_osl: .FORCE
284 # run our own checks on C/C++ style
285 PYTHONIOENCODING=utf_8 $(PYTHON) \
286 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
287 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
288 "$(BLENDER_DIR)/release/scripts/templates_osl"
291 test_style_osl_qtc: .FORCE
292 # run our own checks on C/C++ style
294 PYTHONIOENCODING=utf_8 $(PYTHON) \
295 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
296 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
297 "$(BLENDER_DIR)/release/scripts/templates_osl" \
299 "$(BLENDER_DIR)/test_style.tasks"
300 @echo "written: test_style.tasks"
302 # -----------------------------------------------------------------------------
306 project_qtcreator: .FORCE
307 $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
309 project_netbeans: .FORCE
310 $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
312 project_eclipse: .FORCE
313 cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
316 # -----------------------------------------------------------------------------
320 check_cppcheck: .FORCE
322 cd "$(BUILD_DIR)" ; \
323 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
324 "$(BLENDER_DIR)/check_cppcheck.txt"
325 @echo "written: check_cppcheck.txt"
327 check_clang_array: .FORCE
329 cd "$(BUILD_DIR)" ; \
330 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
334 cd "$(BUILD_DIR)" ; \
335 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
339 cd "$(BUILD_DIR)" ; \
340 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
344 cd "$(BUILD_DIR)" ; \
345 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
347 check_spelling_py: .FORCE
348 cd "$(BUILD_DIR)" ; \
349 PYTHONIOENCODING=utf_8 $(PYTHON) \
350 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
351 "$(BLENDER_DIR)/release/scripts"
353 check_spelling_c: .FORCE
354 cd "$(BUILD_DIR)" ; \
355 PYTHONIOENCODING=utf_8 $(PYTHON) \
356 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
357 "$(BLENDER_DIR)/source" \
358 "$(BLENDER_DIR)/intern/cycles" \
359 "$(BLENDER_DIR)/intern/guardedalloc" \
360 "$(BLENDER_DIR)/intern/ghost" \
362 check_spelling_c_qtc: .FORCE
363 cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
364 PYTHONIOENCODING=utf_8 $(PYTHON) \
365 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
366 "$(BLENDER_DIR)/source" \
367 "$(BLENDER_DIR)/intern/cycles" \
368 "$(BLENDER_DIR)/intern/guardedalloc" \
369 "$(BLENDER_DIR)/intern/ghost" \
371 "$(BLENDER_DIR)/check_spelling_c.tasks"
373 check_spelling_osl: .FORCE
375 PYTHONIOENCODING=utf_8 $(PYTHON) \
376 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
377 "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
379 check_descriptions: .FORCE
380 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python \
381 "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
383 # -----------------------------------------------------------------------------
388 ./build_files/utils/build_tgz.sh
391 "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
392 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
395 if [ -d "../lib" ]; then \
396 svn update ../lib/* ; \
399 git submodule foreach git pull --rebase origin master
402 # -----------------------------------------------------------------------------
406 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
408 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py
409 cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
410 @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
413 cd doc/doxygen; doxygen Doxyfile
414 @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
417 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py
418 @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
421 $(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
423 help_features: .FORCE
427 w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
428 if not l.lstrip().startswith('#') \
430 r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\".*\")\s*.*', r'\g<1> - \g<2>', l).strip('() \n'),) \
431 if w.startswith('WITH_')]))" | uniq
435 $(MAKE) -C "$(BUILD_DIR)" clean