1 # -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
4 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
20 # ##### END GPL LICENSE BLOCK #####
22 # This Makefile does an out-of-source CMake build in ../build_`OS`_`CPU`
25 # This is for users who like to configure & build blender with a single command.
30 OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
31 # CPU:=$(shell uname -m) # UNUSED
34 # Source and Build DIR's
35 BLENDER_DIR:=$(shell pwd -P)
38 ifndef BUILD_CMAKE_ARGS
43 BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build_$(OS_NCASE)
47 # -----------------------------------------------------------------------------
48 # additional targets for the build configuration
50 # support 'make debug'
51 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
52 BUILD_DIR:=$(BUILD_DIR)_debug
55 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
56 BUILD_DIR:=$(BUILD_DIR)_lite
57 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake
59 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
60 BUILD_DIR:=$(BUILD_DIR)_bpy
61 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake
63 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
64 BUILD_DIR:=$(BUILD_DIR)_bpy
65 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake
69 # -----------------------------------------------------------------------------
70 # Get the number of cores for threaded build
73 NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
76 NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3)
79 NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
82 NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
86 # -----------------------------------------------------------------------------
87 # Macro for configuring cmake
89 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
92 -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
95 # -----------------------------------------------------------------------------
96 # Tool for 'make config'
100 CMAKE_CONFIG_TOOL = cmake-gui
102 CMAKE_CONFIG_TOOL = ccmake
106 # -----------------------------------------------------------------------------
110 @echo Configuring Blender ...
112 # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
116 # do this always incase of failed initial build, could be smarter here...
120 @echo Building Blender ...
121 $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install
123 @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
124 @echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
133 # -----------------------------------------------------------------------------
134 # Configuration (save some cd'ing around)
136 $(CMAKE_CONFIG_TOOL) $(BUILD_DIR)
139 # -----------------------------------------------------------------------------
140 # Help for build targets
143 @echo "Convenience targets provided for building blender, (multiple at once can be used)"
144 @echo " * debug - build a debug binary"
145 @echo " * lite - disable non essential features for a smaller binary and faster build"
146 @echo " * headless - build without an interface (renderfarm or server automation)"
147 @echo " * bpy - build as a python module which can be loaded from python directly"
149 @echo " * config - run cmake configuration tool to set build options"
151 @echo " Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
152 @echo " Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments."
155 @echo "Project Files for IDE's"
156 @echo " * project_qtcreator - QtCreator Project Files"
157 @echo " * project_netbeans - NetBeans Project Files"
158 @echo " * project_eclipse - Eclipse CDT4 Project Files"
160 @echo "Package Targets"
161 @echo " * package_debian - build a debian package"
162 @echo " * package_pacman - build an arch linux pacmanpackage"
163 @echo " * package_archive - build an archive package"
165 @echo "Testing Targets (not associated with building blender)"
166 @echo " * test - run ctest, currently tests import/export, operator execution and that python modules load"
167 @echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions"
168 @echo " * test_pep8 - checks all python script are pep8 which are tagged to use the stricter formatting"
169 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
170 @echo " * test_style - checks C/C++ conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle"
172 @echo "Static Source Code Checking (not associated with building blender)"
173 @echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
174 @echo " * check_splint - run blenders source through splint (C only)"
175 @echo " * check_sparse - run blenders source through sparse (C only)"
176 @echo " * check_spelling_c - check for spelling errors (C/C++ only)"
177 @echo " * check_spelling_py - check for spelling errors (Python only)"
179 @echo "Documentation Targets (not associated with building blender)"
180 @echo " * doc_py - generate sphinx python api docs"
181 @echo " * doc_doxy - generate doxygen C/C++ docs"
182 @echo " * doc_dna - generate blender file format reference"
183 @echo " * doc_man - generate manpage"
186 # -----------------------------------------------------------------------------
190 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
193 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
196 make -C $(BUILD_DIR) -s package_archive
197 @echo archive in "$(BUILD_DIR)/release"
200 # -----------------------------------------------------------------------------
204 cd $(BUILD_DIR) ; ctest . --output-on-failure
206 # run pep8 check check on scripts we distribute.
208 python3.2 source/tests/pep8.py > test_pep8.log 2>&1
209 @echo "written: test_pep8.log"
211 # run some checks on our cmakefiles.
213 python3.2 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
214 @echo "written: test_cmake_consistency.log"
216 # run deprecation tests, see if we have anything to remove.
218 python3.2 source/tests/check_deprecated.py
221 # run our own checks on C/C++ style
222 PYTHONIOENCODING=utf_8 python3.2 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator --no-length-check
224 # -----------------------------------------------------------------------------
229 python3.2 build_files/cmake/cmake_qtcreator_project.py $(BUILD_DIR)
232 python3.2 build_files/cmake/cmake_netbeans_project.py $(BUILD_DIR)
235 cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR)
238 # -----------------------------------------------------------------------------
244 cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py
248 cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py
252 cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py
255 cd $(BUILD_DIR) ; PYTHONIOENCODING=utf_8 python3.2 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/release/scripts
258 cd $(BUILD_DIR) ; PYTHONIOENCODING=utf_8 python3.2 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/source
260 # -----------------------------------------------------------------------------
264 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
266 $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py
267 cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out
268 @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
271 cd doc/doxygen; doxygen Doxyfile
272 @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'"
275 $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py
276 @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
279 python3.2 doc/manpage/blender.1.py $(BUILD_DIR)/bin/blender
283 $(MAKE) -C $(BUILD_DIR) clean