host-build.mk 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. ifneq ($(strip $(PKG_CAT)),)
  9. ifeq ($(PKG_CAT),unzip)
  10. UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
  11. else
  12. UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
  13. endif
  14. define Build/Prepare/Default
  15. $(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. $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
  66. endif
  67. define HostBuild
  68. $(PKG_BUILD_DIR)/.prepared:
  69. @-rm -rf $(PKG_BUILD_DIR)
  70. @mkdir -p $(PKG_BUILD_DIR)
  71. $(call Build/Prepare)
  72. touch $$@
  73. $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
  74. $(call Build/Configure)
  75. touch $$@
  76. $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
  77. $(call Build/Compile)
  78. touch $$@
  79. $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
  80. $(call Build/Install)
  81. touch $$@
  82. ifdef Build/Install
  83. install-targets: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  84. endif
  85. package-clean: FORCE
  86. $(call Build/Clean)
  87. $(call Build/Uninstall)
  88. rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
  89. download:
  90. prepare: $(PKG_BUILD_DIR)/.prepared
  91. configure: $(PKG_BUILD_DIR)/.configured
  92. compile-targets: $(PKG_BUILD_DIR)/.built
  93. compile: compile-targets
  94. install-targets:
  95. install: install-targets
  96. clean-targets:
  97. clean: FORCE
  98. @$(MAKE) clean-targets
  99. $(call Build/Clean)
  100. rm -rf $(PKG_BUILD_DIR)
  101. endef