host-build.mk 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. include $(INCLUDE_DIR)/host.mk
  8. include $(INCLUDE_DIR)/unpack.mk
  9. include $(INCLUDE_DIR)/depends.mk
  10. STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s)
  11. STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
  12. STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
  13. override MAKEFLAGS=
  14. include $(INCLUDE_DIR)/quilt.mk
  15. Build/Patch:=$(Build/Patch/Default)
  16. ifneq ($(strip $(PKG_UNPACK)),)
  17. define Build/Prepare/Default
  18. $(PKG_UNPACK)
  19. $(Build/Patch)
  20. endef
  21. endif
  22. define Build/Prepare
  23. $(call Build/Prepare/Default)
  24. endef
  25. define Build/Configure/Default
  26. @(cd $(PKG_BUILD_DIR)/$(3); \
  27. [ -x configure ] && \
  28. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/$(3)/ && \
  29. $(2) \
  30. CPPFLAGS="-I$(STAGING_DIR)/host/include" \
  31. LDFLAGS="-L$(STAGING_DIR)/host/lib" \
  32. ./configure \
  33. --target=$(GNU_TARGET_NAME) \
  34. --host=$(GNU_TARGET_NAME) \
  35. --build=$(GNU_HOST_NAME) \
  36. --program-prefix="" \
  37. --program-suffix="" \
  38. --prefix=/usr \
  39. --exec-prefix=/usr \
  40. --bindir=/usr/bin \
  41. --sbindir=/usr/sbin \
  42. --libexecdir=/usr/lib \
  43. --sysconfdir=/etc \
  44. --datadir=/usr/share \
  45. --localstatedir=/var \
  46. --mandir=/usr/man \
  47. --infodir=/usr/info \
  48. $(DISABLE_NLS) \
  49. $(1); \
  50. true; \
  51. )
  52. endef
  53. define Build/Configure
  54. $(call Build/Configure/Default)
  55. endef
  56. define Build/Compile/Default
  57. $(MAKE) -C $(PKG_BUILD_DIR) $(1)
  58. endef
  59. define Build/Compile
  60. $(call Build/Compile/Default)
  61. endef
  62. ifneq ($(strip $(PKG_SOURCE)),)
  63. download: $(DL_DIR)/$(PKG_SOURCE)
  64. $(DL_DIR)/$(PKG_SOURCE):
  65. mkdir -p $(DL_DIR)
  66. $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
  67. $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
  68. endif
  69. ifneq ($(CONFIG_AUTOREBUILD),)
  70. define HostBuild/Autoclean
  71. $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
  72. $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
  73. $(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*")
  74. endef
  75. endif
  76. define HostBuild
  77. ifeq ($(DUMP),)
  78. $(call HostBuild/Autoclean)
  79. endif
  80. $(STAMP_PREPARED):
  81. @-rm -rf $(PKG_BUILD_DIR)
  82. @mkdir -p $(PKG_BUILD_DIR)
  83. $(call Build/Prepare)
  84. touch $$@
  85. $(STAMP_CONFIGURED): $(STAMP_PREPARED)
  86. $(call Build/Configure)
  87. touch $$@
  88. $(STAMP_BUILT): $(STAMP_CONFIGURED)
  89. $(call Build/Compile)
  90. @$(NO_TRACE_MAKE) $(PKG_BUILD_DIR)/.dep_files
  91. touch $$@
  92. $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(STAMP_BUILT)
  93. $(call Build/Install)
  94. mkdir -p $$(shell dirname $$@)
  95. touch $$@
  96. ifdef Build/Install
  97. install: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  98. endif
  99. package-clean: FORCE
  100. $(call Build/Clean)
  101. $(call Build/Uninstall)
  102. rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  103. download:
  104. prepare: $(STAMP_PREPARED)
  105. configure: $(STAMP_CONFIGURED)
  106. compile: $(STAMP_BUILT)
  107. install:
  108. clean: FORCE
  109. $(call Build/Clean)
  110. rm -rf $(PKG_BUILD_DIR)
  111. endef