2
0

autotools.mk 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #
  2. # Copyright (C) 2007-2012 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2))
  8. # delete *.la-files from staging_dir - we can not yet remove respective lines within all package
  9. # Makefiles, since backfire still uses libtool v1.5.x which (may) require those files
  10. define libtool_remove_files
  11. find $(1) -name '*.la' | $(XARGS) rm -f;
  12. endef
  13. AM_TOOL_PATHS:= \
  14. AUTOM4TE=$(STAGING_DIR_HOST)/bin/autom4te \
  15. AUTOCONF=$(STAGING_DIR_HOST)/bin/autoconf \
  16. AUTOMAKE=$(STAGING_DIR_HOST)/bin/automake \
  17. ACLOCAL=$(STAGING_DIR_HOST)/bin/aclocal \
  18. AUTOHEADER=$(STAGING_DIR_HOST)/bin/autoheader \
  19. LIBTOOLIZE=$(STAGING_DIR_HOST)/bin/libtoolize \
  20. LIBTOOL=$(STAGING_DIR_HOST)/bin/libtool \
  21. M4=$(STAGING_DIR_HOST)/bin/m4 \
  22. AUTOPOINT=true
  23. # 1: build dir
  24. # 2: remove files
  25. # 3: automake paths
  26. # 4: libtool paths
  27. # 5: extra m4 dirs
  28. define autoreconf
  29. (cd $(1); \
  30. $(patsubst %,rm -f %;,$(2)) \
  31. $(foreach p,$(3), \
  32. if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \
  33. [ -d $(p)/autom4te.cache ] && rm -rf autom4te.cache; \
  34. [ -e $(p)/config.rpath ] || \
  35. ln -s $(SCRIPT_DIR)/config.rpath $(p)/config.rpath; \
  36. touch NEWS AUTHORS COPYING ABOUT-NLS ChangeLog; \
  37. $(AM_TOOL_PATHS) $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
  38. $(if $(word 2,$(3)),--no-recursive) \
  39. -B $(STAGING_DIR_HOST)/share/aclocal \
  40. $(patsubst %,-I %,$(5)) \
  41. $(patsubst %,-I %,$(4)) $(p) || true; \
  42. fi; \
  43. ) \
  44. );
  45. endef
  46. # 1: build dir
  47. define patch_libtool
  48. @(cd $(1); \
  49. for lt in $$$$($$(STAGING_DIR_HOST)/bin/find . -name ltmain.sh); do \
  50. lt_version="$$$$($$(STAGING_DIR_HOST)/bin/sed -ne 's,^[[:space:]]*VERSION="\?\([0-9]\.[0-9]\+\).*,\1,p' $$$$lt)"; \
  51. case "$$$$lt_version" in \
  52. 1.5|2.2|2.4) echo "autotools.mk: Found libtool v$$$$lt_version - applying patch to $$$$lt"; \
  53. (cd $$$$(dirname $$$$lt) && $$(PATCH) -N -s -p1 < $$(TOPDIR)/tools/libtool/files/libtool-v$$$$lt_version.patch || true) ;; \
  54. *) echo "autotools.mk: error: Unsupported libtool version v$$$$lt_version - cannot patch $$$$lt"; exit 1 ;; \
  55. esac; \
  56. done; \
  57. );
  58. endef
  59. PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
  60. PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
  61. PKG_MACRO_PATHS?=m4
  62. PKG_REMOVE_FILES?=aclocal.m4
  63. Hooks/InstallDev/Post += libtool_remove_files
  64. define autoreconf_target
  65. $(strip $(call autoreconf, \
  66. $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
  67. $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
  68. $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
  69. endef
  70. define patch_libtool_target
  71. $(strip $(call patch_libtool, \
  72. $(PKG_BUILD_DIR)))
  73. endef
  74. define gettext_version_target
  75. (cd $(PKG_BUILD_DIR) && \
  76. GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
  77. $(STAGING_DIR_HOST)/bin/sed \
  78. -i $(PKG_BUILD_DIR)/configure.ac \
  79. -e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \
  80. $(STAGING_DIR_HOSTPKG)/bin/autopoint --force \
  81. );
  82. endef
  83. ifneq ($(filter gettext-version,$(PKG_FIXUP)),)
  84. Hooks/Configure/Pre += gettext_version_target
  85. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  86. Hooks/Configure/Pre += autoreconf_target
  87. endif
  88. endif
  89. ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
  90. Hooks/Configure/Pre += patch_libtool_target
  91. endif
  92. ifneq ($(filter libtool,$(PKG_FIXUP)),)
  93. PKG_BUILD_DEPENDS += libtool libintl libiconv
  94. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  95. Hooks/Configure/Pre += autoreconf_target
  96. endif
  97. endif
  98. ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
  99. PKG_BUILD_DEPENDS += libtool libintl libiconv
  100. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  101. Hooks/Configure/Pre += autoreconf_target
  102. endif
  103. endif
  104. ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
  105. ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
  106. Hooks/Configure/Pre += autoreconf_target
  107. endif
  108. endif
  109. HOST_FIXUP?=$(PKG_FIXUP)
  110. HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
  111. HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
  112. HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4)
  113. HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
  114. define autoreconf_host
  115. $(strip $(call autoreconf, \
  116. $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
  117. $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \
  118. $(HOST_MACRO_PATHS)))
  119. endef
  120. define patch_libtool_host
  121. $(strip $(call patch_libtool, \
  122. $(HOST_BUILD_DIR)))
  123. endef
  124. ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
  125. Hooks/HostConfigure/Pre += patch_libtool_host
  126. endif
  127. ifneq ($(filter patch-libtool,$(HOST_FIXUP)),)
  128. Hooks/HostConfigure/Pre += $(strip $(call patch_libtool,$(HOST_BUILD_DIR)))
  129. endif
  130. ifneq ($(filter libtool,$(HOST_FIXUP)),)
  131. ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
  132. Hooks/HostConfigure/Pre += autoreconf_host
  133. endif
  134. endif
  135. ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
  136. ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
  137. Hooks/HostConfigure/Pre += autoreconf_host
  138. endif
  139. endif
  140. ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
  141. ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
  142. Hooks/HostConfigure/Pre += autoreconf_host
  143. endif
  144. endif