leds: support oneshot as well as timer triggers
[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:=$(STAGING_DIR_HOST)/bin/ccache
22   CMAKE_C_COMPILER:=$(CCACHE)
23   CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
24   CMAKE_CXX_COMPILER:=$(CCACHE)
25   CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
26 endif
27 CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
28 CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
29 CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
30
31 CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
32 CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOST)
33 CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
34
35 define Build/Configure/Default
36         (cd $(PKG_BUILD_DIR); \
37                 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
38                 CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
39                 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
40                 cmake \
41                         -DCMAKE_SYSTEM_NAME=Linux \
42                         -DCMAKE_SYSTEM_VERSION=1 \
43                         -DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \
44                         -DCMAKE_BUILD_TYPE=Release \
45                         -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
46                         -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
47                         -DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
48                         -DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
49                         -DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
50                         -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
51                         -DCMAKE_ASM_COMPILER="$(CMAKE_C_COMPILER)" \
52                         -DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
53                         -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
54                         -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
55                         -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
56                         -DCMAKE_AR="$(CMAKE_AR)" \
57                         -DCMAKE_NM="$(CMAKE_NM)" \
58                         -DCMAKE_RANLIB="$(CMAKE_RANLIB)" \
59                         -DCMAKE_FIND_ROOT_PATH="$(CMAKE_FIND_ROOT_PATH)" \
60                         -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
61                         -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
62                         -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
63                         -DCMAKE_STRIP=: \
64                         -DCMAKE_INSTALL_PREFIX=/usr \
65                         -DDL_LIBRARY=$(STAGING_DIR) \
66                         -DCMAKE_PREFIX_PATH=$(STAGING_DIR) \
67                         -DCMAKE_SKIP_RPATH=TRUE  \
68                         $(CMAKE_OPTIONS) \
69                 $(CMAKE_SOURCE_DIR) \
70         )
71 endef
72
73 define Build/InstallDev/cmake
74         $(INSTALL_DIR) $(1)
75         $(CP) $(PKG_INSTALL_DIR)/* $(1)/
76 endef
77
78 Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))
79
80 define Host/Configure/Default
81         (cd $(HOST_BUILD_DIR); \
82                 CFLAGS="$(HOST_CFLAGS)" \
83                 CXXFLAGS="$(HOST_CFLAGS)" \
84                 LDFLAGS="$(HOST_LDFLAGS)" \
85                 cmake \
86                         -DCMAKE_BUILD_TYPE=Release \
87                         -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
88                         -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
89                         -DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
90                         -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
91                         -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
92                         -DCMAKE_FIND_ROOT_PATH="$(CMAKE_HOST_FIND_ROOT_PATH)" \
93                         -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
94                         -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
95                         -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
96                         -DCMAKE_STRIP=: \
97                         -DCMAKE_INSTALL_PREFIX=$(HOST_BUILD_PREFIX) \
98                         -DCMAKE_PREFIX_PATH=$(HOST_BUILD_PREFIX) \
99                         -DCMAKE_SKIP_RPATH=TRUE  \
100                         $(CMAKE_HOST_OPTIONS) \
101                 $(CMAKE_SOURCE_DIR) \
102         )
103 endef