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