added cmake configureation presets, so on *nix systems you can do...
[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 # support 'make debug'
42 ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
43         BUILD_DIR:=$(BUILD_DIR)_debug
44         BUILD_TYPE:=Debug
45 endif
46 ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
47         BUILD_DIR:=$(BUILD_DIR)_lite
48         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake
49 endif
50 ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
51         BUILD_DIR:=$(BUILD_DIR)_bpy
52         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake
53 endif
54 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
55         BUILD_DIR:=$(BUILD_DIR)_bpy
56         BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake
57 endif
58
59 # Get the number of cores for threaded build
60 NPROCS:=1
61 ifeq ($(OS), Linux)
62         NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
63 endif
64 ifeq ($(OS), Darwin)
65         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3)
66 endif
67 ifeq ($(OS), FreeBSD)
68         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
69 endif
70 ifeq ($(OS), NetBSD)
71         NPROCS:=$(shell sysctl -a | grep "hw.ncpu " | cut -d" " -f3 )
72 endif
73
74
75 # Build Blender
76 all:
77         @echo
78         @echo Configuring Blender ...
79
80         if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
81                 cmake $(BUILD_CMAKE_ARGS) -H$(BLENDER_DIR) -B$(BUILD_DIR) -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE); \
82         fi
83
84         @echo
85         @echo Building Blender ...
86         $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install
87         @echo
88         @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
89         @echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
90         @echo
91
92 debug: all
93 lite: all
94 headless: all
95 bpy: all
96
97 # package types
98 package_debian:
99         cd build_files/package_spec ; DEB_BUILD_OPTIONS="parallel=$(NPROCS)" sh ./build_debian.sh
100
101 package_pacman:
102         cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot
103
104 package_archive:
105         make -C $(BUILD_DIR) -s package_archive
106         @echo archive in "$(BUILD_DIR)/release"
107
108 # forward build targets
109 test:
110         cd $(BUILD_DIR) ; ctest . --output-on-failure
111
112 # run pep8 check check on scripts we distribute.
113 test_pep8:
114         python3 source/tests/pep8.py > test_pep8.log 2>&1
115         @echo "written: test_pep8.log"
116
117 # run some checks on our cmakefiles.
118 test_cmake:
119         python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
120         @echo "written: test_cmake_consistency.log"
121
122 # run deprecation tests, see if we have anything to remove.
123 test_deprecated:
124         python3 source/tests/check_deprecated.py
125
126 clean:
127         $(MAKE) -C $(BUILD_DIR) clean
128
129 .PHONY: all