1 # SPDX-FileCopyrightText: 2011-2023 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # This Makefile does an out-of-source CMake build in ../build_`OS`
8 # This is for users who like to configure & build blender with a single command.
12 Blender Convenience Targets
13 Provided for building Blender
(multiple targets can be used at once
).
15 * debug
: Build a debug binary.
16 * full
: Enable
all supported dependencies
& options.
17 * lite
: Disable non essential features for a smaller binary and faster build.
18 * release
: Complete build with
all options enabled including CUDA and Optix
, matching the releases on blender.org
19 * headless
: Build without an interface
(renderfarm or server automation
).
20 * cycles
: Build Cycles standalone only
, without Blender.
21 * bpy
: Build
as a python module which can be loaded from python directly.
22 * developer
: Enable faster builds
, error checking and tests
, recommended for developers.
23 * ninja
: Use ninja build tool for faster builds.
24 * ccache
: Use ccache for faster rebuilds.
26 Note
: when passing in multiple targets their order is not important.
27 So for a fast build you can for e.g. run
'make lite ccache ninja'.
28 Note
: passing the argument
'BUILD_DIR=path' when calling make will
override the default build
dir.
29 Note
: passing the argument
'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.
31 Other Convenience Targets
32 Provided for other building operations.
34 * config
: Run cmake configuration tool to set build options.
35 * deps
: Build library dependencies
(intended only for platform maintainers
).
37 The existence of locally build dependencies overrides the pre-built dependencies from subversion.
38 These must be manually removed from
'lib/' to go back to using the pre-compiled libraries.
41 Generate project files for development environments.
43 * project_qtcreator
: QtCreator Project Files.
44 * project_netbeans
: NetBeans Project Files.
45 * project_eclipse
: Eclipse CDT4 Project Files.
49 * package_archive
: Build an archive package.
52 Not associated with building Blender.
55 Run automated tests with ctest.
57 Static Source Code Checking
58 Not associated with building Blender.
60 * check_cppcheck
: Run blender source through cppcheck
(C
& C
++).
61 * check_clang_array
: Run blender source through clang array checking script
(C
& C
++).
62 * check_struct_comments
: Check struct member comments are correct
(C
& C
++).
63 * check_deprecated
: Check if there is any deprecated code to remove.
64 * check_descriptions
: Check for duplicate
/invalid descriptions.
65 * check_licenses
: Check license headers follow the SPDX license specification
,
66 using one of the accepted licenses in
'doc/license/SPDX-license-identifiers.txt'
67 Append with
'SHOW_HEADERS=1' to show
all unique headers
68 which can be useful for spotting license irregularities.
69 * check_cmake
: Runs our own cmake file checker which detects errors in the cmake file list definitions.
70 * check_pep8
: Checks
all Python script are pep8 which are tagged to use the stricter formatting.
71 * check_mypy
: Checks
all Python scripts using mypy
,
72 see
: tools
/check_source
/check_mypy_config.py scripts which are included.
74 Documentation Checking
76 * check_docs_file_structure
:
77 Check the documentation for the source-tree
's file structure
78 matches Blender's source-code.
79 See
: https
://developer.blender.org
/docs
/features
/code_layout
/
82 This runs the spell checker from the developer tools repositor.
84 * check_spelling_c
: Check for spelling errors
(C
/C
++ only
),
85 * check_spelling_py
: Check for spelling errors
(Python only
).
86 * check_spelling_shaders
: Check for spelling errors
(GLSL
,OSL
& MSL only
).
88 Note
: an additional word-list is maintained at
: 'tools/check_source/check_spelling_c_config.py'
90 Note
: that spell checkers can take a
'CHECK_SPELLING_CACHE' filepath argument
,
91 so re-running does not need to re-check unchanged files.
94 make check_spelling_c CHECK_SPELLING_CACHE
=..
/spelling_cache.data
97 Not associated with building Blender.
100 Updates PNG icons from SVG files.
102 Optionally pass in variables
: 'BLENDER_BIN', 'INKSCAPE_BIN'
103 otherwise default paths are used.
106 make icons INKSCAPE_BIN
=/path
/to
/inkscape
109 Updates Geometry icons from BLEND file.
111 Optionally pass in variable
: 'BLENDER_BIN'
112 otherwise default paths are used.
115 make icons_geom BLENDER_BIN
=/path
/to
/blender
118 Create a compressed archive of the source code.
120 * source_archive_complete
:
121 Create a compressed archive of the source code and
all the libraries of dependencies.
124 Updates git and
all submodules and svn.
127 Updates git and
all submodules but not svn.
130 Format source code using clang-format
& autopep8
(uses PATHS if passed in
). For example
::
132 make format PATHS
="source/blender/blenlib source/blender/blenkernel"
134 Environment Variables
136 * BUILD_CMAKE_ARGS
: Arguments passed to CMake.
137 * BUILD_DIR
: Override default build path.
138 * PYTHON
: Use this for the Python command
(used for checking tools
).
139 * NPROCS
: Number of processes to use building
(auto-detect when omitted
).
140 * AUTOPEP8
: Command used for Python code-formatting
(used for the format target
).
142 Documentation Targets
143 Not associated with building Blender.
145 * doc_py
: Generate sphinx python api docs.
146 * doc_doxy
: Generate doxygen C
/C
++ docs.
147 * doc_dna
: Generate blender file format reference.
148 * doc_man
: Generate manpage.
152 * help
: This help message.
153 * help_features
: Show a list of optional features when building.
158 # This makefile is not meant for Windows
159 ifeq ($(OS
),Windows_NT
)
160 $(error On Windows
, use
"cmd //c make.bat" instead of
"make")
164 OS
:=$(shell uname
-s
)
165 OS_NCASE
:=$(shell uname
-s | tr
'[A-Z]' '[a-z]')
166 CPU
:=$(shell uname
-m
)
168 # Use our OS and CPU architecture naming conventions.
172 ifeq ($(OS_NCASE
),darwin
)
175 OS_LIBDIR
:=$(OS_NCASE
)
179 # Source and Build DIR's
180 BLENDER_DIR
:=$(shell pwd
-P
)
182 BLENDER_IS_PYTHON_MODULE
:=
184 # CMake arguments, assigned to local variable to make it mutable.
185 CMAKE_CONFIG_ARGS
:= $(BUILD_CMAKE_ARGS
)
188 BUILD_DIR
:=$(shell dirname
"$(BLENDER_DIR)")/build_
$(OS_NCASE
)
192 DEPS_SOURCE_DIR
:=$(BLENDER_DIR
)/build_files
/build_environment
194 ifndef DEPS_BUILD_DIR
195 DEPS_BUILD_DIR
:=$(BUILD_DIR
)/deps
198 ifndef DEPS_INSTALL_DIR
199 DEPS_INSTALL_DIR
:=$(shell dirname
"$(BLENDER_DIR)")/lib
/$(OS_LIBDIR
)_
$(CPU
)
202 # Set the LIBDIR, an empty string when not found.
203 LIBDIR
:=$(wildcard $(BLENDER_DIR
)/lib
/${OS_LIBDIR}_
${CPU})
205 LIBDIR
:=$(wildcard $(BLENDER_DIR
)/lib
/${OS_LIBDIR})
208 # Find the newest Python version bundled in `LIBDIR`.
210 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
212 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
214 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
216 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
218 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
226 # Allow to use alternative binary (pypy3, etc)
228 # If not overriden, first try using Python from LIBDIR.
229 PYTHON
:=$(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)
230 ifeq (, $(wildcard $(PYTHON
)))
231 # If not available, use system python3 or python command.
233 ifeq (, $(shell command
-v
$(PYTHON
)))
237 # Don't generate __pycache__ files in lib folder, they
238 # can interfere with updates.
243 # Use the autopep8 module in ../lib/ (which can be executed via Python directly).
244 # Otherwise the "autopep8" command can be used.
247 AUTOPEP8
:=$(wildcard $(LIBDIR
)/python
/lib
/python
$(PY_LIB_VERSION
)/site-packages
/autopep8.py
)
255 # -----------------------------------------------------------------------------
256 # Additional targets for the build configuration
258 # NOTE: These targets can be combined and are applied in reverse order listed here.
259 # So it's important that `bpy` comes before `release` (for example)
260 # `make bpy release` first loads `release` configuration, then `bpy`.
261 # This is important as `bpy` will turn off some settings enabled by release.
263 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
264 BUILD_DIR
:=$(BUILD_DIR
)_bpy
265 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" $(CMAKE_CONFIG_ARGS
)
266 BLENDER_IS_PYTHON_MODULE
:=1
268 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
269 BUILD_DIR
:=$(BUILD_DIR
)_debug
272 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
273 BUILD_DIR
:=$(BUILD_DIR
)_full
274 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake" $(CMAKE_CONFIG_ARGS
)
276 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
277 BUILD_DIR
:=$(BUILD_DIR
)_lite
278 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake" $(CMAKE_CONFIG_ARGS
)
280 ifneq "$(findstring release, $(MAKECMDGOALS))" ""
281 BUILD_DIR
:=$(BUILD_DIR
)_release
282 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_release.cmake" $(CMAKE_CONFIG_ARGS
)
284 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
285 BUILD_DIR
:=$(BUILD_DIR
)_cycles
286 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake" $(CMAKE_CONFIG_ARGS
)
288 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
289 BUILD_DIR
:=$(BUILD_DIR
)_headless
290 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake" $(CMAKE_CONFIG_ARGS
)
293 ifneq "$(findstring developer, $(MAKECMDGOALS))" ""
294 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_developer.cmake" $(CMAKE_CONFIG_ARGS
)
297 ifneq "$(findstring ccache, $(MAKECMDGOALS))" ""
298 CMAKE_CONFIG_ARGS
:=-DWITH_COMPILER_CCACHE
=YES
$(CMAKE_CONFIG_ARGS
)
301 # -----------------------------------------------------------------------------
304 ifneq "$(findstring ninja, $(MAKECMDGOALS))" ""
305 CMAKE_CONFIG_ARGS
:=$(CMAKE_CONFIG_ARGS
) -G Ninja
307 DEPS_BUILD_COMMAND
:=ninja
309 ifneq ("$(wildcard $(BUILD_DIR)/build.ninja)","")
312 BUILD_COMMAND
:=make
-s
315 ifneq ("$(wildcard $(DEPS_BUILD_DIR)/build.ninja)","")
316 DEPS_BUILD_COMMAND
:=ninja
319 DEPS_BUILD_COMMAND
:=make
-s
321 DEPS_BUILD_COMMAND
:="$(BLENDER_DIR)/build_files/build_environment/linux/make_deps_wrapper.sh" -s
326 # -----------------------------------------------------------------------------
327 # Blender binary path
329 # Allow passing in own BLENDER_BIN so developers who don't
330 # use the default build path can still use utility helpers.
332 BLENDER_BIN?
="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
333 BLENDER_BIN_DIR?
="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
335 BLENDER_BIN?
="$(BUILD_DIR)/bin/blender"
336 BLENDER_BIN_DIR?
="$(BUILD_DIR)/bin"
340 # -----------------------------------------------------------------------------
341 # Get the number of cores for threaded build
345 NPROCS
:=$(shell nproc
)
348 NPROCS
:=$(shell getconf NPROCESSORS_ONLN
)
350 ifneq (,$(filter $(OS
),Darwin FreeBSD
))
351 NPROCS
:=$(shell sysctl
-n hw.ncpu
)
356 # -----------------------------------------------------------------------------
357 # Macro for configuring cmake
359 CMAKE_CONFIG
= cmake
$(CMAKE_CONFIG_ARGS
) \
362 -DCMAKE_BUILD_TYPE_INIT
:STRING
=$(BUILD_TYPE
)
365 # -----------------------------------------------------------------------------
366 # Tool for 'make config'
370 CMAKE_CONFIG_TOOL
= cmake-gui
372 CMAKE_CONFIG_TOOL
= ccmake
376 # -----------------------------------------------------------------------------
380 @echo Configuring Blender in
\"$(BUILD_DIR
)\" ...
382 # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
383 # # $(CMAKE_CONFIG); \
386 # # do this always incase of failed initial build, could be smarter here...
390 @echo Building Blender ...
391 $(BUILD_COMMAND
) -C
"$(BUILD_DIR)" -j
$(NPROCS
) install
393 @echo Edit build configuration with
: \"$(BUILD_DIR
)/CMakeCache.txt
\" run make again to rebuild.
394 @if
test -z
"$(BLENDER_IS_PYTHON_MODULE)"; then \
395 echo Blender successfully built
, run from
: $(BLENDER_BIN
); \
397 echo Blender successfully built
as a Python module
, \"bpy
\" can be imported from
: $(BLENDER_BIN_DIR
); \
412 # -----------------------------------------------------------------------------
414 DEPS_TARGET
= install
415 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
421 @echo Configuring dependencies in
\"$(DEPS_BUILD_DIR
)\", install to
\"$(DEPS_INSTALL_DIR
)\"
423 @cmake
-H
"$(DEPS_SOURCE_DIR)" \
424 -B
"$(DEPS_BUILD_DIR)" \
425 -DHARVEST_TARGET
=$(DEPS_INSTALL_DIR
)
428 @echo Building dependencies ...
429 $(DEPS_BUILD_COMMAND
) -C
"$(DEPS_BUILD_DIR)" -j
$(NPROCS
) $(DEPS_TARGET
)
431 @echo Dependencies successfully built and installed to
$(DEPS_INSTALL_DIR
).
434 # -----------------------------------------------------------------------------
435 # Configuration (save some cd'ing around)
437 $(CMAKE_CONFIG_TOOL
) "$(BUILD_DIR)"
440 # -----------------------------------------------------------------------------
441 # Help for build targets
446 # -----------------------------------------------------------------------------
450 package_archive
: .FORCE
451 make
-C
"$(BUILD_DIR)" -s package_archive
452 @echo archive in
"$(BUILD_DIR)/release"
455 # -----------------------------------------------------------------------------
459 @
$(PYTHON
) .
/build_files
/utils
/make_test.py
"$(BUILD_DIR)"
462 # -----------------------------------------------------------------------------
466 project_qtcreator
: .FORCE
467 $(PYTHON
) build_files
/cmake
/cmake_qtcreator_project.py
--build-dir
"$(BUILD_DIR)"
469 project_netbeans
: .FORCE
470 $(PYTHON
) build_files
/cmake
/cmake_netbeans_project.py
"$(BUILD_DIR)"
472 project_eclipse
: .FORCE
473 cmake
-G
"Eclipse CDT4 - Unix Makefiles" -H
"$(BLENDER_DIR)" -B
"$(BUILD_DIR)"
476 # -----------------------------------------------------------------------------
480 check_cppcheck
: .FORCE
482 @cd
"$(BUILD_DIR)" ; \
484 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py"
486 check_struct_comments
: .FORCE
488 @cd
"$(BUILD_DIR)" ; \
490 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang.py" \
491 --checks
=struct_comments
--match
=".*" --jobs
=$(NPROCS
)
493 check_clang_array
: .FORCE
495 @cd
"$(BUILD_DIR)" ; \
496 $(PYTHON
) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
499 @
$(PYTHON
) "$(BLENDER_DIR)/tools/check_source/check_mypy.py"
501 check_docs_file_structure
: .FORCE
502 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
503 "$(BLENDER_DIR)/tools/check_docs/check_docs_code_layout.py"
505 check_spelling_py
: .FORCE
506 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
507 "$(BLENDER_DIR)/tools/check_source/check_spelling.py" \
508 --cache-file
=$(CHECK_SPELLING_CACHE
) \
509 --match
=".*\.(py)$$" \
510 "$(BLENDER_DIR)/scripts" \
511 "$(BLENDER_DIR)/source" \
512 "$(BLENDER_DIR)/tools"
514 check_spelling_c
: .FORCE
515 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
516 "$(BLENDER_DIR)/tools/check_source/check_spelling.py" \
517 --cache-file
=$(CHECK_SPELLING_CACHE
) \
518 --match
=".*\.(c|cc|cpp|cxx|h|hh|hpp|hxx|inl|m|mm)$$" \
519 "$(BLENDER_DIR)/source" \
520 "$(BLENDER_DIR)/intern/cycles" \
521 "$(BLENDER_DIR)/intern/guardedalloc" \
522 "$(BLENDER_DIR)/intern/ghost"
524 check_spelling_shaders
: .FORCE
525 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
526 "$(BLENDER_DIR)/tools/check_source/check_spelling.py" \
527 --cache-file
=$(CHECK_SPELLING_CACHE
) \
528 --match
=".*\.(osl|metal|msl|glsl)$$" \
529 "$(BLENDER_DIR)/intern/" \
530 "$(BLENDER_DIR)/source/"
532 check_descriptions
: .FORCE
533 @
$(BLENDER_BIN
) --background
--factory-startup
--python \
534 "$(BLENDER_DIR)/tools/check_source/check_descriptions.py"
536 check_deprecated
: .FORCE
537 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
538 tools
/check_source
/check_deprecated.py
540 check_licenses
: .FORCE
541 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
542 "$(BLENDER_DIR)/tools/check_source/check_licenses.py" \
543 "--show-headers=$(SHOW_HEADERS)"
546 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
550 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
551 tools
/check_source
/check_cmake_consistency.py
554 # -----------------------------------------------------------------------------
558 source_archive
: .FORCE
559 @
$(PYTHON
) .
/build_files
/utils
/make_source_archive.py
561 source_archive_complete
: .FORCE
563 -S
"$(BLENDER_DIR)/build_files/build_environment" -B
"$(BUILD_DIR)/source_archive" \
564 -DCMAKE_BUILD_TYPE_INIT
:STRING
=$(BUILD_TYPE
) -DPACKAGE_USE_UPSTREAM_SOURCES
=OFF
565 # This assumes CMake is still using a default `PACKAGE_DIR` variable:
566 @
$(PYTHON
) .
/build_files
/utils
/make_source_archive.py
--include-packages
"$(BUILD_DIR)/source_archive/packages"
569 @BLENDER_BIN
=$(BLENDER_BIN
) "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
570 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
571 "$(BLENDER_DIR)/release/datafiles/alert_icons_update.py"
574 @BLENDER_BIN
=$(BLENDER_BIN
) \
575 "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
578 @
$(PYTHON
) .
/build_files
/utils
/make_update.py
581 @
$(PYTHON
) .
/build_files
/utils
/make_update.py
--no-libraries
584 @PATH
="${LIBDIR}/llvm/bin/:$(PATH)" $(PYTHON
) tools
/utils_maintenance
/clang_format_paths.py
$(PATHS
)
585 @
$(PYTHON
) tools
/utils_maintenance
/autopep8_format_paths.py
--autopep8-command
="$(AUTOPEP8)" $(PATHS
)
588 # -----------------------------------------------------------------------------
592 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
594 @ASAN_OPTIONS
=halt_on_error
=0:${ASAN_OPTIONS} \
596 --background
--factory-startup \
597 --python doc
/python_api
/sphinx_doc_gen.py
598 @sphinx-build
-b html
-j
$(NPROCS
) doc
/python_api
/sphinx-in doc
/python_api
/sphinx-out
599 @echo
"docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'"
602 @cd doc
/doxygen
; doxygen Doxyfile
603 @echo
"docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
607 --background
--factory-startup \
608 --python doc
/blender_file_format
/BlendFileDnaExporter_25.py
609 @echo
"docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
612 @
$(PYTHON
) doc
/manpage
/blender
.1.py
--blender
="$(BLENDER_BIN)" --output
=blender
.1 --verbose
614 help_features
: .FORCE
615 @
$(PYTHON
) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR
)"/CMakeLists.txt"
618 $(BUILD_COMMAND
) -C
"$(BUILD_DIR)" clean