Cleanup: remove unused test break code for handling cancels.
[blender.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 define HELP_TEXT
28
29 Convenience Targets
30    Provided for building Blender, (multiple at once can be used).
31
32    * debug:         Build a debug binary.
33    * full:          Enable all supported dependencies & options.
34    * lite:          Disable non essential features for a smaller binary and faster build.
35    * headless:      Build without an interface (renderfarm or server automation).
36    * cycles:        Build Cycles standalone only, without Blender.
37    * bpy:           Build as a python module which can be loaded from python directly.
38    * deps:          Build library dependencies (intended only for platform maintainers).
39
40    * config:        Run cmake configuration tool to set build options.
41
42    Note: passing the argument 'BUILD_DIR=path' when calling make will override the default build dir.
43    Note: passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.
44
45
46 Project Files
47    Generate poject files for development environments.
48
49    * project_qtcreator:     QtCreator Project Files.
50    * project_netbeans:      NetBeans Project Files.
51    * project_eclipse:       Eclipse CDT4 Project Files.
52
53 Package Targets
54
55    * package_debian:    Build a debian package.
56    * package_pacman:    Build an arch linux pacman package.
57    * package_archive:   Build an archive package.
58
59 Testing Targets
60    Not associated with building Blender.
61
62    * test:
63      Run ctest, currently tests import/export,
64      operator execution and that python modules load
65    * test_cmake:
66      Runs our own cmake file checker
67      which detects errors in the cmake file list definitions
68    * test_pep8:
69      Checks all python script are pep8
70      which are tagged to use the stricter formatting
71    * test_deprecated:
72      Checks for deprecation tags in our code which may need to be removed
73    * test_style_c:
74      Checks C/C++ conforms with blenders style guide:
75      https://wiki.blender.org/wiki/Source/Code_Style
76    * test_style_c_qtc:
77      Same as test_style but outputs QtCreator tasks format
78    * test_style_osl:
79      Checks OpenShadingLanguage conforms with blenders style guide:
80      https://wiki.blender.org/wiki/Source/Code_Style
81    * test_style_osl_qtc:
82      Checks OpenShadingLanguage conforms with blenders style guide:
83      https://wiki.blender.org/wiki/Source/Code_Style
84
85 Static Source Code Checking
86    Not associated with building Blender.
87
88    * check_cppcheck:        Run blender source through cppcheck (C & C++).
89    * check_clang_array:     Run blender source through clang array checking script (C & C++).
90    * check_splint:          Run blenders source through splint (C only).
91    * check_sparse:          Run blenders source through sparse (C only).
92    * check_smatch:          Run blenders source through smatch (C only).
93    * check_spelling_c:      Check for spelling errors (C/C++ only).
94    * check_spelling_c_qtc:  Same as check_spelling_c but outputs QtCreator tasks format.
95    * check_spelling_osl:    Check for spelling errors (OSL only).
96    * check_spelling_py:     Check for spelling errors (Python only).
97    * check_descriptions:    Check for duplicate/invalid descriptions.
98
99 Utilities
100    Not associated with building Blender.
101
102    * icons:
103      Updates PNG icons from SVG files.
104
105      Optionally pass in variables: 'BLENDER_BIN', 'INKSCAPE_BIN'
106      otherwise default paths are used.
107
108      Example
109         make icons INKSCAPE_BIN=/path/to/inkscape
110
111    * icons_geom:
112      Updates Geometry icons from BLEND file.
113
114      Optionally pass in variable: 'BLENDER_BIN'
115      otherwise default paths are used.
116
117      Example
118         make icons_geom BLENDER_BIN=/path/to/blender
119
120    * tgz:
121      Create a compressed archive of the source code.
122
123    * update:
124      updates git and all submodules
125
126 Environment Variables
127
128    * BUILD_CMAKE_ARGS:      Arguments passed to CMake.
129    * BUILD_DIR:             Override default build path.
130    * PYTHON:                Use this for the Python command (used for checking tools).
131    * NPROCS:                Number of processes to use building (auto-detect when omitted).
132
133 Documentation Targets
134    Not associated with building Blender.
135
136    * doc_py:        Generate sphinx python api docs.
137    * doc_doxy:      Generate doxygen C/C++ docs.
138    * doc_dna:       Generate blender file format reference.
139    * doc_man:       Generate manpage.
140
141 Information
142
143    * help:              This help message.
144    * help_features:     Show a list of optional features when building.
145
146 endef
147 # HELP_TEXT (end)
148
149
150 # System Vars
151 OS:=$(shell uname -s)
152 OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
153 CPU:=$(shell uname -m)
154
155
156 # Source and Build DIR's
157 BLENDER_DIR:=$(shell pwd -P)
158 BUILD_TYPE:=Release
159
160 ifndef BUILD_CMAKE_ARGS
161         BUILD_CMAKE_ARGS:=
162 endif
163
164 ifndef BUILD_DIR
165         BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
166 endif
167
168 # Dependencies DIR's
169 DEPS_SOURCE_DIR:=$(BLENDER_DIR)/build_files/build_environment
170
171 ifndef DEPS_BUILD_DIR
172         DEPS_BUILD_DIR:=$(BUILD_DIR)/deps
173 endif
174
175 ifndef DEPS_INSTALL_DIR
176         DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
177
178         ifneq ($(OS_NCASE),darwin)
179                 # Add processor type to directory name
180                 DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(CPU)
181         endif
182 endif
183
184 # Allow to use alternative binary (pypy3, etc)
185 ifndef PYTHON
186         PYTHON:=python3
187 endif
188
189
190 # -----------------------------------------------------------------------------
191 # additional targets for the build configuration
192
193 # support 'make debug'
194 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
195         BUILD_DIR:=$(BUILD_DIR)_debug
196         BUILD_TYPE:=Debug
197 endif
198 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
199         BUILD_DIR:=$(BUILD_DIR)_full
200         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
201 endif
202 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
203         BUILD_DIR:=$(BUILD_DIR)_lite
204         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
205 endif
206 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
207         BUILD_DIR:=$(BUILD_DIR)_cycles
208         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake"
209 endif
210 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
211         BUILD_DIR:=$(BUILD_DIR)_headless
212         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake"
213 endif
214 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
215         BUILD_DIR:=$(BUILD_DIR)_bpy
216         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
217 endif
218
219
220 # -----------------------------------------------------------------------------
221 # Blender binary path
222
223 # Allow passing in own BLENDER_BIN so developers who don't
224 # use the default build path can still use utility helpers.
225 ifeq ($(OS), Darwin)
226         BLENDER_BIN?="$(BUILD_DIR)/bin/blender.app/Contents/MacOS/blender"
227 else
228         BLENDER_BIN?="$(BUILD_DIR)/bin/blender"
229 endif
230
231
232 # -----------------------------------------------------------------------------
233 # Get the number of cores for threaded build
234 ifndef NPROCS
235         NPROCS:=1
236         ifeq ($(OS), Linux)
237                 NPROCS:=$(shell nproc)
238         endif
239         ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
240                 NPROCS:=$(shell sysctl -n hw.ncpu)
241         endif
242 endif
243
244
245 # -----------------------------------------------------------------------------
246 # Macro for configuring cmake
247
248 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
249                      -H"$(BLENDER_DIR)" \
250                      -B"$(BUILD_DIR)" \
251                      -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
252
253
254 # -----------------------------------------------------------------------------
255 # Tool for 'make config'
256
257 # X11 spesific
258 ifdef DISPLAY
259         CMAKE_CONFIG_TOOL = cmake-gui
260 else
261         CMAKE_CONFIG_TOOL = ccmake
262 endif
263
264
265 # -----------------------------------------------------------------------------
266 # Build Blender
267 all: .FORCE
268         @echo
269         @echo Configuring Blender in \"$(BUILD_DIR)\" ...
270
271 #       # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
272 #       #       $(CMAKE_CONFIG); \
273 #       # fi
274
275 #       # do this always incase of failed initial build, could be smarter here...
276         @$(CMAKE_CONFIG)
277
278         @echo
279         @echo Building Blender ...
280         $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
281         @echo
282         @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
283         @echo Blender successfully built, run from: $(BLENDER_BIN)
284         @echo
285
286 debug: all
287 full: all
288 lite: all
289 cycles: all
290 headless: all
291 bpy: all
292
293 # -----------------------------------------------------------------------------
294 # Build dependencies
295 DEPS_TARGET = install
296 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
297         DEPS_TARGET = clean
298 endif
299
300 deps: .FORCE
301         @echo
302         @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
303
304         @cmake -H"$(DEPS_SOURCE_DIR)" \
305                -B"$(DEPS_BUILD_DIR)" \
306                    -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
307
308         @echo
309         @echo Building dependencies ...
310         $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
311         @echo
312         @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
313         @echo
314
315 # -----------------------------------------------------------------------------
316 # Configuration (save some cd'ing around)
317 config: .FORCE
318         $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
319
320
321 # -----------------------------------------------------------------------------
322 # Help for build targets
323 export HELP_TEXT
324 help: .FORCE
325         @echo "$$HELP_TEXT"
326
327 # -----------------------------------------------------------------------------
328 # Packages
329 #
330 package_debian: .FORCE
331         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
332
333 package_pacman: .FORCE
334         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
335
336 package_archive: .FORCE
337         make -C "$(BUILD_DIR)" -s package_archive
338         @echo archive in "$(BUILD_DIR)/release"
339
340
341 # -----------------------------------------------------------------------------
342 # Tests
343 #
344 test: .FORCE
345         cd $(BUILD_DIR) ; ctest . --output-on-failure
346
347 # run pep8 check check on scripts we distribute.
348 test_pep8: .FORCE
349         $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
350         @echo "written: test_pep8.log"
351
352 # run some checks on our cmakefiles.
353 test_cmake: .FORCE
354         $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
355         @echo "written: test_cmake_consistency.log"
356
357 # run deprecation tests, see if we have anything to remove.
358 test_deprecated: .FORCE
359         $(PYTHON) tests/check_deprecated.py
360
361 test_style_c: .FORCE
362         # run our own checks on C/C++ style
363         PYTHONIOENCODING=utf_8 $(PYTHON) \
364             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
365             "$(BLENDER_DIR)/source/blender" \
366             "$(BLENDER_DIR)/source/creator" \
367             --no-length-check
368
369 test_style_c_qtc: .FORCE
370         # run our own checks on C/C++ style
371         USE_QTC_TASK=1 \
372         PYTHONIOENCODING=utf_8 $(PYTHON) \
373             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
374             "$(BLENDER_DIR)/source/blender" \
375             "$(BLENDER_DIR)/source/creator" \
376             --no-length-check \
377             > \
378             "$(BLENDER_DIR)/test_style.tasks"
379         @echo "written: test_style.tasks"
380
381
382 test_style_osl: .FORCE
383         # run our own checks on C/C++ style
384         PYTHONIOENCODING=utf_8 $(PYTHON) \
385             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
386             "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
387             "$(BLENDER_DIR)/release/scripts/templates_osl"
388
389
390 test_style_osl_qtc: .FORCE
391         # run our own checks on C/C++ style
392         USE_QTC_TASK=1 \
393         PYTHONIOENCODING=utf_8 $(PYTHON) \
394             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
395             "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
396             "$(BLENDER_DIR)/release/scripts/templates_osl" \
397             > \
398             "$(BLENDER_DIR)/test_style.tasks"
399         @echo "written: test_style.tasks"
400
401 # -----------------------------------------------------------------------------
402 # Project Files
403 #
404
405 project_qtcreator: .FORCE
406         $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
407
408 project_netbeans: .FORCE
409         $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
410
411 project_eclipse: .FORCE
412         cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
413
414
415 # -----------------------------------------------------------------------------
416 # Static Checking
417 #
418
419 check_cppcheck: .FORCE
420         $(CMAKE_CONFIG)
421         cd "$(BUILD_DIR)" ; \
422         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
423             "$(BLENDER_DIR)/check_cppcheck.txt"
424         @echo "written: check_cppcheck.txt"
425
426 check_clang_array: .FORCE
427         $(CMAKE_CONFIG)
428         cd "$(BUILD_DIR)" ; \
429         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
430
431 check_splint: .FORCE
432         $(CMAKE_CONFIG)
433         cd "$(BUILD_DIR)" ; \
434         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
435
436 check_sparse: .FORCE
437         $(CMAKE_CONFIG)
438         cd "$(BUILD_DIR)" ; \
439         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
440
441 check_smatch: .FORCE
442         $(CMAKE_CONFIG)
443         cd "$(BUILD_DIR)" ; \
444         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
445
446 check_spelling_py: .FORCE
447         cd "$(BUILD_DIR)" ; \
448         PYTHONIOENCODING=utf_8 $(PYTHON) \
449             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
450             "$(BLENDER_DIR)/release/scripts"
451
452 check_spelling_c: .FORCE
453         cd "$(BUILD_DIR)" ; \
454         PYTHONIOENCODING=utf_8 $(PYTHON) \
455             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
456             "$(BLENDER_DIR)/source" \
457             "$(BLENDER_DIR)/intern/cycles" \
458             "$(BLENDER_DIR)/intern/guardedalloc" \
459             "$(BLENDER_DIR)/intern/ghost" \
460
461 check_spelling_c_qtc: .FORCE
462         cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
463         PYTHONIOENCODING=utf_8 $(PYTHON) \
464             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
465             "$(BLENDER_DIR)/source" \
466             "$(BLENDER_DIR)/intern/cycles" \
467             "$(BLENDER_DIR)/intern/guardedalloc" \
468             "$(BLENDER_DIR)/intern/ghost" \
469             > \
470             "$(BLENDER_DIR)/check_spelling_c.tasks"
471
472 check_spelling_osl: .FORCE
473         cd "$(BUILD_DIR)" ;\
474         PYTHONIOENCODING=utf_8 $(PYTHON) \
475             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
476             "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
477
478 check_descriptions: .FORCE
479         $(BLENDER_BIN) --background -noaudio --factory-startup --python \
480             "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
481
482 # -----------------------------------------------------------------------------
483 # Utilities
484 #
485
486 tgz: .FORCE
487         ./build_files/utils/build_tgz.sh
488
489 INKSCAPE_BIN?="inkscape"
490 icons: .FORCE
491         BLENDER_BIN=$(BLENDER_BIN) INKSCAPE_BIN=$(INKSCAPE_BIN) \
492                 "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
493         BLENDER_BIN=$(BLENDER_BIN) INKSCAPE_BIN=$(INKSCAPE_BIN) \
494                 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
495
496 icons_geom: .FORCE
497         BLENDER_BIN=$(BLENDER_BIN) \
498             "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
499
500 update: .FORCE
501         if [ "$(OS_NCASE)" = "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
502                 svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
503         fi
504         if [ -d "../lib" ]; then \
505                 svn cleanup ../lib/* ; \
506                 svn update ../lib/* ; \
507         fi
508         git pull --rebase
509         git submodule update --init --recursive
510         git submodule foreach git checkout master
511         git submodule foreach git pull --rebase origin master
512
513
514 # -----------------------------------------------------------------------------
515 # Documentation
516 #
517
518 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
519 doc_py: .FORCE
520         ASAN_OPTIONS=halt_on_error=0 \
521         $(BLENDER_BIN) --background -noaudio --factory-startup \
522                 --python doc/python_api/sphinx_doc_gen.py
523         cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
524         @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'"
525
526 doc_doxy: .FORCE
527         cd doc/doxygen; doxygen Doxyfile
528         @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
529
530 doc_dna: .FORCE
531         $(BLENDER_BIN) --background -noaudio --factory-startup \
532                 --python doc/blender_file_format/BlendFileDnaExporter_25.py
533         @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
534
535 doc_man: .FORCE
536         $(PYTHON) doc/manpage/blender.1.py $(BLENDER_BIN) blender.1
537
538 help_features: .FORCE
539         @$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt"
540
541 clean: .FORCE
542         $(MAKE) -C "$(BUILD_DIR)" clean
543
544 .PHONY: all
545
546 .FORCE: