Depsgraph: Report proper error when modifier fails to create relation link
[blender.git] / GNUmakefile
1 # -*- mode: gnumakefile; tab-width: 8; 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 # Allow to use alternative binary (pypy3, etc)
47 ifndef PYTHON
48         PYTHON:=python3
49 endif
50
51
52 # -----------------------------------------------------------------------------
53 # additional targets for the build configuration
54
55 # support 'make debug'
56 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
57         BUILD_DIR:=$(BUILD_DIR)_debug
58         BUILD_TYPE:=Debug
59 endif
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"
63 endif
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"
67 endif
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"
71 endif
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"
75 endif
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"
79 endif
80
81
82 # -----------------------------------------------------------------------------
83 # Get the number of cores for threaded build
84 ifndef NPROCS
85         NPROCS:=1
86         ifeq ($(OS), Linux)
87                 NPROCS:=$(shell nproc)
88         endif
89         ifeq ($(OS), Darwin)
90                 NPROCS:=$(shell sysctl -n hw.ncpu)
91         endif
92         ifeq ($(OS), FreeBSD)
93                 NPROCS:=$(shell sysctl -n hw.ncpu)
94         endif
95         ifeq ($(OS), NetBSD)
96                 NPROCS:=$(shell sysctl -n hw.ncpu)
97         endif
98 endif
99
100
101 # -----------------------------------------------------------------------------
102 # Macro for configuring cmake
103
104 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
105                      -H"$(BLENDER_DIR)" \
106                      -B"$(BUILD_DIR)" \
107                      -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
108
109
110 # -----------------------------------------------------------------------------
111 # Tool for 'make config'
112
113 # X11 spesific
114 ifdef DISPLAY
115         CMAKE_CONFIG_TOOL = cmake-gui
116 else 
117         CMAKE_CONFIG_TOOL = ccmake
118 endif
119
120
121 # -----------------------------------------------------------------------------
122 # Build Blender
123 all: .FORCE
124         @echo
125         @echo Configuring Blender in \"$(BUILD_DIR)\" ...
126
127 #       # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
128 #       #       $(CMAKE_CONFIG); \
129 #       # fi
130         
131 #       # do this always incase of failed initial build, could be smarter here...
132         @$(CMAKE_CONFIG)
133
134         @echo
135         @echo Building Blender ...
136         $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
137         @echo
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"
140         @echo
141
142 debug: all
143 full: all
144 lite: all
145 cycles: all
146 headless: all
147 bpy: all
148
149
150 # -----------------------------------------------------------------------------
151 # Configuration (save some cd'ing around)
152 config: .FORCE
153         $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
154
155
156 # -----------------------------------------------------------------------------
157 # Help for build targets
158 help: .FORCE
159         @echo ""
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"
167         @echo ""
168         @echo "  * config    - run cmake configuration tool to set build options"
169         @echo ""
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."
172         @echo ""
173         @echo ""
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"
178         @echo ""
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"
183         @echo ""
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"
199         @echo ""
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"
211         @echo ""
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"
216         @echo ""
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)."
222         @echo ""
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"
228         @echo ""
229         @echo "Information"
230         @echo "  * help          - this help message"
231         @echo "  * help_features - show a list of optional features when building"
232         @echo ""
233
234 # -----------------------------------------------------------------------------
235 # Packages
236 #
237 package_debian: .FORCE
238         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
239
240 package_pacman: .FORCE
241         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
242
243 package_archive: .FORCE
244         make -C "$(BUILD_DIR)" -s package_archive
245         @echo archive in "$(BUILD_DIR)/release"
246
247
248 # -----------------------------------------------------------------------------
249 # Tests
250 #
251 test: .FORCE
252         cd $(BUILD_DIR) ; ctest . --output-on-failure
253
254 # run pep8 check check on scripts we distribute.
255 test_pep8: .FORCE
256         $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
257         @echo "written: test_pep8.log"
258
259 # run some checks on our cmakefiles.
260 test_cmake: .FORCE
261         $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
262         @echo "written: test_cmake_consistency.log"
263
264 # run deprecation tests, see if we have anything to remove.
265 test_deprecated: .FORCE
266         $(PYTHON) tests/check_deprecated.py
267
268 test_style_c: .FORCE
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" \
274             --no-length-check
275
276 test_style_c_qtc: .FORCE
277         # run our own checks on C/C++ style
278         USE_QTC_TASK=1 \
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" \
283             --no-length-check \
284             > \
285             "$(BLENDER_DIR)/test_style.tasks"
286         @echo "written: test_style.tasks"
287
288
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"
295
296
297 test_style_osl_qtc: .FORCE
298         # run our own checks on C/C++ style
299         USE_QTC_TASK=1 \
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" \
304             > \
305             "$(BLENDER_DIR)/test_style.tasks"
306         @echo "written: test_style.tasks"
307
308 # -----------------------------------------------------------------------------
309 # Project Files
310 #
311
312 project_qtcreator: .FORCE
313         $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
314
315 project_netbeans: .FORCE
316         $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
317
318 project_eclipse: .FORCE
319         cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
320
321
322 # -----------------------------------------------------------------------------
323 # Static Checking
324 #
325
326 check_cppcheck: .FORCE
327         $(CMAKE_CONFIG)
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"
332
333 check_clang_array: .FORCE
334         $(CMAKE_CONFIG)
335         cd "$(BUILD_DIR)" ; \
336         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
337
338 check_splint: .FORCE
339         $(CMAKE_CONFIG)
340         cd "$(BUILD_DIR)" ; \
341         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
342
343 check_sparse: .FORCE
344         $(CMAKE_CONFIG)
345         cd "$(BUILD_DIR)" ; \
346         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
347
348 check_smatch: .FORCE
349         $(CMAKE_CONFIG)
350         cd "$(BUILD_DIR)" ; \
351         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
352
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"
358
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" \
367
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" \
376             > \
377             "$(BLENDER_DIR)/check_spelling_c.tasks"
378
379 check_spelling_osl: .FORCE
380         cd "$(BUILD_DIR)" ;\
381         PYTHONIOENCODING=utf_8 $(PYTHON) \
382             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
383             "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
384
385 check_descriptions: .FORCE
386         "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python \
387             "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
388
389 # -----------------------------------------------------------------------------
390 # Utilities
391 #
392
393 tgz: .FORCE
394         ./build_files/utils/build_tgz.sh
395
396 icons: .FORCE
397         "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
398         "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
399
400 update: .FORCE
401         if [ -d "../lib" ]; then \
402                 svn update ../lib/* ; \
403         fi
404         git pull --rebase
405         git submodule foreach git pull --rebase origin master
406
407
408 # -----------------------------------------------------------------------------
409 # Documentation
410 #
411
412 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
413 doc_py: .FORCE
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'"
418
419 doc_doxy: .FORCE
420         cd doc/doxygen; doxygen Doxyfile
421         @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
422
423 doc_dna: .FORCE
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'"
427
428 doc_man: .FORCE
429         $(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
430
431 help_features: .FORCE
432         @$(PYTHON) -c \
433                 "import re; \
434                 print('\n'.join([ \
435                 w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
436                 if not l.lstrip().startswith('#') \
437                 for w in (re.sub(\
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
440
441
442 clean: .FORCE
443         $(MAKE) -C "$(BUILD_DIR)" clean
444
445 .PHONY: all
446
447 .FORCE: