host-build.mk 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #
  2. # Copyright (C) 2006 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. ifneq ($(strip $(PKG_UNPACK)),)
  14. define Build/Prepare/Default
  15. $(PKG_UNPACK)
  16. @if [ -d ./patches ]; then \
  17. $(PATCH) $(PKG_BUILD_DIR) ./patches; \
  18. fi
  19. endef
  20. endif
  21. define Build/Prepare
  22. $(call Build/Prepare/Default)
  23. endef
  24. define Build/Configure/Default
  25. @(cd $(PKG_BUILD_DIR)/$(3); \
  26. [ -x configure ] && \
  27. $(2) \
  28. CPPFLAGS="-I$(STAGING_DIR)/host/include" \
  29. LDFLAGS="-L$(STAGING_DIR)/host/lib" \
  30. ./configure \
  31. --target=$(GNU_TARGET_NAME) \
  32. --host=$(GNU_TARGET_NAME) \
  33. --build=$(GNU_HOST_NAME) \
  34. --program-prefix="" \
  35. --program-suffix="" \
  36. --prefix=/usr \
  37. --exec-prefix=/usr \
  38. --bindir=/usr/bin \
  39. --sbindir=/usr/sbin \
  40. --libexecdir=/usr/lib \
  41. --sysconfdir=/etc \
  42. --datadir=/usr/share \
  43. --localstatedir=/var \
  44. --mandir=/usr/man \
  45. --infodir=/usr/info \
  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 ($(CONFIG_AUTOREBUILD),)
  68. define HostBuild/Autoclean
  69. $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
  70. $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
  71. $(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*")
  72. endef
  73. endif
  74. define HostBuild
  75. ifeq ($(DUMP),)
  76. $(call HostBuild/Autoclean)
  77. endif
  78. $(STAMP_PREPARED):
  79. @-rm -rf $(PKG_BUILD_DIR)
  80. @mkdir -p $(PKG_BUILD_DIR)
  81. $(call Build/Prepare)
  82. touch $$@
  83. $(STAMP_CONFIGURED): $(STAMP_PREPARED)
  84. $(call Build/Configure)
  85. touch $$@
  86. $(STAMP_BUILT): $(STAMP_CONFIGURED)
  87. $(call Build/Compile)
  88. @$(NO_TRACE_MAKE) $(PKG_BUILD_DIR)/.dep_files
  89. touch $$@
  90. $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(STAMP_BUILT)
  91. $(call Build/Install)
  92. mkdir -p $$(shell dirname $$@)
  93. touch $$@
  94. ifdef Build/Install
  95. install: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  96. endif
  97. package-clean: FORCE
  98. $(call Build/Clean)
  99. $(call Build/Uninstall)
  100. rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  101. download:
  102. prepare: $(STAMP_PREPARED)
  103. configure: $(STAMP_CONFIGURED)
  104. compile: $(STAMP_BUILT)
  105. install:
  106. clean: FORCE
  107. $(call Build/Clean)
  108. rm -rf $(PKG_BUILD_DIR)
  109. endef