autotools.mk 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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) \
  38. LIBTOOLIZE='$(STAGING_DIR_HOST)/bin/libtoolize --install' \
  39. $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
  40. $(if $(word 2,$(3)),--no-recursive) \
  41. -B $(STAGING_DIR_HOST)/share/aclocal \
  42. $(patsubst %,-I %,$(5)) \
  43. $(patsubst %,-I %,$(4)) $(p) || true; \
  44. fi; \
  45. ) \
  46. );
  47. endef
  48. # 1: build dir
  49. define patch_libtool
  50. @(cd $(1); \
  51. for lt in $$$$($$(STAGING_DIR_HOST)/bin/find . -name ltmain.sh); do \
  52. lt_version="$$$$($$(STAGING_DIR_HOST)/bin/sed -ne 's,^[[:space:]]*VERSION="\?\([0-9]\.[0-9]\+\).*,\1,p' $$$$lt)"; \
  53. case "$$$$lt_version" in \
  54. 1.5|2.2|2.4) echo "autotools.mk: Found libtool v$$$$lt_version - applying patch to $$$$lt"; \
  55. (cd $$$$(dirname $$$$lt) && $$(PATCH) -N -s -p1 < $$(TOPDIR)/tools/libtool/files/libtool-v$$$$lt_version.patch || true) ;; \
  56. *) echo "autotools.mk: error: Unsupported libtool version v$$$$lt_version - cannot patch $$$$lt"; exit 1 ;; \
  57. esac; \
  58. done; \
  59. );
  60. endef
  61. PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
  62. PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
  63. PKG_MACRO_PATHS?=m4
  64. PKG_REMOVE_FILES?=aclocal.m4
  65. Hooks/InstallDev/Post += libtool_remove_files
  66. define autoreconf_target
  67. $(strip $(call autoreconf, \
  68. $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
  69. $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
  70. $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR_HOSTPKG)/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
  71. endef
  72. define patch_libtool_target
  73. $(strip $(call patch_libtool, \
  74. $(PKG_BUILD_DIR)))
  75. endef
  76. define gettext_version_target
  77. (cd $(PKG_BUILD_DIR) && \
  78. 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' ) && \
  79. $(STAGING_DIR_HOST)/bin/sed \
  80. -i $(PKG_BUILD_DIR)/configure.ac \
  81. -e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \
  82. $(STAGING_DIR_HOSTPKG)/bin/autopoint --force \
  83. );
  84. endef
  85. ifneq ($(filter gettext-version,$(PKG_FIXUP)),)
  86. Hooks/Configure/Pre += gettext_version_target
  87. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  88. Hooks/Configure/Pre += autoreconf_target
  89. endif
  90. endif
  91. ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
  92. Hooks/Configure/Pre += patch_libtool_target
  93. endif
  94. ifneq ($(filter libtool,$(PKG_FIXUP)),)
  95. PKG_BUILD_DEPENDS += libtool gettext libiconv
  96. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  97. Hooks/Configure/Pre += autoreconf_target
  98. endif
  99. endif
  100. ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
  101. PKG_BUILD_DEPENDS += libtool gettext libiconv
  102. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  103. Hooks/Configure/Pre += autoreconf_target
  104. endif
  105. endif
  106. ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
  107. ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
  108. Hooks/Configure/Pre += autoreconf_target
  109. endif
  110. endif
  111. HOST_FIXUP?=$(PKG_FIXUP)
  112. HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
  113. HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
  114. HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4)
  115. HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
  116. define autoreconf_host
  117. $(strip $(call autoreconf, \
  118. $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
  119. $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \
  120. $(HOST_MACRO_PATHS)))
  121. endef
  122. define patch_libtool_host
  123. $(strip $(call patch_libtool, \
  124. $(HOST_BUILD_DIR)))
  125. endef
  126. ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
  127. Hooks/HostConfigure/Pre += patch_libtool_host
  128. endif
  129. ifneq ($(filter patch-libtool,$(HOST_FIXUP)),)
  130. Hooks/HostConfigure/Pre += $(strip $(call patch_libtool,$(HOST_BUILD_DIR)))
  131. endif
  132. ifneq ($(filter libtool,$(HOST_FIXUP)),)
  133. ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
  134. Hooks/HostConfigure/Pre += autoreconf_host
  135. endif
  136. endif
  137. ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
  138. ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
  139. Hooks/HostConfigure/Pre += autoreconf_host
  140. endif
  141. endif
  142. ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
  143. ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
  144. Hooks/HostConfigure/Pre += autoreconf_host
  145. endif
  146. endif