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`_`CPU`
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
)
169 # Source and Build DIR's
170 BLENDER_DIR
:=$(shell pwd
-P
)
172 BLENDER_IS_PYTHON_MODULE
:=
174 # CMake arguments, assigned to local variable to make it mutable.
175 CMAKE_CONFIG_ARGS
:= $(BUILD_CMAKE_ARGS
)
178 BUILD_DIR
:=$(shell dirname
"$(BLENDER_DIR)")/build_
$(OS_NCASE
)
182 DEPS_SOURCE_DIR
:=$(BLENDER_DIR
)/build_files
/build_environment
184 ifndef DEPS_BUILD_DIR
185 DEPS_BUILD_DIR
:=$(BUILD_DIR
)/deps
188 ifndef DEPS_INSTALL_DIR
189 DEPS_INSTALL_DIR
:=$(shell dirname
"$(BLENDER_DIR)")/lib
/$(OS_NCASE
)
191 # Add processor type to directory name, except for darwin x86_64
192 # which by convention does not have it.
193 ifeq ($(OS_NCASE
),darwin
)
194 ifneq ($(CPU
),x86_64
)
195 DEPS_INSTALL_DIR
:=$(DEPS_INSTALL_DIR
)_
$(CPU
)
198 DEPS_INSTALL_DIR
:=$(DEPS_INSTALL_DIR
)_
$(CPU
)
202 # Set the LIBDIR, an empty string when not found.
203 LIBDIR
:=$(wildcard ..
/lib
/${OS_NCASE}_
${CPU})
205 LIBDIR
:=$(wildcard ..
/lib
/${OS_NCASE}_
${CPU}_glibc_228
)
208 LIBDIR
:=$(wildcard ..
/lib
/${OS_NCASE})
211 # Find the newest Python version bundled in `LIBDIR`.
213 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
215 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
217 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
219 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
221 ifeq (, $(wildcard $(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)))
229 # Allow to use alternative binary (pypy3, etc)
231 # If not overriden, first try using Python from LIBDIR.
232 PYTHON
:=$(LIBDIR
)/python
/bin
/python
$(PY_LIB_VERSION
)
233 ifeq (, $(wildcard $(PYTHON
)))
234 # If not available, use system python3 or python command.
236 ifeq (, $(shell command
-v
$(PYTHON
)))
240 # Don't generate __pycache__ files in lib folder, they
241 # can interfere with updates.
246 # Use the autopep8 module in ../lib/ (which can be executed via Python directly).
247 # Otherwise the "autopep8" command can be used.
250 AUTOPEP8
:=$(wildcard $(LIBDIR
)/python
/lib
/python
$(PY_LIB_VERSION
)/site-packages
/autopep8.py
)
258 # -----------------------------------------------------------------------------
259 # Additional targets for the build configuration
261 # NOTE: These targets can be combined and are applied in reverse order listed here.
262 # So it's important that `bpy` comes before `release` (for example)
263 # `make bpy release` first loads `release` configuration, then `bpy`.
264 # This is important as `bpy` will turn off some settings enabled by release.
266 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
267 BUILD_DIR
:=$(BUILD_DIR
)_bpy
268 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" $(CMAKE_CONFIG_ARGS
)
269 BLENDER_IS_PYTHON_MODULE
:=1
271 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
272 BUILD_DIR
:=$(BUILD_DIR
)_debug
275 ifneq "$(findstring full, $(MAKECMDGOALS))" ""
276 BUILD_DIR
:=$(BUILD_DIR
)_full
277 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake" $(CMAKE_CONFIG_ARGS
)
279 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
280 BUILD_DIR
:=$(BUILD_DIR
)_lite
281 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake" $(CMAKE_CONFIG_ARGS
)
283 ifneq "$(findstring release, $(MAKECMDGOALS))" ""
284 BUILD_DIR
:=$(BUILD_DIR
)_release
285 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_release.cmake" $(CMAKE_CONFIG_ARGS
)
287 ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
288 BUILD_DIR
:=$(BUILD_DIR
)_cycles
289 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake" $(CMAKE_CONFIG_ARGS
)
291 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
292 BUILD_DIR
:=$(BUILD_DIR
)_headless
293 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake" $(CMAKE_CONFIG_ARGS
)
296 ifneq "$(findstring developer, $(MAKECMDGOALS))" ""
297 CMAKE_CONFIG_ARGS
:=-C
"$(BLENDER_DIR)/build_files/cmake/config/blender_developer.cmake" $(CMAKE_CONFIG_ARGS
)
300 ifneq "$(findstring ccache, $(MAKECMDGOALS))" ""
301 CMAKE_CONFIG_ARGS
:=-DWITH_COMPILER_CCACHE
=YES
$(CMAKE_CONFIG_ARGS
)
304 # -----------------------------------------------------------------------------
307 ifneq "$(findstring ninja, $(MAKECMDGOALS))" ""
308 CMAKE_CONFIG_ARGS
:=$(CMAKE_CONFIG_ARGS
) -G Ninja
310 DEPS_BUILD_COMMAND
:=ninja
312 ifneq ("$(wildcard $(BUILD_DIR)/build.ninja)","")
315 BUILD_COMMAND
:=make
-s
318 ifneq ("$(wildcard $(DEPS_BUILD_DIR)/build.ninja)","")
319 DEPS_BUILD_COMMAND
:=ninja
322 DEPS_BUILD_COMMAND
:=make
-s
324 DEPS_BUILD_COMMAND
:="$(BLENDER_DIR)/build_files/build_environment/linux/make_deps_wrapper.sh" -s
329 # -----------------------------------------------------------------------------
330 # Blender binary path
332 # Allow passing in own BLENDER_BIN so developers who don't
333 # use the default build path can still use utility helpers.
335 BLENDER_BIN?
="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
336 BLENDER_BIN_DIR?
="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
338 BLENDER_BIN?
="$(BUILD_DIR)/bin/blender"
339 BLENDER_BIN_DIR?
="$(BUILD_DIR)/bin"
343 # -----------------------------------------------------------------------------
344 # Get the number of cores for threaded build
348 NPROCS
:=$(shell nproc
)
351 NPROCS
:=$(shell getconf NPROCESSORS_ONLN
)
353 ifneq (,$(filter $(OS
),Darwin FreeBSD
))
354 NPROCS
:=$(shell sysctl
-n hw.ncpu
)
359 # -----------------------------------------------------------------------------
360 # Macro for configuring cmake
362 CMAKE_CONFIG
= cmake
$(CMAKE_CONFIG_ARGS
) \
365 -DCMAKE_BUILD_TYPE_INIT
:STRING
=$(BUILD_TYPE
)
368 # -----------------------------------------------------------------------------
369 # Tool for 'make config'
373 CMAKE_CONFIG_TOOL
= cmake-gui
375 CMAKE_CONFIG_TOOL
= ccmake
379 # -----------------------------------------------------------------------------
383 @echo Configuring Blender in
\"$(BUILD_DIR
)\" ...
385 # # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
386 # # $(CMAKE_CONFIG); \
389 # # do this always incase of failed initial build, could be smarter here...
393 @echo Building Blender ...
394 $(BUILD_COMMAND
) -C
"$(BUILD_DIR)" -j
$(NPROCS
) install
396 @echo Edit build configuration with
: \"$(BUILD_DIR
)/CMakeCache.txt
\" run make again to rebuild.
397 @if
test -z
"$(BLENDER_IS_PYTHON_MODULE)"; then \
398 echo Blender successfully built
, run from
: $(BLENDER_BIN
); \
400 echo Blender successfully built
as a Python module
, \"bpy
\" can be imported from
: $(BLENDER_BIN_DIR
); \
415 # -----------------------------------------------------------------------------
417 DEPS_TARGET
= install
418 ifneq "$(findstring clean, $(MAKECMDGOALS))" ""
424 @echo Configuring dependencies in
\"$(DEPS_BUILD_DIR
)\", install to
\"$(DEPS_INSTALL_DIR
)\"
426 @cmake
-H
"$(DEPS_SOURCE_DIR)" \
427 -B
"$(DEPS_BUILD_DIR)" \
428 -DHARVEST_TARGET
=$(DEPS_INSTALL_DIR
)
431 @echo Building dependencies ...
432 $(DEPS_BUILD_COMMAND
) -C
"$(DEPS_BUILD_DIR)" -j
$(NPROCS
) $(DEPS_TARGET
)
434 @echo Dependencies successfully built and installed to
$(DEPS_INSTALL_DIR
).
437 # -----------------------------------------------------------------------------
438 # Configuration (save some cd'ing around)
440 $(CMAKE_CONFIG_TOOL
) "$(BUILD_DIR)"
443 # -----------------------------------------------------------------------------
444 # Help for build targets
449 # -----------------------------------------------------------------------------
453 package_archive
: .FORCE
454 make
-C
"$(BUILD_DIR)" -s package_archive
455 @echo archive in
"$(BUILD_DIR)/release"
458 # -----------------------------------------------------------------------------
462 @
$(PYTHON
) .
/build_files
/utils
/make_test.py
"$(BUILD_DIR)"
465 # -----------------------------------------------------------------------------
469 project_qtcreator
: .FORCE
470 $(PYTHON
) build_files
/cmake
/cmake_qtcreator_project.py
--build-dir
"$(BUILD_DIR)"
472 project_netbeans
: .FORCE
473 $(PYTHON
) build_files
/cmake
/cmake_netbeans_project.py
"$(BUILD_DIR)"
475 project_eclipse
: .FORCE
476 cmake
-G
"Eclipse CDT4 - Unix Makefiles" -H
"$(BLENDER_DIR)" -B
"$(BUILD_DIR)"
479 # -----------------------------------------------------------------------------
483 check_cppcheck
: .FORCE
485 @cd
"$(BUILD_DIR)" ; \
487 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
488 "$(BLENDER_DIR)/check_cppcheck.txt"
489 @echo
"written: check_cppcheck.txt"
491 check_struct_comments
: .FORCE
493 @cd
"$(BUILD_DIR)" ; \
495 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang.py" \
496 --checks
=struct_comments
--match
=".*" --jobs
=$(NPROCS
)
498 check_clang_array
: .FORCE
500 @cd
"$(BUILD_DIR)" ; \
501 $(PYTHON
) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
504 @
$(PYTHON
) "$(BLENDER_DIR)/tools/check_source/check_mypy.py"
506 check_docs_file_structure
: .FORCE
507 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
508 "$(BLENDER_DIR)/tools/check_docs/check_docs_code_layout.py"
510 check_spelling_py
: .FORCE
511 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
512 "$(BLENDER_DIR)/tools/check_source/check_spelling.py" \
513 --cache-file
=$(CHECK_SPELLING_CACHE
) \
514 --match
=".*\.(py)$$" \
515 "$(BLENDER_DIR)/scripts" \
516 "$(BLENDER_DIR)/source" \
517 "$(BLENDER_DIR)/tools"
519 check_spelling_c
: .FORCE
520 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
521 "$(BLENDER_DIR)/tools/check_source/check_spelling.py" \
522 --cache-file
=$(CHECK_SPELLING_CACHE
) \
523 --match
=".*\.(c|cc|cpp|cxx|h|hh|hpp|hxx|inl|m|mm)$$" \
524 "$(BLENDER_DIR)/source" \
525 "$(BLENDER_DIR)/intern/cycles" \
526 "$(BLENDER_DIR)/intern/guardedalloc" \
527 "$(BLENDER_DIR)/intern/ghost"
529 check_spelling_shaders
: .FORCE
530 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
531 "$(BLENDER_DIR)/tools/check_source/check_spelling.py" \
532 --cache-file
=$(CHECK_SPELLING_CACHE
) \
533 --match
=".*\.(osl|metal|msl|glsl)$$" \
534 "$(BLENDER_DIR)/intern/" \
535 "$(BLENDER_DIR)/source/"
537 check_descriptions
: .FORCE
538 @
$(BLENDER_BIN
) --background
-noaudio
--factory-startup
--python \
539 "$(BLENDER_DIR)/tools/check_source/check_descriptions.py"
541 check_deprecated
: .FORCE
542 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
543 tools
/check_source
/check_deprecated.py
545 check_licenses
: .FORCE
546 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
547 "$(BLENDER_DIR)/tools/check_source/check_licenses.py" \
548 "--show-headers=$(SHOW_HEADERS)"
551 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
555 @PYTHONIOENCODING
=utf_8
$(PYTHON
) \
556 tools
/check_source
/check_cmake_consistency.py
559 # -----------------------------------------------------------------------------
563 source_archive
: .FORCE
564 @
$(PYTHON
) .
/build_files
/utils
/make_source_archive.py
566 source_archive_complete
: .FORCE
568 -S
"$(BLENDER_DIR)/build_files/build_environment" -B
"$(BUILD_DIR)/source_archive" \
569 -DCMAKE_BUILD_TYPE_INIT
:STRING
=$(BUILD_TYPE
) -DPACKAGE_USE_UPSTREAM_SOURCES
=OFF
570 # This assumes CMake is still using a default `PACKAGE_DIR` variable:
571 @
$(PYTHON
) .
/build_files
/utils
/make_source_archive.py
--include-packages
"$(BUILD_DIR)/source_archive/packages"
574 @BLENDER_BIN
=$(BLENDER_BIN
) "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
575 "$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
576 "$(BLENDER_DIR)/release/datafiles/alert_icons_update.py"
579 @BLENDER_BIN
=$(BLENDER_BIN
) \
580 "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
583 @
$(PYTHON
) .
/build_files
/utils
/make_update.py
586 @
$(PYTHON
) .
/build_files
/utils
/make_update.py
--no-libraries
589 @PATH
="${LIBDIR}/llvm/bin/:$(PATH)" $(PYTHON
) tools
/utils_maintenance
/clang_format_paths.py
$(PATHS
)
590 @
$(PYTHON
) tools
/utils_maintenance
/autopep8_format_paths.py
--autopep8-command
="$(AUTOPEP8)" $(PATHS
)
593 # -----------------------------------------------------------------------------
597 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
599 @ASAN_OPTIONS
=halt_on_error
=0:${ASAN_OPTIONS} \
601 --background
-noaudio
--factory-startup \
602 --python doc
/python_api
/sphinx_doc_gen.py
603 @sphinx-build
-b html
-j
$(NPROCS
) doc
/python_api
/sphinx-in doc
/python_api
/sphinx-out
604 @echo
"docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'"
607 @cd doc
/doxygen
; doxygen Doxyfile
608 @echo
"docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
612 --background
-noaudio
--factory-startup \
613 --python doc
/blender_file_format
/BlendFileDnaExporter_25.py
614 @echo
"docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
617 @
$(PYTHON
) doc
/manpage
/blender
.1.py
--blender
="$(BLENDER_BIN)" --output
=blender
.1 --verbose
619 help_features
: .FORCE
620 @
$(PYTHON
) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR
)"/CMakeLists.txt"
623 $(BUILD_COMMAND
) -C
"$(BUILD_DIR)" clean