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)
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,"
186 @echo " operator execution and that python modules load"
187 @echo " * test_cmake - runs our own cmake file checker"
188 @echo " which detects errors in the cmake file list definitions"
189 @echo " * test_pep8 - checks all python script are pep8"
190 @echo " which are tagged to use the stricter formatting"
191 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
192 @echo " * test_style_c - checks C/C++ conforms with blenders style guide:"
193 @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
194 @echo " * test_style_c_qtc - same as test_style but outputs QtCreator tasks format"
195 @echo " * test_style_osl - checks OpenShadingLanguage conforms with blenders style guide:"
196 @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
197 @echo " * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide:"
198 @echo " http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
200 @echo "Static Source Code Checking (not associated with building blender)"
201 @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
202 @echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
203 @echo " * check_splint - run blenders source through splint (C only)"
204 @echo " * check_sparse - run blenders source through sparse (C only)"
205 @echo " * check_smatch - run blenders source through smatch (C only)"
206 @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
207 @echo " * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
208 @echo " * check_spelling_osl - check for spelling errors (OSL only)"
209 @echo " * check_spelling_py - check for spelling errors (Python only)"
210 @echo " * check_descriptions - check for duplicate/invalid descriptions"
212 @echo "Utilities (not associated with building blender)"
213 @echo " * icons - updates PNG icons from SVG files."
214 @echo " * tgz - create a compressed archive of the source code."
215 @echo " * update - updates git and all submodules"
217 @echo "Environment Variables"
218 @echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
219 @echo " * BUILD_DIR - override default build path."
220 @echo " * PYTHON - use this for the Python command (used for checking tools)."
221 @echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
223 @echo "Documentation Targets (not associated with building blender)"
224 @echo " * doc_py - generate sphinx python api docs"
225 @echo " * doc_doxy - generate doxygen C/C++ docs"
226 @echo " * doc_dna - generate blender file format reference"
227 @echo " * doc_man - generate manpage"
230 @echo " * help - this help message"
231 @echo " * help_features - show a list of optional features when building"
234 # -----------------------------------------------------------------------------
237 package_debian: .FORCE
238 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
240 package_pacman: .FORCE
241 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
243 package_archive: .FORCE
244 make -C "$(BUILD_DIR)" -s package_archive
245 @echo archive in "$(BUILD_DIR)/release"
248 # -----------------------------------------------------------------------------
252 cd $(BUILD_DIR) ; ctest . --output-on-failure
254 # run pep8 check check on scripts we distribute.
256 $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
257 @echo "written: test_pep8.log"
259 # run some checks on our cmakefiles.
261 $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
262 @echo "written: test_cmake_consistency.log"
264 # run deprecation tests, see if we have anything to remove.
265 test_deprecated: .FORCE
266 $(PYTHON) tests/check_deprecated.py
269 # run our own checks on C/C++ style
270 PYTHONIOENCODING=utf_8 $(PYTHON) \
271 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
272 "$(BLENDER_DIR)/source/blender" \
273 "$(BLENDER_DIR)/source/creator" \
276 test_style_c_qtc: .FORCE
277 # run our own checks on C/C++ style
279 PYTHONIOENCODING=utf_8 $(PYTHON) \
280 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
281 "$(BLENDER_DIR)/source/blender" \
282 "$(BLENDER_DIR)/source/creator" \
285 "$(BLENDER_DIR)/test_style.tasks"
286 @echo "written: test_style.tasks"
289 test_style_osl: .FORCE
290 # run our own checks on C/C++ style
291 PYTHONIOENCODING=utf_8 $(PYTHON) \
292 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
293 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
294 "$(BLENDER_DIR)/release/scripts/templates_osl"
297 test_style_osl_qtc: .FORCE
298 # run our own checks on C/C++ style
300 PYTHONIOENCODING=utf_8 $(PYTHON) \
301 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
302 "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
303 "$(BLENDER_DIR)/release/scripts/templates_osl" \
305 "$(BLENDER_DIR)/test_style.tasks"
306 @echo "written: test_style.tasks"
308 # -----------------------------------------------------------------------------
312 project_qtcreator: .FORCE
313 $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
315 project_netbeans: .FORCE
316 $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
318 project_eclipse: .FORCE
319 cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
322 # -----------------------------------------------------------------------------
326 check_cppcheck: .FORCE
328 cd "$(BUILD_DIR)" ; \
329 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
330 "$(BLENDER_DIR)/check_cppcheck.txt"
331 @echo "written: check_cppcheck.txt"
333 check_clang_array: .FORCE
335 cd "$(BUILD_DIR)" ; \
336 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
340 cd "$(BUILD_DIR)" ; \
341 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
345 cd "$(BUILD_DIR)" ; \
346 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
350 cd "$(BUILD_DIR)" ; \
351 $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
353 check_spelling_py: .FORCE
354 cd "$(BUILD_DIR)" ; \
355 PYTHONIOENCODING=utf_8 $(PYTHON) \
356 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
357 "$(BLENDER_DIR)/release/scripts"
359 check_spelling_c: .FORCE
360 cd "$(BUILD_DIR)" ; \
361 PYTHONIOENCODING=utf_8 $(PYTHON) \
362 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
363 "$(BLENDER_DIR)/source" \
364 "$(BLENDER_DIR)/intern/cycles" \
365 "$(BLENDER_DIR)/intern/guardedalloc" \
366 "$(BLENDER_DIR)/intern/ghost" \
368 check_spelling_c_qtc: .FORCE
369 cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
370 PYTHONIOENCODING=utf_8 $(PYTHON) \
371 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
372 "$(BLENDER_DIR)/source" \
373 "$(BLENDER_DIR)/intern/cycles" \
374 "$(BLENDER_DIR)/intern/guardedalloc" \
375 "$(BLENDER_DIR)/intern/ghost" \
377 "$(BLENDER_DIR)/check_spelling_c.tasks"
379 check_spelling_osl: .FORCE
381 PYTHONIOENCODING=utf_8 $(PYTHON) \
382 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
383 "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
385 check_descriptions: .FORCE
386 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python \
387 "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
389 # -----------------------------------------------------------------------------
394 ./build_files/utils/build_tgz.sh
397 "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
398 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
401 if [ -d "../lib" ]; then \
402 svn update ../lib/* ; \
405 git submodule foreach git pull --rebase origin master
408 # -----------------------------------------------------------------------------
412 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
414 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup \
415 --python doc/python_api/sphinx_doc_gen.py
416 cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
417 @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
420 cd doc/doxygen; doxygen Doxyfile
421 @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
424 "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup \
425 --python doc/blender_file_format/BlendFileDnaExporter_25.py
426 @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
429 $(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
431 help_features: .FORCE
435 w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
436 if not l.lstrip().startswith('#') \
438 r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\".*\")\s*.*', r'\g<1> - \g<2>', l).strip('() \n'),) \
439 if w.startswith('WITH_')]))" | uniq
443 $(MAKE) -C "$(BUILD_DIR)" clean