buildbot: point python to a symbolic link. Helps when updating libs is happening.
[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_DIR:=$(shell dirname $(BLENDER_DIR))/build/$(OS_NCASE)
38 BUILD_TYPE:=Release
39 BUILD_CMAKE_ARGS:=
40
41
42 # -----------------------------------------------------------------------------
43 # additional targets for the build configuration
44
45 # support 'make debug'
46 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
47         BUILD_DIR:=$(BUILD_DIR)_debug
48         BUILD_TYPE:=Debug
49 endif
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
53 endif
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
57 endif
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
61 endif
62
63
64 # -----------------------------------------------------------------------------
65 # Get the number of cores for threaded build
66 NPROCS:=1
67 ifeq ($(OS), Linux)
68         NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
69 endif
70 ifeq ($(OS), Darwin)
71         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3)
72 endif
73 ifeq ($(OS), FreeBSD)
74         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
75 endif
76 ifeq ($(OS), NetBSD)
77         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
78 endif
79
80
81 # -----------------------------------------------------------------------------
82 # Macro for configuring cmake
83
84 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
85                      -H$(BLENDER_DIR) \
86                      -B$(BUILD_DIR) \
87                      -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
88
89
90 # -----------------------------------------------------------------------------
91 # Build Blender
92 all:
93         @echo
94         @echo Configuring Blender ...
95
96         if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
97                 $(CMAKE_CONFIG); \
98         fi
99
100         @echo
101         @echo Building Blender ...
102         $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install
103         @echo
104         @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
105         @echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
106         @echo
107
108 debug: all
109 lite: all
110 headless: all
111 bpy: all
112
113 # -----------------------------------------------------------------------------
114 # Helo for build targets
115 help:
116         @echo ""
117         @echo "Convenience targets provided for building blender, (multiple at once can be used)"
118         @echo "  * debug     - build a debug binary"
119         @echo "  * lite      - disable non essential features for a smaller binary and faster build"
120         @echo "  * headless  - build without an interface (renderfarm or server automation)"
121         @echo "  * bpy       - build as a python module which can be loaded from python directly"
122         @echo ""
123         @echo "Project Files for IDE's"
124         @echo "  * project_qtcreator - QtCreator Project Files"
125         @echo "  * project_netbeans  - NetBeans Project Files"
126         @echo "  * project_eclipse   - Eclipse CDT4 Project Files"
127         @echo ""
128         @echo "Package Targets"
129         @echo "  * package_debian  - build a debian package"
130         @echo "  * package_pacman  - build an arch linux pacmanpackage"
131         @echo "  * package_archive - build an archive package"
132         @echo ""
133         @echo "Other Targets"
134         @echo "  * translations  - update blenders translation files in po/"
135         # TODO, doxygen and sphinx docs
136         @echo ""
137         @echo "Testing Targets (not assosiated with building blender)"
138         @echo "  * test            - run ctest, currently tests import/export, operator execution and that python modules load"
139         @echo "  * test_cmake      - runs our own cmake file checker which detects errors in the cmake file list definitions"
140         @echo "  * test_pep8       - checks all python script are pep8 which are tagged to use the stricter formatting"
141         @echo "  * test_deprecated - checks for deprecation tags in our code which may need to be removed"
142         @echo ""
143         @echo "Static Source Code Checking (not assosiated with building blender)"
144         @echo "  * check_cppcheck  - run blender source through cppcheck (C & C++)"
145         @echo "  * check_splint    - run blenders source through splint (C only)"
146         @echo "  * check_sparse    - run blenders source through sparse (C only)"
147         @echo ""
148
149 # -----------------------------------------------------------------------------
150 # Packages
151 #
152 package_debian:
153         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
154
155 package_pacman:
156         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
157
158 package_archive:
159         make -C $(BUILD_DIR) -s package_archive
160         @echo archive in "$(BUILD_DIR)/release"
161
162
163 # -----------------------------------------------------------------------------
164 # Other Targets
165 #
166 translations:
167         $(BUILD_DIR)/bin/blender --background --python po/update_msg.py
168         python3 po/update_pot.py
169         python3 po/update_po.py
170         python3 po/update_mo.py
171
172
173 # -----------------------------------------------------------------------------
174 # Tests
175 #
176 test:
177         cd $(BUILD_DIR) ; ctest . --output-on-failure
178
179 # run pep8 check check on scripts we distribute.
180 test_pep8:
181         python3 source/tests/pep8.py > test_pep8.log 2>&1
182         @echo "written: test_pep8.log"
183
184 # run some checks on our cmakefiles.
185 test_cmake:
186         python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
187         @echo "written: test_cmake_consistency.log"
188
189 # run deprecation tests, see if we have anything to remove.
190 test_deprecated:
191         python3 source/tests/check_deprecated.py
192
193
194 # -----------------------------------------------------------------------------
195 # Project Files
196 #
197
198 project_qtcreator:
199         python3 build_files/cmake/cmake_qtcreator_project.py $(BUILD_DIR)
200
201 project_netbeans:
202         python3 build_files/cmake/cmake_netbeans_project.py $(BUILD_DIR)
203
204 project_eclipse:
205         cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR)
206
207
208 # -----------------------------------------------------------------------------
209 # Static Checking
210 #
211
212 check_cppcheck:
213         $(CMAKE_CONFIG)
214         cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py
215
216 check_splint:
217         $(CMAKE_CONFIG)
218         cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py
219
220 check_sparse:
221         $(CMAKE_CONFIG)
222         cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py
223
224
225 clean:
226         $(MAKE) -C $(BUILD_DIR) clean
227
228 .PHONY: all