Makefile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=wrapper
  9. PKG_VERSION:=1
  10. include $(INCLUDE_DIR)/toolchain-build.mk
  11. # 1: args
  12. define toolchain_util
  13. $(strip $(SCRIPT_DIR)/ext-toolchain.sh --toolchain $(CONFIG_TOOLCHAIN_ROOT) \
  14. --cflags $(CONFIG_TARGET_OPTIMIZATION) \
  15. --cflags "$(if $(call qstrip,$(CONFIG_TOOLCHAIN_LIBC)),-m$(call qstrip,$(CONFIG_TOOLCHAIN_LIBC))) $(if $(CONFIG_SOFT_FLOAT),-msoft-float)" \
  16. --cflags "$(patsubst ./%,-I$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))" \
  17. --cflags "$(patsubst ./%,-L$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))" \
  18. $(1))
  19. endef
  20. # 1: config symbol
  21. # 2: feature
  22. define toolchain_test
  23. $$(if $$($(1)), \
  24. @echo -n "Testing external toolchain for $(2) support ... "; \
  25. if $(call toolchain_util,--test "$(2)"); then \
  26. echo "ok"; exit 0; \
  27. else \
  28. echo "failed"; \
  29. echo "ERROR: $(1) is enabled but the external toolchain does not support it"; \
  30. exit 1; \
  31. fi)
  32. endef
  33. define Host/SetToolchainInfo
  34. if [ -f $(CONFIG_TOOLCHAIN_ROOT)/info.mk ]; then \
  35. $(CP) $(CONFIG_TOOLCHAIN_ROOT)/info.mk $(TOOLCHAIN_DIR)/; \
  36. else \
  37. $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(CONFIG_GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk; \
  38. fi
  39. endef
  40. define Host/Prepare
  41. $(call toolchain_test,CONFIG_SOFT_FLOAT,softfloat)
  42. $(call toolchain_test,CONFIG_IPV6,ipv6)
  43. $(call toolchain_test,CONFIG_NLS,wchar)
  44. $(call toolchain_test,CONFIG_PACKAGE_libpthread,threads)
  45. endef
  46. define Host/Configure
  47. endef
  48. define Host/Compile
  49. endef
  50. define Host/Install
  51. $(call toolchain_util,--wrap "$(TOOLCHAIN_DIR)/bin")
  52. $(call Host/SetToolchainInfo)
  53. endef
  54. define Host/Clean
  55. rm -rf $(TOOLCHAIN_DIR)/bin
  56. rm -rf $(TOOLCHAIN_DIR)/info.mk
  57. endef
  58. $(eval $(call HostBuild))