host-build.mk 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #
  2. # Copyright (C) 2006-2009 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
  8. HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
  9. include $(INCLUDE_DIR)/host.mk
  10. include $(INCLUDE_DIR)/unpack.mk
  11. include $(INCLUDE_DIR)/depends.mk
  12. HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
  13. HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
  14. HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
  15. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
  16. override MAKEFLAGS=
  17. include $(INCLUDE_DIR)/download.mk
  18. include $(INCLUDE_DIR)/quilt.mk
  19. Host/Patch:=$(Host/Patch/Default)
  20. ifneq ($(strip $(HOST_UNPACK)),)
  21. define Host/Prepare/Default
  22. $(HOST_UNPACK)
  23. $(Host/Patch)
  24. endef
  25. endif
  26. define Host/Prepare
  27. $(call Host/Prepare/Default)
  28. endef
  29. HOST_CONFIGURE_VARS = \
  30. CPPFLAGS="$(HOST_CFLAGS)" \
  31. LDFLAGS="$(HOST_LDFLAGS)" \
  32. SHELL="$(BASH)"
  33. HOST_CONFIGURE_ARGS = \
  34. --target=$(GNU_HOST_NAME) \
  35. --host=$(GNU_HOST_NAME) \
  36. --build=$(GNU_HOST_NAME) \
  37. --program-prefix="" \
  38. --program-suffix="" \
  39. --prefix=$(STAGING_DIR_HOST) \
  40. --exec-prefix=$(STAGING_DIR_HOST) \
  41. --sysconfdir=$(STAGING_DIR_HOST)/etc \
  42. --localstatedir=$(STAGING_DIR_HOST)/var
  43. HOST_CONFIGURE_CMD = ./configure
  44. define Host/Configure/Default
  45. @(cd $(HOST_BUILD_DIR)/$(3); \
  46. if [ -x configure ]; then \
  47. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
  48. $(2) \
  49. $(HOST_CONFIGURE_CMD) \
  50. $(HOST_CONFIGURE_VARS) \
  51. $(HOST_CONFIGURE_ARGS) \
  52. $(1); \
  53. fi \
  54. )
  55. endef
  56. define Host/Configure
  57. $(call Host/Configure/Default)
  58. endef
  59. define Host/Compile/Default
  60. $(MAKE) -C $(HOST_BUILD_DIR) $(1)
  61. endef
  62. define Host/Compile
  63. $(call Host/Compile/Default)
  64. endef
  65. ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
  66. define HostHost/Autoclean
  67. $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(HOST_STAMP_PREPARED))
  68. $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
  69. endef
  70. endif
  71. define Download/default
  72. FILE:=$(PKG_SOURCE)
  73. URL:=$(PKG_SOURCE_URL)
  74. PROTO:=$(PKG_SOURCE_PROTO)
  75. SUBDIR:=$(PKG_SOURCE_SUBDIR)
  76. VERSION:=$(PKG_SOURCE_VERSION)
  77. MD5SUM:=$(PKG_MD5SUM)
  78. endef
  79. ifndef DUMP
  80. define HostBuild
  81. $(if $(QUILT),$(Host/Quilt))
  82. $(if $(STAMP_PREPARED),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
  83. $(if $(DUMP),,$(call HostHost/Autoclean))
  84. $(HOST_STAMP_PREPARED):
  85. @-rm -rf $(HOST_BUILD_DIR)
  86. @mkdir -p $(HOST_BUILD_DIR)
  87. $(call Host/Prepare)
  88. touch $$@
  89. $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
  90. $(call Host/Configure)
  91. touch $$@
  92. $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
  93. $(call Host/Compile)
  94. touch $$@
  95. $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
  96. $(call Host/Install)
  97. mkdir -p $$(shell dirname $$@)
  98. touch $$@
  99. ifdef Host/Install
  100. host-install: $(HOST_STAMP_INSTALLED)
  101. endif
  102. download:
  103. host-prepare: $(HOST_STAMP_PREPARED)
  104. host-configure: $(HOST_STAMP_CONFIGURED)
  105. host-compile: $(HOST_STAMP_BUILT)
  106. host-install:
  107. host-clean: FORCE
  108. $(call Host/Clean)
  109. $(call Host/Uninstall)
  110. rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
  111. endef
  112. prepare: host-prepare
  113. compile: host-compile
  114. install: host-install
  115. clean: host-clean
  116. endif