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
48 DEPS_BUILD_DIR:=$(BUILD_DIR)/deps
49 DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
51 ifneq ($(OS_NCASE),darwin)
52 # Add processor type to directory name
53 DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(shell uname -p)
56 # Allow to use alternative binary (pypy3, etc)
62 # -----------------------------------------------------------------------------
63 # additional targets for the build configuration
65 # support 'make debug'
66 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
67 BUILD_DIR:=$(BUILD_DIR)_debug
70 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
71 BUILD_DIR:=$(BUILD_DIR)_full
72 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
74 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
75 BUILD_DIR:=$(BUILD_DIR)_lite
76 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
78 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
79 BUILD_DIR:=$(BUILD_DIR)_cycles
80 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
82 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
83 BUILD_DIR:=$(BUILD_DIR)_headless
84 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
86 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
87 BUILD_DIR:=$(BUILD_DIR)_bpy
88 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
92 # -----------------------------------------------------------------------------
96 BLENDER_BIN="$(BUILD_DIR)/bin/blender.app/Contents/MacOS/blender"
98 BLENDER_BIN="$(BUILD_DIR)/bin/blender"
102 # -----------------------------------------------------------------------------
103 # Get the number of cores for threaded build
107 NPROCS:=$(shell nproc)
109 ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
110 NPROCS:=$(shell sysctl -n hw.ncpu)
115 # -----------------------------------------------------------------------------
116 # Macro for configuring cmake
118 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
121 -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
124 # -----------------------------------------------------------------------------
125 # Tool for 'make config'
129 CMAKE_CONFIG_TOOL = cmake-gui
131 CMAKE_CONFIG_TOOL = ccmake
135 # -----------------------------------------------------------------------------
139 @echo Configuring Blender in \"$(BUILD_DIR)\" ...
141 # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
142 # # $(CMAKE_CONFIG); \
145 # # do this always incase of failed initial build, could be smarter here...
149 @echo Building Blender ...
150 $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
152 @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
153 @echo Blender successfully built, run from: $(BLENDER_BIN)
163 # -----------------------------------------------------------------------------
165 DEPS_TARGET = install
166 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
172 @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
174 @cmake -H"$(DEPS_SOURCE_DIR)" \
175 -B"$(DEPS_BUILD_DIR)" \
176 -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
179 @echo Building dependencies ...
180 $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
182 @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
185 # -----------------------------------------------------------------------------
186 # Configuration (save some cd'ing around)
188 $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
191 # -----------------------------------------------------------------------------
192 # Help for build targets
195 @echo "Convenience targets provided for building blender, (multiple at once can be used)"
196 @echo " * debug - build a debug binary"
197 @echo " * full - enable all supported dependencies & options"
198 @echo " * lite - disable non essential features for a smaller binary and faster build"
199 @echo " * headless - build without an interface (renderfarm or server automation)"
200 @echo " * cycles - build Cycles standalone only, without Blender"
201 @echo " * bpy - build as a python module which can be loaded from python directly"
202 @echo " * deps - build library dependencies (intended only for platform maintainers)"
204 @echo " * config - run cmake configuration tool to set build options"
206 @echo " Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
207 @echo " Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
210 @echo "Project Files for IDE's"
211 @echo " * project_qtcreator - QtCreator Project Files"
212 @echo " * project_netbeans - NetBeans Project Files"
213 @echo " * project_eclipse - Eclipse CDT4 Project Files"
215 @echo "Package Targets"
216 @echo " * package_debian - build a debian package"
217 @echo " * package_pacman - build an arch linux pacman package"
218 @echo " * package_archive - build an archive package"
220 @echo "Testing Targets (not associated with building blender)"
221 @echo " * test - run ctest, currently tests import/export,"
222 @echo " operator execution and that python modules load"
223 @echo " * test_cmake - runs our own cmake file checker"
224 @echo " which detects errors in the cmake file list definitions"
225 @echo " * test_pep8 - checks all python script are pep8"
226 @echo " which are tagged to use the stricter formatting"
227 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
228 @echo " * test_style_c - checks C/C++ conforms with blenders style guide:"
229 @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
230 @echo " * test_style_c_qtc - same as test_style but outputs QtCreator tasks format"
231 @echo " * test_style_osl - checks OpenShadingLanguage conforms with blenders style guide:"
232 @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
233 @echo " * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide:"
234 @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
236 @echo "Static Source Code Checking (not associated with building blender)"
237 @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
238 @echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
239 @echo " * check_splint - run blenders source through splint (C only)"
240 @echo " * check_sparse - run blenders source through sparse (C only)"
241 @echo " * check_smatch - run blenders source through smatch (C only)"
242 @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
243 @echo " * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
244 @echo " * check_spelling_osl - check for spelling errors (OSL only)"
245 @echo " * check_spelling_py - check for spelling errors (Python only)"
246 @echo " * check_descriptions - check for duplicate/invalid descriptions"
248 @echo "Utilities (not associated with building blender)"
249 @echo " * icons - Updates PNG icons from SVG files."
250 @echo " Set environment variables 'BLENDER_BIN' and 'INKSCAPE_BIN'"
251 @echo " to define your own commands."
252 @echo " * tgz - create a compressed archive of the source code."
253 @echo " * update - updates git and all submodules"
255 @echo "Environment Variables"
256 @echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
257 @echo " * BUILD_DIR - override default build path."
258 @echo " * PYTHON - use this for the Python command (used for checking tools)."
259 @echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
261 @echo "Documentation Targets (not associated with building blender)"
262 @echo " * doc_py - generate sphinx python api docs"
263 @echo " * doc_doxy - generate doxygen C/C++ docs"
264 @echo " * doc_dna - generate blender file format reference"
265 @echo " * doc_man - generate manpage"
268 @echo " * help - this help message"
269 @echo " * help_features - show a list of optional features when building"
272 # -----------------------------------------------------------------------------
275 package_debian: .FORCE
276 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
278 package_pacman: .FORCE
279 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
281 package_archive: .FORCE
282 make -C "$(BUILD_DIR)" -s package_archive
283 @echo archive in "$(BUILD_DIR)/release"
286 # -----------------------------------------------------------------------------
290 cd $(BUILD_DIR) ; ctest . --output-on-failure
292 # run pep8 check check on scripts we distribute.
294 $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
295 @echo "written: test_pep8.log"
297 # run some checks on our cmakefiles.
299 $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
300 @echo "written: test_cmake_consistency.log"
302 # run deprecation tests, see if we have anything to remove.
303 test_deprecated: .FORCE
304 $(PYTHON) tests/check_deprecated.py
307 # run our own checks on C/C++ style
308 PYTHONIOENCODING=utf_8 $(PYTHON) \
309 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
310 "$(BLENDER_DIR)/source/blender" \
311 "$(BLENDER_DIR)/source/creator" \
314 test_style_c_qtc: .FORCE
315 # 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 "$(BLENDER_DIR)/test_style.tasks"
324 @echo "written: test_style.tasks"
327 test_style_osl: .FORCE
328 # run our own checks on C/C++ style
329 PYTHONIOENCODING=utf_8 $(PYTHON) \
330 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
331 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
332 "$(BLENDER_DIR)/release/scripts/templates_osl"
335 test_style_osl_qtc: .FORCE
336 # 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" \
343 "$(BLENDER_DIR)/test_style.tasks"
344 @echo "written: test_style.tasks"
346 # -----------------------------------------------------------------------------
350 project_qtcreator: .FORCE
351 $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
353 project_netbeans: .FORCE
354 $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
356 project_eclipse: .FORCE
357 cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
360 # -----------------------------------------------------------------------------
364 check_cppcheck: .FORCE
366 cd "$(BUILD_DIR)" ; \
367 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
368 "$(BLENDER_DIR)/check_cppcheck.txt"
369 @echo "written: check_cppcheck.txt"
371 check_clang_array: .FORCE
373 cd "$(BUILD_DIR)" ; \
374 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
378 cd "$(BUILD_DIR)" ; \
379 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
383 cd "$(BUILD_DIR)" ; \
384 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
388 cd "$(BUILD_DIR)" ; \
389 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
391 check_spelling_py: .FORCE
392 cd "$(BUILD_DIR)" ; \
393 PYTHONIOENCODING=utf_8 $(PYTHON) \
394 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
395 "$(BLENDER_DIR)/release/scripts"
397 check_spelling_c: .FORCE
398 cd "$(BUILD_DIR)" ; \
399 PYTHONIOENCODING=utf_8 $(PYTHON) \
400 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
401 "$(BLENDER_DIR)/source" \
402 "$(BLENDER_DIR)/intern/cycles" \
403 "$(BLENDER_DIR)/intern/guardedalloc" \
404 "$(BLENDER_DIR)/intern/ghost" \
406 check_spelling_c_qtc: .FORCE
407 cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
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 "$(BLENDER_DIR)/check_spelling_c.tasks"
417 check_spelling_osl: .FORCE
419 PYTHONIOENCODING=utf_8 $(PYTHON) \
420 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
421 "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
423 check_descriptions: .FORCE
424 $(BLENDER_BIN) --background -noaudio --factory-startup --python \
425 "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
427 # -----------------------------------------------------------------------------
432 ./build_files/utils/build_tgz.sh
435 "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
436 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
439 if [ "$(OS_NCASE)" = "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
440 svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
442 if [ -d "../lib" ]; then \
443 svn cleanup ../lib/* ; \
444 svn update ../lib/* ; \
447 git submodule update --init --recursive
448 # Use blender2.7 branch for submodules that have it.
449 git submodule foreach "git checkout blender2.7 || git checkout master"
450 git submodule foreach git pull --rebase origin
453 # -----------------------------------------------------------------------------
457 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
459 ASAN_OPTIONS=halt_on_error=0 \
460 $(BLENDER_BIN) --background -noaudio --factory-startup \
461 --python doc/python_api/sphinx_doc_gen.py
462 cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
463 @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
466 cd doc/doxygen; doxygen Doxyfile
467 @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
470 $(BLENDER_BIN) --background -noaudio --factory-startup \
471 --python doc/blender_file_format/BlendFileDnaExporter_25.py
472 @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
475 $(PYTHON) doc/manpage/blender.1.py $(BLENDER_BIN) blender.1
477 help_features: .FORCE
478 @$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt"
481 $(MAKE) -C "$(BUILD_DIR)" clean