1 # -*- mode: gnumakefile; tab-width: 4; 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 DEPS_SOURCE_DIR:=$(BLENDER_DIR)/build_files/build_environment
50 DEPS_BUILD_DIR:=$(BUILD_DIR)/deps
53 ifndef DEPS_INSTALL_DIR
54 DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
56 ifneq ($(OS_NCASE),darwin)
57 # Add processor type to directory name
58 DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(shell uname -p)
62 # Allow to use alternative binary (pypy3, etc)
68 # -----------------------------------------------------------------------------
69 # additional targets for the build configuration
71 # support 'make debug'
72 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
73 BUILD_DIR:=$(BUILD_DIR)_debug
76 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
77 BUILD_DIR:=$(BUILD_DIR)_full
78 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
80 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
81 BUILD_DIR:=$(BUILD_DIR)_lite
82 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
84 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
85 BUILD_DIR:=$(BUILD_DIR)_cycles
86 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
88 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
89 BUILD_DIR:=$(BUILD_DIR)_headless
90 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
92 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
93 BUILD_DIR:=$(BUILD_DIR)_bpy
94 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
98 # -----------------------------------------------------------------------------
102 BLENDER_BIN="$(BUILD_DIR)/bin/blender.app/Contents/MacOS/blender"
104 BLENDER_BIN="$(BUILD_DIR)/bin/blender"
108 # -----------------------------------------------------------------------------
109 # Get the number of cores for threaded build
113 NPROCS:=$(shell nproc)
115 ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
116 NPROCS:=$(shell sysctl -n hw.ncpu)
121 # -----------------------------------------------------------------------------
122 # Macro for configuring cmake
124 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
127 -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
130 # -----------------------------------------------------------------------------
131 # Tool for 'make config'
135 CMAKE_CONFIG_TOOL = cmake-gui
137 CMAKE_CONFIG_TOOL = ccmake
141 # -----------------------------------------------------------------------------
145 @echo Configuring Blender in \"$(BUILD_DIR)\" ...
147 # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
148 # # $(CMAKE_CONFIG); \
151 # # do this always incase of failed initial build, could be smarter here...
155 @echo Building Blender ...
156 $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
158 @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
159 @echo Blender successfully built, run from: $(BLENDER_BIN)
169 # -----------------------------------------------------------------------------
171 DEPS_TARGET = install
172 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
178 @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
180 @cmake -H"$(DEPS_SOURCE_DIR)" \
181 -B"$(DEPS_BUILD_DIR)" \
182 -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
185 @echo Building dependencies ...
186 $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
188 @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
191 # -----------------------------------------------------------------------------
192 # Configuration (save some cd'ing around)
194 $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
197 # -----------------------------------------------------------------------------
198 # Help for build targets
201 @echo "Convenience targets provided for building blender, (multiple at once can be used)"
202 @echo " * debug - build a debug binary"
203 @echo " * full - enable all supported dependencies & options"
204 @echo " * lite - disable non essential features for a smaller binary and faster build"
205 @echo " * headless - build without an interface (renderfarm or server automation)"
206 @echo " * cycles - build Cycles standalone only, without Blender"
207 @echo " * bpy - build as a python module which can be loaded from python directly"
208 @echo " * deps - build library dependencies (intended only for platform maintainers)"
210 @echo " * config - run cmake configuration tool to set build options"
212 @echo " Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
213 @echo " Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
216 @echo "Project Files for IDE's"
217 @echo " * project_qtcreator - QtCreator Project Files"
218 @echo " * project_netbeans - NetBeans Project Files"
219 @echo " * project_eclipse - Eclipse CDT4 Project Files"
221 @echo "Package Targets"
222 @echo " * package_debian - build a debian package"
223 @echo " * package_pacman - build an arch linux pacman package"
224 @echo " * package_archive - build an archive package"
226 @echo "Testing Targets (not associated with building blender)"
227 @echo " * test - run ctest, currently tests import/export,"
228 @echo " operator execution and that python modules load"
229 @echo " * test_cmake - runs our own cmake file checker"
230 @echo " which detects errors in the cmake file list definitions"
231 @echo " * test_pep8 - checks all python script are pep8"
232 @echo " which are tagged to use the stricter formatting"
233 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
234 @echo " * test_style_c - checks C/C++ conforms with blenders style guide:"
235 @echo " https://wiki.blender.org/wiki/Source/Code_Style"
236 @echo " * test_style_c_qtc - same as test_style but outputs QtCreator tasks format"
237 @echo " * test_style_osl - checks OpenShadingLanguage conforms with blenders style guide:"
238 @echo " https://wiki.blender.org/wiki/Source/Code_Style"
239 @echo " * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide:"
240 @echo " https://wiki.blender.org/wiki/Source/Code_Style"
242 @echo "Static Source Code Checking (not associated with building blender)"
243 @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
244 @echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
245 @echo " * check_splint - run blenders source through splint (C only)"
246 @echo " * check_sparse - run blenders source through sparse (C only)"
247 @echo " * check_smatch - run blenders source through smatch (C only)"
248 @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
249 @echo " * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
250 @echo " * check_spelling_osl - check for spelling errors (OSL only)"
251 @echo " * check_spelling_py - check for spelling errors (Python only)"
252 @echo " * check_descriptions - check for duplicate/invalid descriptions"
254 @echo "Utilities (not associated with building blender)"
255 @echo " * icons - Updates PNG icons from SVG files."
256 @echo " Set environment variables 'BLENDER_BIN' and 'INKSCAPE_BIN'"
257 @echo " to define your own commands."
258 @echo " * icons_geom - Updates Geometry icons from BLEND file."
259 @echo " Set environment variable 'BLENDER_BIN'"
260 @echo " to define your own command."
261 @echo " * tgz - create a compressed archive of the source code."
262 @echo " * update - updates git and all submodules"
264 @echo "Environment Variables"
265 @echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
266 @echo " * BUILD_DIR - override default build path."
267 @echo " * PYTHON - use this for the Python command (used for checking tools)."
268 @echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
270 @echo "Documentation Targets (not associated with building blender)"
271 @echo " * doc_py - generate sphinx python api docs"
272 @echo " * doc_doxy - generate doxygen C/C++ docs"
273 @echo " * doc_dna - generate blender file format reference"
274 @echo " * doc_man - generate manpage"
277 @echo " * help - this help message"
278 @echo " * help_features - show a list of optional features when building"
281 # -----------------------------------------------------------------------------
284 package_debian: .FORCE
285 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
287 package_pacman: .FORCE
288 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
290 package_archive: .FORCE
291 make -C "$(BUILD_DIR)" -s package_archive
292 @echo archive in "$(BUILD_DIR)/release"
295 # -----------------------------------------------------------------------------
299 cd $(BUILD_DIR) ; ctest . --output-on-failure
301 # run pep8 check check on scripts we distribute.
303 $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
304 @echo "written: test_pep8.log"
306 # run some checks on our cmakefiles.
308 $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
309 @echo "written: test_cmake_consistency.log"
311 # run deprecation tests, see if we have anything to remove.
312 test_deprecated: .FORCE
313 $(PYTHON) tests/check_deprecated.py
316 # run our own checks on C/C++ style
317 PYTHONIOENCODING=utf_8 $(PYTHON) \
318 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
319 "$(BLENDER_DIR)/source/blender" \
320 "$(BLENDER_DIR)/source/creator" \
323 test_style_c_qtc: .FORCE
324 # run our own checks on C/C++ style
326 PYTHONIOENCODING=utf_8 $(PYTHON) \
327 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
328 "$(BLENDER_DIR)/source/blender" \
329 "$(BLENDER_DIR)/source/creator" \
332 "$(BLENDER_DIR)/test_style.tasks"
333 @echo "written: test_style.tasks"
336 test_style_osl: .FORCE
337 # run our own checks on C/C++ style
338 PYTHONIOENCODING=utf_8 $(PYTHON) \
339 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
340 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
341 "$(BLENDER_DIR)/release/scripts/templates_osl"
344 test_style_osl_qtc: .FORCE
345 # run our own checks on C/C++ style
347 PYTHONIOENCODING=utf_8 $(PYTHON) \
348 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
349 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
350 "$(BLENDER_DIR)/release/scripts/templates_osl" \
352 "$(BLENDER_DIR)/test_style.tasks"
353 @echo "written: test_style.tasks"
355 # -----------------------------------------------------------------------------
359 project_qtcreator: .FORCE
360 $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
362 project_netbeans: .FORCE
363 $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
365 project_eclipse: .FORCE
366 cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
369 # -----------------------------------------------------------------------------
373 check_cppcheck: .FORCE
375 cd "$(BUILD_DIR)" ; \
376 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
377 "$(BLENDER_DIR)/check_cppcheck.txt"
378 @echo "written: check_cppcheck.txt"
380 check_clang_array: .FORCE
382 cd "$(BUILD_DIR)" ; \
383 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
387 cd "$(BUILD_DIR)" ; \
388 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
392 cd "$(BUILD_DIR)" ; \
393 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
397 cd "$(BUILD_DIR)" ; \
398 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
400 check_spelling_py: .FORCE
401 cd "$(BUILD_DIR)" ; \
402 PYTHONIOENCODING=utf_8 $(PYTHON) \
403 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
404 "$(BLENDER_DIR)/release/scripts"
406 check_spelling_c: .FORCE
407 cd "$(BUILD_DIR)" ; \
408 PYTHONIOENCODING=utf_8 $(PYTHON) \
409 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
410 "$(BLENDER_DIR)/source" \
411 "$(BLENDER_DIR)/intern/cycles" \
412 "$(BLENDER_DIR)/intern/guardedalloc" \
413 "$(BLENDER_DIR)/intern/ghost" \
415 check_spelling_c_qtc: .FORCE
416 cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
417 PYTHONIOENCODING=utf_8 $(PYTHON) \
418 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
419 "$(BLENDER_DIR)/source" \
420 "$(BLENDER_DIR)/intern/cycles" \
421 "$(BLENDER_DIR)/intern/guardedalloc" \
422 "$(BLENDER_DIR)/intern/ghost" \
424 "$(BLENDER_DIR)/check_spelling_c.tasks"
426 check_spelling_osl: .FORCE
428 PYTHONIOENCODING=utf_8 $(PYTHON) \
429 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
430 "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
432 check_descriptions: .FORCE
433 $(BLENDER_BIN) --background -noaudio --factory-startup --python \
434 "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
436 # -----------------------------------------------------------------------------
441 ./build_files/utils/build_tgz.sh
444 "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
445 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
448 BLENDER_BIN=$(BLENDER_BIN) \
449 "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
452 if [ "$(OS_NCASE)" = "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
453 svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
455 if [ -d "../lib" ]; then \
456 svn cleanup ../lib/* ; \
457 svn update ../lib/* ; \
460 git submodule update --init --recursive
461 git submodule foreach git checkout master
462 git submodule foreach git pull --rebase origin master
465 # -----------------------------------------------------------------------------
469 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
471 ASAN_OPTIONS=halt_on_error=0 \
472 $(BLENDER_BIN) --background -noaudio --factory-startup \
473 --python doc/python_api/sphinx_doc_gen.py
474 cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
475 @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'"
478 cd doc/doxygen; doxygen Doxyfile
479 @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
482 $(BLENDER_BIN) --background -noaudio --factory-startup \
483 --python doc/blender_file_format/BlendFileDnaExporter_25.py
484 @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
487 $(PYTHON) doc/manpage/blender.1.py $(BLENDER_BIN) blender.1
489 help_features: .FORCE
490 @$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt"
493 $(MAKE) -C "$(BUILD_DIR)" clean