Merging r41037 through r41092 from trunk into soc-2011-tomato
[blender.git] / GNUmakefile
1 # -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
2 # vim: tabstop=8
3 # $Id$
4 #
5 # ##### BEGIN GPL LICENSE BLOCK #####
6 #
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.
11 #
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.
16 #
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.
20 #
21 # ##### END GPL LICENSE BLOCK #####
22
23 # This Makefile does an out-of-source CMake build in ../build/`OS`_`CPU`
24 # eg:
25 #   ../build/Linux_i386
26 # This is for users who like to configure & build blender with a single command.
27
28
29 # System Vars
30 OS:=$(shell uname -s)
31 OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
32 # CPU:=$(shell uname -m)  # UNUSED
33
34
35 # Source and Build DIR's
36 BLENDER_DIR:=$(shell pwd -P)
37 BUILD_TYPE:=Release
38 BUILD_CMAKE_ARGS:=
39
40 ifndef BUILD_DIR
41         BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build/$(OS_NCASE)
42 endif
43
44
45 # -----------------------------------------------------------------------------
46 # additional targets for the build configuration
47
48 # support 'make debug'
49 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
50         BUILD_DIR:=$(BUILD_DIR)_debug
51         BUILD_TYPE:=Debug
52 endif
53 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
54         BUILD_DIR:=$(BUILD_DIR)_lite
55         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake
56 endif
57 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
58         BUILD_DIR:=$(BUILD_DIR)_bpy
59         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake
60 endif
61 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
62         BUILD_DIR:=$(BUILD_DIR)_bpy
63         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake
64 endif
65
66
67 # -----------------------------------------------------------------------------
68 # Get the number of cores for threaded build
69 NPROCS:=1
70 ifeq ($(OS), Linux)
71         NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
72 endif
73 ifeq ($(OS), Darwin)
74         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3)
75 endif
76 ifeq ($(OS), FreeBSD)
77         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
78 endif
79 ifeq ($(OS), NetBSD)
80         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
81 endif
82
83
84 # -----------------------------------------------------------------------------
85 # Macro for configuring cmake
86
87 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
88                      -H$(BLENDER_DIR) \
89                      -B$(BUILD_DIR) \
90                      -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
91
92
93 # -----------------------------------------------------------------------------
94 # Build Blender
95 all:
96         @echo
97         @echo Configuring Blender ...
98
99         if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
100                 $(CMAKE_CONFIG); \
101         fi
102
103         @echo
104         @echo Building Blender ...
105         $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install
106         @echo
107         @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
108         @echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
109         @echo
110
111 debug: all
112 lite: all
113 headless: all
114 bpy: all
115
116 # -----------------------------------------------------------------------------
117 # Helo for build targets
118 help:
119         @echo ""
120         @echo "Convenience targets provided for building blender, (multiple at once can be used)"
121         @echo "  * debug     - build a debug binary"
122         @echo "  * lite      - disable non essential features for a smaller binary and faster build"
123         @echo "  * headless  - build without an interface (renderfarm or server automation)"
124         @echo "  * bpy       - build as a python module which can be loaded from python directly"
125         @echo ""
126         @echo "  Note, passing the argument 'BUILD_DIR=path' when calling make will override the default build dir."
127         @echo ""
128         @echo ""
129         @echo "Project Files for IDE's"
130         @echo "  * project_qtcreator - QtCreator Project Files"
131         @echo "  * project_netbeans  - NetBeans Project Files"
132         @echo "  * project_eclipse   - Eclipse CDT4 Project Files"
133         @echo ""
134         @echo "Package Targets"
135         @echo "  * package_debian  - build a debian package"
136         @echo "  * package_pacman  - build an arch linux pacmanpackage"
137         @echo "  * package_archive - build an archive package"
138         @echo ""
139         @echo "Other Targets (not assosiated with building blender)"
140         @echo "  * translations  - update blenders translation files in po/"
141         @echo ""
142         @echo "Testing Targets (not assosiated with building blender)"
143         @echo "  * test            - run ctest, currently tests import/export, operator execution and that python modules load"
144         @echo "  * test_cmake      - runs our own cmake file checker which detects errors in the cmake file list definitions"
145         @echo "  * test_pep8       - checks all python script are pep8 which are tagged to use the stricter formatting"
146         @echo "  * test_deprecated - checks for deprecation tags in our code which may need to be removed"
147         @echo ""
148         @echo "Static Source Code Checking (not assosiated with building blender)"
149         @echo "  * check_cppcheck  - run blender source through cppcheck (C & C++)"
150         @echo "  * check_splint    - run blenders source through splint (C only)"
151         @echo "  * check_sparse    - run blenders source through sparse (C only)"
152         @echo ""
153         @echo "Documentation Targets (not assosiated with building blender)"
154         @echo "  * doc_py   - generate sphinx python api docs"
155         @echo "  * doc_dna  - generate blender file format reference"
156         @echo "  * doc_man  - generate manpage"
157         @echo ""
158
159 # -----------------------------------------------------------------------------
160 # Packages
161 #
162 package_debian:
163         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
164
165 package_pacman:
166         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
167
168 package_archive:
169         make -C $(BUILD_DIR) -s package_archive
170         @echo archive in "$(BUILD_DIR)/release"
171
172
173 # -----------------------------------------------------------------------------
174 # Other Targets
175 #
176 translations:
177         $(BUILD_DIR)/bin/blender --background --factory-startup --python po/update_msg.py
178         python3 po/update_pot.py
179         python3 po/update_po.py
180         python3 po/update_mo.py
181
182
183 # -----------------------------------------------------------------------------
184 # Tests
185 #
186 test:
187         cd $(BUILD_DIR) ; ctest . --output-on-failure
188
189 # run pep8 check check on scripts we distribute.
190 test_pep8:
191         python3 source/tests/pep8.py > test_pep8.log 2>&1
192         @echo "written: test_pep8.log"
193
194 # run some checks on our cmakefiles.
195 test_cmake:
196         python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
197         @echo "written: test_cmake_consistency.log"
198
199 # run deprecation tests, see if we have anything to remove.
200 test_deprecated:
201         python3 source/tests/check_deprecated.py
202
203
204 # -----------------------------------------------------------------------------
205 # Project Files
206 #
207
208 project_qtcreator:
209         python3 build_files/cmake/cmake_qtcreator_project.py $(BUILD_DIR)
210
211 project_netbeans:
212         python3 build_files/cmake/cmake_netbeans_project.py $(BUILD_DIR)
213
214 project_eclipse:
215         cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR)
216
217
218 # -----------------------------------------------------------------------------
219 # Static Checking
220 #
221
222 check_cppcheck:
223         $(CMAKE_CONFIG)
224         cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py
225
226 check_splint:
227         $(CMAKE_CONFIG)
228         cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py
229
230 check_sparse:
231         $(CMAKE_CONFIG)
232         cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py
233
234
235 # -----------------------------------------------------------------------------
236 # Documentation
237 #
238
239 # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation.
240 doc_py:
241         $(BUILD_DIR)/bin/blender --background --factory-startup --python doc/python_api/sphinx_doc_gen.py
242         cd doc/python_api ; sphinx-build -n -b html sphinx-in sphinx-out
243         @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'"
244
245 doc_dna:
246         $(BUILD_DIR)/bin/blender --background --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py
247         @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
248
249 doc_man:
250         python3 doc/manpage/blender.1.py $(BUILD_DIR)/bin/blender
251
252
253 clean:
254         $(MAKE) -C $(BUILD_DIR) clean
255
256 .PHONY: all