Fix Pose Lib: pose is applied when selected bones don't overlap with pose
[blender-staging.git] / GNUmakefile
1 # -*- mode: gnumakefile; tab-width: 4; indent-tabs-mode: t; -*-
2 # vim: tabstop=4
3 #
4 # ##### BEGIN GPL LICENSE BLOCK #####
5 #
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.
10 #
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.
15 #
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.
19 #
20 # ##### END GPL LICENSE BLOCK #####
21
22 # This Makefile does an out-of-source CMake build in ../build_`OS`_`CPU`
23 # eg:
24 #   ../build_linux_i386
25 # This is for users who like to configure & build blender with a single command.
26
27
28 # System Vars
29 OS:=$(shell uname -s)
30 OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
31 # CPU:=$(shell uname -m)  # UNUSED
32
33
34 # Source and Build DIR's
35 BLENDER_DIR:=$(shell pwd -P)
36 BUILD_TYPE:=Release
37
38 ifndef BUILD_CMAKE_ARGS
39         BUILD_CMAKE_ARGS:=
40 endif
41
42 ifndef BUILD_DIR
43         BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
44 endif
45
46 # Dependencies DIR's
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)
50
51 ifneq ($(OS_NCASE),darwin)
52         # Add processor type to directory name
53         DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(shell uname -p)
54 endif
55
56 # Allow to use alternative binary (pypy3, etc)
57 ifndef PYTHON
58         PYTHON:=python3
59 endif
60
61
62 # -----------------------------------------------------------------------------
63 # additional targets for the build configuration
64
65 # support 'make debug'
66 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
67         BUILD_DIR:=$(BUILD_DIR)_debug
68         BUILD_TYPE:=Debug
69 endif
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"
73 endif
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"
77 endif
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"
81 endif
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"
85 endif
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"
89 endif
90
91
92 # -----------------------------------------------------------------------------
93 # Get the number of cores for threaded build
94 ifndef NPROCS
95         NPROCS:=1
96         ifeq ($(OS), Linux)
97                 NPROCS:=$(shell nproc)
98         endif
99         ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
100                 NPROCS:=$(shell sysctl -n hw.ncpu)
101         endif
102 endif
103
104
105 # -----------------------------------------------------------------------------
106 # Macro for configuring cmake
107
108 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
109                      -H"$(BLENDER_DIR)" \
110                      -B"$(BUILD_DIR)" \
111                      -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
112
113
114 # -----------------------------------------------------------------------------
115 # Tool for 'make config'
116
117 # X11 spesific
118 ifdef DISPLAY
119         CMAKE_CONFIG_TOOL = cmake-gui
120 else
121         CMAKE_CONFIG_TOOL = ccmake
122 endif
123
124
125 # -----------------------------------------------------------------------------
126 # Build Blender
127 all: .FORCE
128         @echo
129         @echo Configuring Blender in \"$(BUILD_DIR)\" ...
130
131 #       # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
132 #       #       $(CMAKE_CONFIG); \
133 #       # fi
134
135 #       # do this always incase of failed initial build, could be smarter here...
136         @$(CMAKE_CONFIG)
137
138         @echo
139         @echo Building Blender ...
140         $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
141         @echo
142         @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
143         @echo Blender successfully built, run from: "$(BUILD_DIR)/bin/blender"
144         @echo
145
146 debug: all
147 full: all
148 lite: all
149 cycles: all
150 headless: all
151 bpy: all
152
153 # -----------------------------------------------------------------------------
154 # Build dependencies
155 DEPS_TARGET = install
156 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
157         DEPS_TARGET = clean
158 endif
159
160 deps: .FORCE
161         @echo
162         @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
163
164         @cmake -H"$(DEPS_SOURCE_DIR)" \
165                -B"$(DEPS_BUILD_DIR)" \
166                    -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
167
168         @echo
169         @echo Building dependencies ...
170         $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
171         @echo
172         @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
173         @echo
174
175 # -----------------------------------------------------------------------------
176 # Configuration (save some cd'ing around)
177 config: .FORCE
178         $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
179
180
181 # -----------------------------------------------------------------------------
182 # Help for build targets
183 help: .FORCE
184         @echo ""
185         @echo "Convenience targets provided for building blender, (multiple at once can be used)"
186         @echo "  * debug     - build a debug binary"
187         @echo "  * full      - enable all supported dependencies & options"
188         @echo "  * lite      - disable non essential features for a smaller binary and faster build"
189         @echo "  * headless  - build without an interface (renderfarm or server automation)"
190         @echo "  * cycles    - build Cycles standalone only, without Blender"
191         @echo "  * bpy       - build as a python module which can be loaded from python directly"
192         @echo "  * deps      - build library dependencies (intended only for platform maintainers)"
193         @echo ""
194         @echo "  * config    - run cmake configuration tool to set build options"
195         @echo ""
196         @echo "  Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
197         @echo "  Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
198         @echo ""
199         @echo ""
200         @echo "Project Files for IDE's"
201         @echo "  * project_qtcreator - QtCreator Project Files"
202         @echo "  * project_netbeans  - NetBeans Project Files"
203         @echo "  * project_eclipse   - Eclipse CDT4 Project Files"
204         @echo ""
205         @echo "Package Targets"
206         @echo "  * package_debian  - build a debian package"
207         @echo "  * package_pacman  - build an arch linux pacman package"
208         @echo "  * package_archive - build an archive package"
209         @echo ""
210         @echo "Testing Targets (not associated with building blender)"
211         @echo "  * test               - run ctest, currently tests import/export,"
212         @echo "                         operator execution and that python modules load"
213         @echo "  * test_cmake         - runs our own cmake file checker"
214         @echo "                         which detects errors in the cmake file list definitions"
215         @echo "  * test_pep8          - checks all python script are pep8"
216         @echo "                         which are tagged to use the stricter formatting"
217         @echo "  * test_deprecated    - checks for deprecation tags in our code which may need to be removed"
218         @echo "  * test_style_c       - checks C/C++ conforms with blenders style guide:"
219         @echo "                         http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
220         @echo "  * test_style_c_qtc   - same as test_style but outputs QtCreator tasks format"
221         @echo "  * test_style_osl     - checks OpenShadingLanguage conforms with blenders style guide:"
222         @echo "                         http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
223         @echo "  * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide:"
224         @echo "                         http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
225         @echo ""
226         @echo "Static Source Code Checking (not associated with building blender)"
227         @echo "  * check_cppcheck       - run blender source through cppcheck (C & C++)"
228         @echo "  * check_clang_array    - run blender source through clang array checking script (C & C++)"
229         @echo "  * check_splint         - run blenders source through splint (C only)"
230         @echo "  * check_sparse         - run blenders source through sparse (C only)"
231         @echo "  * check_smatch         - run blenders source through smatch (C only)"
232         @echo "  * check_spelling_c     - check for spelling errors (C/C++ only)"
233         @echo "  * check_spelling_c_qtc - same as check_spelling_c but outputs QtCreator tasks format"
234         @echo "  * check_spelling_osl   - check for spelling errors (OSL only)"
235         @echo "  * check_spelling_py    - check for spelling errors (Python only)"
236         @echo "  * check_descriptions   - check for duplicate/invalid descriptions"
237         @echo ""
238         @echo "Utilities (not associated with building blender)"
239         @echo "  * icons    - updates PNG icons from SVG files."
240         @echo "  * tgz      - create a compressed archive of the source code."
241         @echo "  * update   - updates git and all submodules"
242         @echo ""
243         @echo "Environment Variables"
244         @echo "  * BUILD_CMAKE_ARGS    - arguments passed to CMake."
245         @echo "  * BUILD_DIR           - override default build path."
246         @echo "  * PYTHON              - use this for the Python command (used for checking tools)."
247         @echo "  * NPROCS              - number of processes to use building (auto-detect when omitted)."
248         @echo ""
249         @echo "Documentation Targets (not associated with building blender)"
250         @echo "  * doc_py   - generate sphinx python api docs"
251         @echo "  * doc_doxy - generate doxygen C/C++ docs"
252         @echo "  * doc_dna  - generate blender file format reference"
253         @echo "  * doc_man  - generate manpage"
254         @echo ""
255         @echo "Information"
256         @echo "  * help          - this help message"
257         @echo "  * help_features - show a list of optional features when building"
258         @echo ""
259
260 # -----------------------------------------------------------------------------
261 # Packages
262 #
263 package_debian: .FORCE
264         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
265
266 package_pacman: .FORCE
267         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
268
269 package_archive: .FORCE
270         make -C "$(BUILD_DIR)" -s package_archive
271         @echo archive in "$(BUILD_DIR)/release"
272
273
274 # -----------------------------------------------------------------------------
275 # Tests
276 #
277 test: .FORCE
278         cd $(BUILD_DIR) ; ctest . --output-on-failure
279
280 # run pep8 check check on scripts we distribute.
281 test_pep8: .FORCE
282         $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
283         @echo "written: test_pep8.log"
284
285 # run some checks on our cmakefiles.
286 test_cmake: .FORCE
287         $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
288         @echo "written: test_cmake_consistency.log"
289
290 # run deprecation tests, see if we have anything to remove.
291 test_deprecated: .FORCE
292         $(PYTHON) tests/check_deprecated.py
293
294 test_style_c: .FORCE
295         # run our own checks on C/C++ style
296         PYTHONIOENCODING=utf_8 $(PYTHON) \
297             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
298             "$(BLENDER_DIR)/source/blender" \
299             "$(BLENDER_DIR)/source/creator" \
300             --no-length-check
301
302 test_style_c_qtc: .FORCE
303         # run our own checks on C/C++ style
304         USE_QTC_TASK=1 \
305         PYTHONIOENCODING=utf_8 $(PYTHON) \
306             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
307             "$(BLENDER_DIR)/source/blender" \
308             "$(BLENDER_DIR)/source/creator" \
309             --no-length-check \
310             > \
311             "$(BLENDER_DIR)/test_style.tasks"
312         @echo "written: test_style.tasks"
313
314
315 test_style_osl: .FORCE
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)/intern/cycles/kernel/shaders" \
320             "$(BLENDER_DIR)/release/scripts/templates_osl"
321
322
323 test_style_osl_qtc: .FORCE
324         # run our own checks on C/C++ style
325         USE_QTC_TASK=1 \
326         PYTHONIOENCODING=utf_8 $(PYTHON) \
327             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
328             "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
329             "$(BLENDER_DIR)/release/scripts/templates_osl" \
330             > \
331             "$(BLENDER_DIR)/test_style.tasks"
332         @echo "written: test_style.tasks"
333
334 # -----------------------------------------------------------------------------
335 # Project Files
336 #
337
338 project_qtcreator: .FORCE
339         $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
340
341 project_netbeans: .FORCE
342         $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
343
344 project_eclipse: .FORCE
345         cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
346
347
348 # -----------------------------------------------------------------------------
349 # Static Checking
350 #
351
352 check_cppcheck: .FORCE
353         $(CMAKE_CONFIG)
354         cd "$(BUILD_DIR)" ; \
355         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
356             "$(BLENDER_DIR)/check_cppcheck.txt"
357         @echo "written: check_cppcheck.txt"
358
359 check_clang_array: .FORCE
360         $(CMAKE_CONFIG)
361         cd "$(BUILD_DIR)" ; \
362         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
363
364 check_splint: .FORCE
365         $(CMAKE_CONFIG)
366         cd "$(BUILD_DIR)" ; \
367         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
368
369 check_sparse: .FORCE
370         $(CMAKE_CONFIG)
371         cd "$(BUILD_DIR)" ; \
372         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
373
374 check_smatch: .FORCE
375         $(CMAKE_CONFIG)
376         cd "$(BUILD_DIR)" ; \
377         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
378
379 check_spelling_py: .FORCE
380         cd "$(BUILD_DIR)" ; \
381         PYTHONIOENCODING=utf_8 $(PYTHON) \
382             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
383             "$(BLENDER_DIR)/release/scripts"
384
385 check_spelling_c: .FORCE
386         cd "$(BUILD_DIR)" ; \
387         PYTHONIOENCODING=utf_8 $(PYTHON) \
388             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
389             "$(BLENDER_DIR)/source" \
390             "$(BLENDER_DIR)/intern/cycles" \
391             "$(BLENDER_DIR)/intern/guardedalloc" \
392             "$(BLENDER_DIR)/intern/ghost" \
393
394 check_spelling_c_qtc: .FORCE
395         cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
396         PYTHONIOENCODING=utf_8 $(PYTHON) \
397             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
398             "$(BLENDER_DIR)/source" \
399             "$(BLENDER_DIR)/intern/cycles" \
400             "$(BLENDER_DIR)/intern/guardedalloc" \
401             "$(BLENDER_DIR)/intern/ghost" \
402             > \
403             "$(BLENDER_DIR)/check_spelling_c.tasks"
404
405 check_spelling_osl: .FORCE
406         cd "$(BUILD_DIR)" ;\
407         PYTHONIOENCODING=utf_8 $(PYTHON) \
408             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
409             "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
410
411 check_descriptions: .FORCE
412         "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python \
413             "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
414
415 # -----------------------------------------------------------------------------
416 # Utilities
417 #
418
419 tgz: .FORCE
420         ./build_files/utils/build_tgz.sh
421
422 icons: .FORCE
423         "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
424         "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
425
426 update: .FORCE
427         if [ "$(OS_NCASE)" == "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
428                 svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
429         fi
430         if [ -d "../lib" ]; then \
431                 svn cleanup ../lib/* ; \
432                 svn update ../lib/* ; \
433         fi
434         git pull --rebase
435         git submodule update --init --recursive
436         git submodule foreach git checkout master
437         git submodule foreach git pull --rebase origin master
438
439
440 # -----------------------------------------------------------------------------
441 # Documentation
442 #
443
444 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
445 doc_py: .FORCE
446         "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup \
447                 --python doc/python_api/sphinx_doc_gen.py
448         cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
449         @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
450
451 doc_doxy: .FORCE
452         cd doc/doxygen; doxygen Doxyfile
453         @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
454
455 doc_dna: .FORCE
456         "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup \
457                 --python doc/blender_file_format/BlendFileDnaExporter_25.py
458         @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
459
460 doc_man: .FORCE
461         $(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
462
463 help_features: .FORCE
464         @$(PYTHON) -c \
465                 "import re; \
466                 print('\n'.join([ \
467                 w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
468                 if not l.lstrip().startswith('#') \
469                 for w in (re.sub(\
470                     r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\".*\")\s*.*', r'\g<1> - \g<2>', l).strip('() \n'),) \
471                 if w.startswith('WITH_')]))" | uniq
472
473
474 clean: .FORCE
475         $(MAKE) -C "$(BUILD_DIR)" clean
476
477 .PHONY: all
478
479 .FORCE: