autotools.mk 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_HOST)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.* //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_HOST)/bin/autopoint --force
  81. endef
  82. ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
  83. Hooks/Configure/Pre += patch_libtool_target
  84. endif
  85. ifneq ($(filter libtool,$(PKG_FIXUP)),)
  86. PKG_BUILD_DEPENDS += libtool libintl libiconv
  87. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  88. Hooks/Configure/Pre += autoreconf_target
  89. endif
  90. endif
  91. ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
  92. PKG_BUILD_DEPENDS += libtool libintl libiconv
  93. ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
  94. Hooks/Configure/Pre += autoreconf_target
  95. endif
  96. endif
  97. ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
  98. ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
  99. Hooks/Configure/Pre += autoreconf_target
  100. endif
  101. endif
  102. ifneq ($(filter gettext-version,$(PKG_FIXUP)),)
  103. Hooks/Configure/Pre += gettext_version_target
  104. endif
  105. HOST_FIXUP?=$(PKG_FIXUP)
  106. HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
  107. HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
  108. HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4)
  109. HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
  110. define autoreconf_host
  111. $(strip $(call autoreconf, \
  112. $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
  113. $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \
  114. $(HOST_MACRO_PATHS)))
  115. endef
  116. define patch_libtool_host
  117. $(strip $(call patch_libtool, \
  118. $(HOST_BUILD_DIR)))
  119. endef
  120. ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
  121. Hooks/HostConfigure/Pre += patch_libtool_host
  122. endif
  123. ifneq ($(filter patch-libtool,$(HOST_FIXUP)),)
  124. Hooks/HostConfigure/Pre += $(strip $(call patch_libtool,$(HOST_BUILD_DIR)))
  125. endif
  126. ifneq ($(filter libtool,$(HOST_FIXUP)),)
  127. ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
  128. Hooks/HostConfigure/Pre += autoreconf_host
  129. endif
  130. endif
  131. ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
  132. ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
  133. Hooks/HostConfigure/Pre += autoreconf_host
  134. endif
  135. endif
  136. ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
  137. ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
  138. Hooks/HostConfigure/Pre += autoreconf_host
  139. endif
  140. endif