host-build.mk 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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_DEPENDS),)))
  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. define Host/Install/Default
  67. $(MAKE) -C $(HOST_BUILD_DIR) install
  68. endef
  69. define Host/Install
  70. $(call Host/Install/Default)
  71. endef
  72. ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
  73. define HostHost/Autoclean
  74. $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
  75. $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
  76. endef
  77. endif
  78. define Download/default
  79. FILE:=$(PKG_SOURCE)
  80. URL:=$(PKG_SOURCE_URL)
  81. PROTO:=$(PKG_SOURCE_PROTO)
  82. SUBDIR:=$(PKG_SOURCE_SUBDIR)
  83. VERSION:=$(PKG_SOURCE_VERSION)
  84. MD5SUM:=$(PKG_MD5SUM)
  85. endef
  86. define Host/Exports/Default
  87. $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p))
  88. $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST)
  89. $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
  90. $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
  91. endef
  92. Host/Exports=$(Host/Exports/Default)
  93. ifndef DUMP
  94. define HostBuild
  95. $(if $(HOST_QUILT),$(Host/Quilt))
  96. $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
  97. $(if $(DUMP),,$(call HostHost/Autoclean))
  98. $(HOST_STAMP_PREPARED):
  99. @-rm -rf $(HOST_BUILD_DIR)
  100. @mkdir -p $(HOST_BUILD_DIR)
  101. $(call Host/Prepare)
  102. touch $$@
  103. $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
  104. $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
  105. $(call Host/Configure)
  106. touch $$@
  107. $(call Host/Exports,$(HOST_STAMP_BUILT))
  108. $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
  109. $(call Host/Compile)
  110. touch $$@
  111. $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
  112. $(call Host/Install)
  113. mkdir -p $$(shell dirname $$@)
  114. touch $$@
  115. ifdef Host/Install
  116. host-install: $(HOST_STAMP_INSTALLED)
  117. endif
  118. ifndef STAMP_BUILT
  119. prepare: host-prepare
  120. compile: host-compile
  121. install: host-install
  122. clean: host-clean
  123. update: host-update
  124. else
  125. host-compile: $(HOST_STAMP_INSTALLED)
  126. endif
  127. host-prepare: $(HOST_STAMP_PREPARED)
  128. host-configure: $(HOST_STAMP_CONFIGURED)
  129. host-compile: $(HOST_STAMP_BUILT)
  130. host-install:
  131. host-clean: FORCE
  132. $(call Host/Clean)
  133. $(call Host/Uninstall)
  134. rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
  135. endef
  136. download:
  137. prepare:
  138. compile:
  139. install:
  140. clean:
  141. endif