host-build.mk 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. BUILD_TYPES += host
  13. HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
  14. HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
  15. HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
  16. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
  17. override MAKEFLAGS=
  18. include $(INCLUDE_DIR)/download.mk
  19. include $(INCLUDE_DIR)/quilt.mk
  20. Host/Patch:=$(Host/Patch/Default)
  21. ifneq ($(strip $(HOST_UNPACK)),)
  22. define Host/Prepare/Default
  23. $(HOST_UNPACK)
  24. $(Host/Patch)
  25. endef
  26. endif
  27. define Host/Prepare
  28. $(call Host/Prepare/Default)
  29. endef
  30. HOST_CONFIGURE_VARS = \
  31. CPPFLAGS="$(HOST_CFLAGS)" \
  32. LDFLAGS="$(HOST_LDFLAGS)" \
  33. SHELL="$(BASH)"
  34. HOST_CONFIGURE_ARGS = \
  35. --target=$(GNU_HOST_NAME) \
  36. --host=$(GNU_HOST_NAME) \
  37. --build=$(GNU_HOST_NAME) \
  38. --program-prefix="" \
  39. --program-suffix="" \
  40. --prefix=$(STAGING_DIR_HOST) \
  41. --exec-prefix=$(STAGING_DIR_HOST) \
  42. --sysconfdir=$(STAGING_DIR_HOST)/etc \
  43. --localstatedir=$(STAGING_DIR_HOST)/var
  44. HOST_CONFIGURE_CMD = ./configure
  45. define Host/Configure/Default
  46. @(cd $(HOST_BUILD_DIR)/$(3); \
  47. if [ -x configure ]; then \
  48. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
  49. $(2) \
  50. $(HOST_CONFIGURE_CMD) \
  51. $(HOST_CONFIGURE_VARS) \
  52. $(HOST_CONFIGURE_ARGS) \
  53. $(1); \
  54. fi \
  55. )
  56. endef
  57. define Host/Configure
  58. $(call Host/Configure/Default)
  59. endef
  60. define Host/Compile/Default
  61. $(MAKE) -C $(HOST_BUILD_DIR) $(1)
  62. endef
  63. define Host/Compile
  64. $(call Host/Compile/Default)
  65. endef
  66. ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
  67. define HostHost/Autoclean
  68. $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(HOST_STAMP_PREPARED))
  69. $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
  70. endef
  71. endif
  72. define Download/default
  73. FILE:=$(PKG_SOURCE)
  74. URL:=$(PKG_SOURCE_URL)
  75. PROTO:=$(PKG_SOURCE_PROTO)
  76. SUBDIR:=$(PKG_SOURCE_SUBDIR)
  77. VERSION:=$(PKG_SOURCE_VERSION)
  78. MD5SUM:=$(PKG_MD5SUM)
  79. endef
  80. ifndef DUMP
  81. define HostBuild
  82. $(if $(HOST_QUILT),$(Host/Quilt))
  83. $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
  84. $(if $(DUMP),,$(call HostHost/Autoclean))
  85. $(HOST_STAMP_PREPARED):
  86. @-rm -rf $(HOST_BUILD_DIR)
  87. @mkdir -p $(HOST_BUILD_DIR)
  88. $(call Host/Prepare)
  89. touch $$@
  90. $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
  91. $(call Host/Configure)
  92. touch $$@
  93. $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
  94. $(call Host/Compile)
  95. touch $$@
  96. $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
  97. $(call Host/Install)
  98. mkdir -p $$(shell dirname $$@)
  99. touch $$@
  100. ifdef Host/Install
  101. host-install: $(HOST_STAMP_INSTALLED)
  102. endif
  103. ifndef STAMP_BUILT
  104. prepare: host-prepare
  105. compile: host-compile
  106. install: host-install
  107. clean: host-clean
  108. else
  109. host-compile: $(HOST_STAMP_INSTALLED)
  110. endif
  111. host-prepare: $(HOST_STAMP_PREPARED)
  112. host-configure: $(HOST_STAMP_CONFIGURED)
  113. host-compile: $(HOST_STAMP_BUILT)
  114. host-install:
  115. host-clean: FORCE
  116. $(call Host/Clean)
  117. $(call Host/Uninstall)
  118. rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
  119. endef
  120. download:
  121. prepare:
  122. compile:
  123. install:
  124. clean:
  125. endif