ar71xx: add kernel support for the EnGenius EAP300 v2 board
[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_CROSS)ar)
31 CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_CROSS)ranlib)
32
33 define Build/Configure/Default
34 (cd $(PKG_BUILD_DIR); \
35 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
36 CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
37 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
38 cmake \
39 -DCMAKE_SYSTEM_NAME=Linux \
40 -DCMAKE_SYSTEM_VERSION=1 \
41 -DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \
42 -DCMAKE_BUILD_TYPE=Release \
43 -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
44 -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
45 -DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
46 -DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
47 -DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
48 -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
49 -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
50 -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
51 -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
52 -DCMAKE_AR="$(CMAKE_AR)" \
53 -DCMAKE_RANLIB="$(CMAKE_RANLIB)" \
54 -DCMAKE_FIND_ROOT_PATH="$(STAGING_DIR);$(TOOLCHAIN_DIR)" \
55 -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
56 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
57 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
58 -DCMAKE_STRIP=: \
59 -DCMAKE_INSTALL_PREFIX=/usr \
60 -DDL_LIBRARY=$(STAGING_DIR) \
61 -DCMAKE_PREFIX_PATH=$(STAGING_DIR) \
62 $(CMAKE_OPTIONS) \
63 $(CMAKE_SOURCE_DIR) \
64 )
65 endef
66
67 define Build/InstallDev/cmake
68 $(INSTALL_DIR) $(1)
69 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
70 endef
71
72 Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))