autotools.mk 5.2 KB

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