toolchain/wrapper: fill and reference info.mk in staging_dir ext toolchain
[openwrt/staging/nbd.git] / toolchain / wrapper / Makefile
1 #
2 # Copyright (C) 2012 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=wrapper
11 PKG_VERSION:=1
12
13 include $(INCLUDE_DIR)/toolchain-build.mk
14
15
16 # 1: args
17 define toolchain_util
18 $(strip $(SCRIPT_DIR)/ext-toolchain.sh --toolchain $(CONFIG_TOOLCHAIN_ROOT) \
19 --cflags $(CONFIG_TARGET_OPTIMIZATION) \
20 --cflags "$(if $(call qstrip,$(CONFIG_TOOLCHAIN_LIBC)),-m$(call qstrip,$(CONFIG_TOOLCHAIN_LIBC))) $(if $(CONFIG_SOFT_FLOAT),-msoft-float)" \
21 --cflags "$(patsubst ./%,-I$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))" \
22 --cflags "$(patsubst ./%,-L$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))" \
23 $(1))
24 endef
25
26 # 1: config symbol
27 # 2: feature
28 define toolchain_test
29 $$(if $$($(1)), \
30 @echo -n "Testing external toolchain for $(2) support ... "; \
31 if $(call toolchain_util,--test "$(2)"); then \
32 echo "ok"; exit 0; \
33 else \
34 echo "failed"; \
35 echo "ERROR: $(1) is enabled but the external toolchain does not support it"; \
36 exit 1; \
37 fi)
38 endef
39
40
41 define Host/SetToolchainInfo
42 if [ -f $(CONFIG_TOOLCHAIN_ROOT)/info.mk ]; then \
43 $(CP) $(CONFIG_TOOLCHAIN_ROOT)/info.mk $(TOOLCHAIN_DIR)/; \
44 else \
45 $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(CONFIG_GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk; \
46 fi
47 endef
48
49 define Host/Prepare
50 $(call toolchain_test,CONFIG_SOFT_FLOAT,softfloat)
51 $(call toolchain_test,CONFIG_IPV6,ipv6)
52 $(call toolchain_test,CONFIG_NLS,wchar)
53 $(call toolchain_test,CONFIG_PACKAGE_libpthread,threads)
54 endef
55
56 define Host/Configure
57 endef
58
59 define Host/Compile
60 endef
61
62 define Host/Install
63 $(call toolchain_util,--wrap "$(TOOLCHAIN_DIR)/bin")
64 $(call Host/SetToolchainInfo)
65 endef
66
67 define Host/Clean
68 rm -rf $(TOOLCHAIN_DIR)/bin
69 rm -rf $(TOOLCHAIN_DIR)/info.mk
70 endef
71
72 $(eval $(call HostBuild))