host-build.mk 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #
  2. # Copyright (C) 2006-2010 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. HOST_BUILD_PARALLEL ?=
  10. ifeq ($(strip $(HOST_BUILD_PARALLEL)),0)
  11. HOST_JOBS?=-j1
  12. else
  13. HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL)$(CONFIG_PKG_DEFAULT_PARALLEL),\
  14. $(if $(CONFIG_PKG_BUILD_PARALLEL),-j$(CONFIG_PKG_BUILD_JOBS),-j1),-j1)
  15. endif
  16. include $(INCLUDE_DIR)/host.mk
  17. include $(INCLUDE_DIR)/unpack.mk
  18. include $(INCLUDE_DIR)/depends.mk
  19. BUILD_TYPES += host
  20. HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),)))
  21. HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
  22. HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
  23. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
  24. override MAKEFLAGS=
  25. include $(INCLUDE_DIR)/download.mk
  26. include $(INCLUDE_DIR)/quilt.mk
  27. include $(INCLUDE_DIR)/autotools.mk
  28. Host/Patch:=$(Host/Patch/Default)
  29. ifneq ($(strip $(HOST_UNPACK)),)
  30. define Host/Prepare/Default
  31. $(HOST_UNPACK)
  32. $(Host/Patch)
  33. endef
  34. endif
  35. define Host/Prepare
  36. $(call Host/Prepare/Default)
  37. endef
  38. HOST_CONFIGURE_VARS = \
  39. CFLAGS="$(HOST_CFLAGS)" \
  40. CPPFLAGS="$(HOST_CFLAGS)" \
  41. LDFLAGS="$(HOST_LDFLAGS)" \
  42. SHELL="$(BASH)"
  43. HOST_CONFIGURE_ARGS = \
  44. --target=$(GNU_HOST_NAME) \
  45. --host=$(GNU_HOST_NAME) \
  46. --build=$(GNU_HOST_NAME) \
  47. --program-prefix="" \
  48. --program-suffix="" \
  49. --prefix=$(STAGING_DIR_HOST) \
  50. --exec-prefix=$(STAGING_DIR_HOST) \
  51. --sysconfdir=$(STAGING_DIR_HOST)/etc \
  52. --localstatedir=$(STAGING_DIR_HOST)/var \
  53. --sbindir=$(STAGING_DIR_HOST)/bin
  54. HOST_CONFIGURE_CMD = ./configure
  55. define Host/Configure/Default
  56. (cd $(HOST_BUILD_DIR)/$(3); \
  57. if [ -x configure ]; then \
  58. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
  59. $(2) \
  60. $(HOST_CONFIGURE_CMD) \
  61. $(HOST_CONFIGURE_VARS) \
  62. $(HOST_CONFIGURE_ARGS) \
  63. $(1); \
  64. fi \
  65. )
  66. endef
  67. define Host/Configure
  68. $(call Host/Configure/Default)
  69. endef
  70. define Host/Compile/Default
  71. $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) $(1)
  72. endef
  73. define Host/Compile
  74. $(call Host/Compile/Default)
  75. endef
  76. define Host/Install/Default
  77. $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install
  78. endef
  79. define Host/Install
  80. $(call Host/Install/Default)
  81. endef
  82. ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
  83. define HostHost/Autoclean
  84. $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
  85. $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
  86. endef
  87. endif
  88. define Download/default
  89. FILE:=$(PKG_SOURCE)
  90. URL:=$(PKG_SOURCE_URL)
  91. PROTO:=$(PKG_SOURCE_PROTO)
  92. SUBDIR:=$(PKG_SOURCE_SUBDIR)
  93. VERSION:=$(PKG_SOURCE_VERSION)
  94. MD5SUM:=$(PKG_MD5SUM)
  95. endef
  96. define Host/Exports/Default
  97. $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p))
  98. $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST)
  99. $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
  100. $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
  101. endef
  102. Host/Exports=$(Host/Exports/Default)
  103. ifndef DUMP
  104. define HostBuild
  105. $(if $(HOST_QUILT),$(Host/Quilt))
  106. $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
  107. $(if $(DUMP),,$(call HostHost/Autoclean))
  108. $(HOST_STAMP_PREPARED):
  109. @-rm -rf $(HOST_BUILD_DIR)
  110. @mkdir -p $(HOST_BUILD_DIR)
  111. $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
  112. $(call Host/Prepare)
  113. $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
  114. touch $$@
  115. $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
  116. $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
  117. $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
  118. $(call Host/Configure)
  119. $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
  120. touch $$@
  121. $(call Host/Exports,$(HOST_STAMP_BUILT))
  122. ifdef Host/Install
  123. host-install: $(if $(STAMP_BUILT),$(HOST_STAMP_BUILT),$(HOST_STAMP_INSTALLED))
  124. endif
  125. ifndef STAMP_BUILT
  126. prepare: host-prepare
  127. compile: host-compile
  128. install: host-install
  129. clean: host-clean
  130. update: host-update
  131. refresh: host-refresh
  132. $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
  133. $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
  134. $(call Host/Compile)
  135. $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
  136. touch $$@
  137. $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
  138. $(call Host/Install)
  139. $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
  140. mkdir -p $$(shell dirname $$@)
  141. touch $$@
  142. else
  143. $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED) $(if $(FORCE_HOST_INSTALL),FORCE)
  144. $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
  145. $(call Host/Compile)
  146. $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
  147. $(call Host/Install)
  148. $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
  149. touch $$@
  150. endif
  151. host-prepare: $(HOST_STAMP_PREPARED)
  152. host-configure: $(HOST_STAMP_CONFIGURED)
  153. host-compile: $(HOST_STAMP_BUILT)
  154. host-install:
  155. host-clean: FORCE
  156. $(call Host/Clean)
  157. $(call Host/Uninstall)
  158. rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
  159. endef
  160. download:
  161. prepare:
  162. compile:
  163. install:
  164. clean:
  165. endif