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