host-build.mk 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. ifneq ($(strip $(PKG_UNPACK)),)
  10. define Build/Prepare/Default
  11. $(PKG_UNPACK)
  12. @if [ -d ./patches ]; then \
  13. $(PATCH) $(PKG_BUILD_DIR) ./patches; \
  14. fi
  15. endef
  16. endif
  17. define Build/Prepare
  18. $(call Build/Prepare/Default)
  19. endef
  20. define Build/Configure/Default
  21. @(cd $(PKG_BUILD_DIR)/$(3); \
  22. [ -x configure ] && \
  23. $(2) \
  24. CPPFLAGS="-I$(STAGING_DIR)/host/include" \
  25. LDFLAGS="-L$(STAGING_DIR)/host/lib" \
  26. ./configure \
  27. --target=$(GNU_TARGET_NAME) \
  28. --host=$(GNU_TARGET_NAME) \
  29. --build=$(GNU_HOST_NAME) \
  30. --program-prefix="" \
  31. --program-suffix="" \
  32. --prefix=/usr \
  33. --exec-prefix=/usr \
  34. --bindir=/usr/bin \
  35. --sbindir=/usr/sbin \
  36. --libexecdir=/usr/lib \
  37. --sysconfdir=/etc \
  38. --datadir=/usr/share \
  39. --localstatedir=/var \
  40. --mandir=/usr/man \
  41. --infodir=/usr/info \
  42. $(DISABLE_NLS) \
  43. $(1); \
  44. true; \
  45. )
  46. endef
  47. define Build/Configure
  48. $(call Build/Configure/Default)
  49. endef
  50. define Build/Compile/Default
  51. $(MAKE) -C $(PKG_BUILD_DIR) $(1)
  52. endef
  53. define Build/Compile
  54. $(call Build/Compile/Default)
  55. endef
  56. ifneq ($(strip $(PKG_SOURCE)),)
  57. download: $(DL_DIR)/$(PKG_SOURCE)
  58. $(DL_DIR)/$(PKG_SOURCE):
  59. mkdir -p $(DL_DIR)
  60. $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
  61. $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
  62. endif
  63. define HostBuild
  64. ifeq ($(DUMP),)
  65. ifeq ($(CONFIG_AUTOREBUILD),y)
  66. ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) . $(PKG_FILE_DEPEND)),$(PKG_BUILD_DIR))
  67. $$(info Forcing package rebuild)
  68. $(PKG_BUILD_DIR)/.prepared: package-clean
  69. endif
  70. endif
  71. endif
  72. $(PKG_BUILD_DIR)/.prepared:
  73. @-rm -rf $(PKG_BUILD_DIR)
  74. @mkdir -p $(PKG_BUILD_DIR)
  75. $(call Build/Prepare)
  76. touch $$@
  77. $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
  78. $(call Build/Configure)
  79. touch $$@
  80. $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
  81. $(call Build/Compile)
  82. touch $$@
  83. $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
  84. $(call Build/Install)
  85. mkdir -p $$(shell dirname $$@)
  86. touch $$@
  87. ifdef Build/Install
  88. install: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  89. endif
  90. package-clean: FORCE
  91. $(call Build/Clean)
  92. $(call Build/Uninstall)
  93. rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  94. download:
  95. prepare: $(PKG_BUILD_DIR)/.prepared
  96. configure: $(PKG_BUILD_DIR)/.configured
  97. compile: $(PKG_BUILD_DIR)/.built
  98. install:
  99. clean: FORCE
  100. $(call Build/Clean)
  101. rm -rf $(PKG_BUILD_DIR)
  102. endef