host-build.mk 3.0 KB

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