1 # -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
5 # ##### BEGIN GPL LICENSE BLOCK #####
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # ##### END GPL LICENSE BLOCK #####
23 # This Makefile does an out-of-source CMake build in ../build/`OS`_`CPU`
26 # This is for users who like to configure & build blender with a single command.
31 OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
32 # CPU:=$(shell uname -m) # UNUSED
35 # Source and Build DIR's
36 BLENDER_DIR:=$(shell pwd -P)
37 BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build/$(OS_NCASE)
42 # -----------------------------------------------------------------------------
43 # additional targets for the build configuration
45 # support 'make debug'
46 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
47 BUILD_DIR:=$(BUILD_DIR)_debug
50 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
51 BUILD_DIR:=$(BUILD_DIR)_lite
52 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake
54 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
55 BUILD_DIR:=$(BUILD_DIR)_bpy
56 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake
58 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
59 BUILD_DIR:=$(BUILD_DIR)_bpy
60 BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake
64 # -----------------------------------------------------------------------------
65 # Get the number of cores for threaded build
68 NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
71 NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3)
74 NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
77 NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
81 # -----------------------------------------------------------------------------
82 # Helo for build targets
85 @echo "Convenience targets provided for building blender, (multiple at once can be used)"
86 @echo " * debug - build a debug binary"
87 @echo " * lite - disable non essential features for a smaller binary and faster build"
88 @echo " * headless - build without an interface (renderfarm or server automation)"
89 @echo " * bpy - build as a python module which can be loaded from python directly"
91 @echo "Project Files for IDE's"
92 @echo " * project_qtcreator - QtCreator Project Files"
93 @echo " * project_netbeans - NetBeans Project Files"
94 @echo " * project_eclipse - Eclipse CDT4 Project Files"
96 @echo "Package Targets"
97 @echo " * package_debian - build a debian package"
98 @echo " * package_pacman - build an arch linux pacmanpackage"
99 @echo " * package_archive - build an archive package"
101 @echo "Testing Targets (not assosiated with building blender)"
102 @echo " * test - run ctest, currently tests import/export, operator execution and that python modules load"
103 @echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions"
104 @echo " * test_pep8 - checks all python script are pep8 which are tagged to use the stricter formatting"
105 @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed"
109 # -----------------------------------------------------------------------------
113 @echo Configuring Blender ...
115 if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
116 cmake $(BUILD_CMAKE_ARGS) -H$(BLENDER_DIR) -B$(BUILD_DIR) -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE); \
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 # -----------------------------------------------------------------------------
137 cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
140 cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
143 make -C $(BUILD_DIR) -s package_archive
144 @echo archive in "$(BUILD_DIR)/release"
147 # -----------------------------------------------------------------------------
151 cd $(BUILD_DIR) ; ctest . --output-on-failure
153 # run pep8 check check on scripts we distribute.
155 python3 source/tests/pep8.py > test_pep8.log 2>&1
156 @echo "written: test_pep8.log"
158 # run some checks on our cmakefiles.
160 python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
161 @echo "written: test_cmake_consistency.log"
163 # run deprecation tests, see if we have anything to remove.
165 python3 source/tests/check_deprecated.py
168 # -----------------------------------------------------------------------------
173 python3 build_files/cmake/cmake_qtcreator_project.py $(BUILD_DIR)
176 python3 build_files/cmake/cmake_netbeans_project.py $(BUILD_DIR)
179 cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR)
183 $(MAKE) -C $(BUILD_DIR) clean