Follow up to MESH_OT_offset_edge_loops
[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
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 # Blender binary path
94
95 ifeq ($(OS), Darwin)
96         BLENDER_BIN="$(BUILD_DIR)/bin/blender.app/Contents/MacOS/blender"
97 else
98         BLENDER_BIN="$(BUILD_DIR)/bin/blender"
99 endif
100
101
102 # -----------------------------------------------------------------------------
103 # Get the number of cores for threaded build
104 ifndef NPROCS
105         NPROCS:=1
106         ifeq ($(OS), Linux)
107                 NPROCS:=$(shell nproc)
108         endif
109         ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD))
110                 NPROCS:=$(shell sysctl -n hw.ncpu)
111         endif
112 endif
113
114
115 # -----------------------------------------------------------------------------
116 # Macro for configuring cmake
117
118 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
119                      -H"$(BLENDER_DIR)" \
120                      -B"$(BUILD_DIR)" \
121                      -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
122
123
124 # -----------------------------------------------------------------------------
125 # Tool for 'make config'
126
127 # X11 spesific
128 ifdef DISPLAY
129         CMAKE_CONFIG_TOOL = cmake-gui
130 else
131         CMAKE_CONFIG_TOOL = ccmake
132 endif
133
134
135 # -----------------------------------------------------------------------------
136 # Build Blender
137 all: .FORCE
138         @echo
139         @echo Configuring Blender in \"$(BUILD_DIR)\" ...
140
141 #       # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
142 #       #       $(CMAKE_CONFIG); \
143 #       # fi
144
145 #       # do this always incase of failed initial build, could be smarter here...
146         @$(CMAKE_CONFIG)
147
148         @echo
149         @echo Building Blender ...
150         $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
151         @echo
152         @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
153         @echo Blender successfully built, run from: $(BLENDER_BIN)
154         @echo
155
156 debug: all
157 full: all
158 lite: all
159 cycles: all
160 headless: all
161 bpy: all
162
163 # -----------------------------------------------------------------------------
164 # Build dependencies
165 DEPS_TARGET = install
166 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
167         DEPS_TARGET = clean
168 endif
169
170 deps: .FORCE
171         @echo
172         @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\"
173
174         @cmake -H"$(DEPS_SOURCE_DIR)" \
175                -B"$(DEPS_BUILD_DIR)" \
176                    -DHARVEST_TARGET=$(DEPS_INSTALL_DIR)
177
178         @echo
179         @echo Building dependencies ...
180         $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
181         @echo
182         @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
183         @echo
184
185 # -----------------------------------------------------------------------------
186 # Configuration (save some cd'ing around)
187 config: .FORCE
188         $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)"
189
190
191 # -----------------------------------------------------------------------------
192 # Help for build targets
193 help: .FORCE
194         @echo ""
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)"
203         @echo ""
204         @echo "  * config    - run cmake configuration tool to set build options"
205         @echo ""
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."
208         @echo ""
209         @echo ""
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"
214         @echo ""
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"
219         @echo ""
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 "                         https://wiki.blender.org/wiki/Source/Code_Style"
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 "                         https://wiki.blender.org/wiki/Source/Code_Style"
233         @echo "  * test_style_osl_qtc - checks OpenShadingLanguage conforms with blenders style guide:"
234         @echo "                         https://wiki.blender.org/wiki/Source/Code_Style"
235         @echo ""
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"
247         @echo ""
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 "  * icons_geom - Updates Geometry icons from BLEND file."
253         @echo "                 Set environment variable 'BLENDER_BIN'"
254         @echo "                 to define your own command."
255         @echo "  * tgz        - create a compressed archive of the source code."
256         @echo "  * update     - updates git and all submodules"
257         @echo ""
258         @echo "Environment Variables"
259         @echo "  * BUILD_CMAKE_ARGS    - arguments passed to CMake."
260         @echo "  * BUILD_DIR           - override default build path."
261         @echo "  * PYTHON              - use this for the Python command (used for checking tools)."
262         @echo "  * NPROCS              - number of processes to use building (auto-detect when omitted)."
263         @echo ""
264         @echo "Documentation Targets (not associated with building blender)"
265         @echo "  * doc_py   - generate sphinx python api docs"
266         @echo "  * doc_doxy - generate doxygen C/C++ docs"
267         @echo "  * doc_dna  - generate blender file format reference"
268         @echo "  * doc_man  - generate manpage"
269         @echo ""
270         @echo "Information"
271         @echo "  * help          - this help message"
272         @echo "  * help_features - show a list of optional features when building"
273         @echo ""
274
275 # -----------------------------------------------------------------------------
276 # Packages
277 #
278 package_debian: .FORCE
279         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
280
281 package_pacman: .FORCE
282         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg
283
284 package_archive: .FORCE
285         make -C "$(BUILD_DIR)" -s package_archive
286         @echo archive in "$(BUILD_DIR)/release"
287
288
289 # -----------------------------------------------------------------------------
290 # Tests
291 #
292 test: .FORCE
293         cd $(BUILD_DIR) ; ctest . --output-on-failure
294
295 # run pep8 check check on scripts we distribute.
296 test_pep8: .FORCE
297         $(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
298         @echo "written: test_pep8.log"
299
300 # run some checks on our cmakefiles.
301 test_cmake: .FORCE
302         $(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
303         @echo "written: test_cmake_consistency.log"
304
305 # run deprecation tests, see if we have anything to remove.
306 test_deprecated: .FORCE
307         $(PYTHON) tests/check_deprecated.py
308
309 test_style_c: .FORCE
310         # run our own checks on C/C++ style
311         PYTHONIOENCODING=utf_8 $(PYTHON) \
312             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
313             "$(BLENDER_DIR)/source/blender" \
314             "$(BLENDER_DIR)/source/creator" \
315             --no-length-check
316
317 test_style_c_qtc: .FORCE
318         # run our own checks on C/C++ style
319         USE_QTC_TASK=1 \
320         PYTHONIOENCODING=utf_8 $(PYTHON) \
321             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
322             "$(BLENDER_DIR)/source/blender" \
323             "$(BLENDER_DIR)/source/creator" \
324             --no-length-check \
325             > \
326             "$(BLENDER_DIR)/test_style.tasks"
327         @echo "written: test_style.tasks"
328
329
330 test_style_osl: .FORCE
331         # run our own checks on C/C++ style
332         PYTHONIOENCODING=utf_8 $(PYTHON) \
333             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
334             "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
335             "$(BLENDER_DIR)/release/scripts/templates_osl"
336
337
338 test_style_osl_qtc: .FORCE
339         # run our own checks on C/C++ style
340         USE_QTC_TASK=1 \
341         PYTHONIOENCODING=utf_8 $(PYTHON) \
342             "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
343             "$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
344             "$(BLENDER_DIR)/release/scripts/templates_osl" \
345             > \
346             "$(BLENDER_DIR)/test_style.tasks"
347         @echo "written: test_style.tasks"
348
349 # -----------------------------------------------------------------------------
350 # Project Files
351 #
352
353 project_qtcreator: .FORCE
354         $(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
355
356 project_netbeans: .FORCE
357         $(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
358
359 project_eclipse: .FORCE
360         cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
361
362
363 # -----------------------------------------------------------------------------
364 # Static Checking
365 #
366
367 check_cppcheck: .FORCE
368         $(CMAKE_CONFIG)
369         cd "$(BUILD_DIR)" ; \
370         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
371             "$(BLENDER_DIR)/check_cppcheck.txt"
372         @echo "written: check_cppcheck.txt"
373
374 check_clang_array: .FORCE
375         $(CMAKE_CONFIG)
376         cd "$(BUILD_DIR)" ; \
377         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
378
379 check_splint: .FORCE
380         $(CMAKE_CONFIG)
381         cd "$(BUILD_DIR)" ; \
382         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
383
384 check_sparse: .FORCE
385         $(CMAKE_CONFIG)
386         cd "$(BUILD_DIR)" ; \
387         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
388
389 check_smatch: .FORCE
390         $(CMAKE_CONFIG)
391         cd "$(BUILD_DIR)" ; \
392         $(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
393
394 check_spelling_py: .FORCE
395         cd "$(BUILD_DIR)" ; \
396         PYTHONIOENCODING=utf_8 $(PYTHON) \
397             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
398             "$(BLENDER_DIR)/release/scripts"
399
400 check_spelling_c: .FORCE
401         cd "$(BUILD_DIR)" ; \
402         PYTHONIOENCODING=utf_8 $(PYTHON) \
403             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
404             "$(BLENDER_DIR)/source" \
405             "$(BLENDER_DIR)/intern/cycles" \
406             "$(BLENDER_DIR)/intern/guardedalloc" \
407             "$(BLENDER_DIR)/intern/ghost" \
408
409 check_spelling_c_qtc: .FORCE
410         cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
411         PYTHONIOENCODING=utf_8 $(PYTHON) \
412             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
413             "$(BLENDER_DIR)/source" \
414             "$(BLENDER_DIR)/intern/cycles" \
415             "$(BLENDER_DIR)/intern/guardedalloc" \
416             "$(BLENDER_DIR)/intern/ghost" \
417             > \
418             "$(BLENDER_DIR)/check_spelling_c.tasks"
419
420 check_spelling_osl: .FORCE
421         cd "$(BUILD_DIR)" ;\
422         PYTHONIOENCODING=utf_8 $(PYTHON) \
423             "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
424             "$(BLENDER_DIR)/intern/cycles/kernel/shaders"
425
426 check_descriptions: .FORCE
427         $(BLENDER_BIN) --background -noaudio --factory-startup --python \
428             "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
429
430 # -----------------------------------------------------------------------------
431 # Utilities
432 #
433
434 tgz: .FORCE
435         ./build_files/utils/build_tgz.sh
436
437 icons: .FORCE
438         "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
439         "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
440
441 icons_geom: .FORCE
442         BLENDER_BIN=$(BLENDER_BIN) \
443             "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
444
445 update: .FORCE
446         if [ "$(OS_NCASE)" = "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
447                 svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
448         fi
449         if [ -d "../lib" ]; then \
450                 svn cleanup ../lib/* ; \
451                 svn update ../lib/* ; \
452         fi
453         git pull --rebase
454         git submodule update --init --recursive
455         git submodule foreach git checkout master
456         git submodule foreach git pull --rebase origin master
457
458
459 # -----------------------------------------------------------------------------
460 # Documentation
461 #
462
463 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
464 doc_py: .FORCE
465         $(BLENDER_BIN) --background -noaudio --factory-startup \
466                 --python doc/python_api/sphinx_doc_gen.py
467         cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
468         @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'"
469
470 doc_doxy: .FORCE
471         cd doc/doxygen; doxygen Doxyfile
472         @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
473
474 doc_dna: .FORCE
475         $(BLENDER_BIN) --background -noaudio --factory-startup \
476                 --python doc/blender_file_format/BlendFileDnaExporter_25.py
477         @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
478
479 doc_man: .FORCE
480         $(PYTHON) doc/manpage/blender.1.py $(BLENDER_BIN) blender.1
481
482 help_features: .FORCE
483         @$(PYTHON) -c \
484                 "import re; \
485                 print('\n'.join([ \
486                 w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
487                 if not l.lstrip().startswith('#') \
488                 for w in (re.sub(\
489                     r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\".*\")\s*.*', r'\g<1> - \g<2>', l).strip('() \n'),) \
490                 if w.startswith('WITH_')]))" | uniq
491
492
493 clean: .FORCE
494         $(MAKE) -C "$(BUILD_DIR)" clean
495
496 .PHONY: all
497
498 .FORCE: