kernel: update 4.1 to 4.1.4
[openwrt/openwrt.git] / include / cmake.mk
1 PKG_INSTALL:=1
2
3 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
4 MAKE_FLAGS+=VERBOSE=1
5 endif
6
7 CMAKE_SOURCE_DIR:=.
8
9 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
10 cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1)
11 else
12 cmake_tool=$(shell which $(1))
13 endif
14
15 ifeq ($(CONFIG_CCACHE),)
16 CMAKE_C_COMPILER:=$(call cmake_tool,$(TARGET_CC))
17 CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX))
18 CMAKE_C_COMPILER_ARG1:=
19 CMAKE_CXX_COMPILER_ARG1:=
20 else
21 CCACHE:=$(shell which ccache)
22 ifeq ($(CCACHE),)
23 CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
24 endif
25 CMAKE_C_COMPILER:=$(CCACHE)
26 CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
27 CMAKE_CXX_COMPILER:=$(CCACHE)
28 CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
29 endif
30 CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
31 CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
32 CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
33
34 CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR);$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
35 CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR_HOST)
36 CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
37
38 define Build/Configure/Default
39 (cd $(PKG_BUILD_DIR); \
40 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
41 CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
42 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
43 cmake \
44 -DCMAKE_SYSTEM_NAME=Linux \
45 -DCMAKE_SYSTEM_VERSION=1 \
46 -DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \
47 -DCMAKE_BUILD_TYPE=Release \
48 -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
49 -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
50 -DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
51 -DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
52 -DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
53 -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
54 -DCMAKE_ASM_COMPILER="$(CMAKE_C_COMPILER)" \
55 -DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
56 -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
57 -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
58 -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
59 -DCMAKE_AR="$(CMAKE_AR)" \
60 -DCMAKE_NM="$(CMAKE_NM)" \
61 -DCMAKE_RANLIB="$(CMAKE_RANLIB)" \
62 -DCMAKE_FIND_ROOT_PATH="$(CMAKE_FIND_ROOT_PATH)" \
63 -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
64 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
65 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
66 -DCMAKE_STRIP=: \
67 -DCMAKE_INSTALL_PREFIX=/usr \
68 -DDL_LIBRARY=$(STAGING_DIR) \
69 -DCMAKE_PREFIX_PATH=$(STAGING_DIR) \
70 -DCMAKE_SKIP_RPATH=TRUE \
71 $(CMAKE_OPTIONS) \
72 $(CMAKE_SOURCE_DIR) \
73 )
74 endef
75
76 define Build/InstallDev/cmake
77 $(INSTALL_DIR) $(1)
78 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
79 endef
80
81 Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))
82
83 define Host/Configure/Default
84 (cd $(HOST_BUILD_DIR); \
85 CFLAGS="$(HOST_CFLAGS)" \
86 CXXFLAGS="$(HOST_CFLAGS)" \
87 LDFLAGS="$(HOST_LDFLAGS)" \
88 cmake \
89 -DCMAKE_BUILD_TYPE=Release \
90 -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
91 -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
92 -DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
93 -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
94 -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
95 -DCMAKE_FIND_ROOT_PATH="$(CMAKE_HOST_FIND_ROOT_PATH)" \
96 -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
97 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
98 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
99 -DCMAKE_STRIP=: \
100 -DCMAKE_INSTALL_PREFIX=$(STAGING_DIR_HOST) \
101 -DCMAKE_PREFIX_PATH=$(STAGING_DIR_HOST) \
102 -DCMAKE_SKIP_RPATH=TRUE \
103 $(CMAKE_HOST_OPTIONS) \
104 $(CMAKE_SOURCE_DIR) \
105 )
106 endef