autotools.mk 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #
  2. # Copyright (C) 2007-2010 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. define replace
  8. if [ -f "$(PKG_BUILD_DIR)/$(3)$(1)" -a -e "$(2)/$(if $(4),$(4),$(1))" ]; then \
  9. rm -f $(PKG_BUILD_DIR)/$(3)$(1); \
  10. ln -s $(2)/$(if $(4),$(4),$(1)) $(PKG_BUILD_DIR)/$(3)$(1); \
  11. fi
  12. endef
  13. PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
  14. # replace copies of ltmain.sh with the build system's version
  15. update_libtool_common = \
  16. $(foreach p,$(LIBTOOL_PATHS), \
  17. $(call replace,ltmain.sh,$(STAGING_DIR)/host/share/libtool,$(p)/) \
  18. $(call replace,libtool.m4,$(STAGING_DIR)/host/share/aclocal,$(p)/) \
  19. )
  20. update_libtool = \
  21. $(foreach p,$(PKG_LIBTOOL_PATHS), \
  22. $(call replace,libtool,$(STAGING_DIR)/host/bin,$(p)/) \
  23. ) \
  24. $(call update_libtool_common)
  25. update_libtool_ucxx = \
  26. $(foreach p,$(PKG_LIBTOOL_PATHS), \
  27. $(call replace,libtool,$(STAGING_DIR)/host/bin,$(p)/,libtool-ucxx) \
  28. ) \
  29. $(call update_libtool_common)
  30. autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2))
  31. # prevent libtool from linking against host development libraries
  32. define libtool_fixup_libdir
  33. find $(1) -name '*.la' | $(XARGS) \
  34. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" \
  35. -e "s,$(STAGING_DIR)/usr/lib/\(libstdc++\|libsupc++\).la,$(TOOLCHAIN_DIR)/usr/lib/\1.la,g"
  36. endef
  37. define remove_version_check
  38. if [ -f "$(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure" ]; then \
  39. $(SED) \
  40. 's,\(gentoo\|pardus\)_ltmain_version=.*,\1_ltmain_version="$$$$\1_lt_version",' \
  41. $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure; \
  42. fi
  43. endef
  44. ifneq ($(filter libtool,$(PKG_FIXUP)),)
  45. PKG_BUILD_DEPENDS += libtool
  46. Hooks/Configure/Pre += update_libtool remove_version_check
  47. Hooks/Configure/Post += update_libtool
  48. Hooks/InstallDev/Post += libtool_fixup_libdir
  49. endif
  50. ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
  51. PKG_BUILD_DEPENDS += libtool
  52. Hooks/Configure/Pre += update_libtool_ucxx remove_version_check
  53. Hooks/Configure/Post += update_libtool_ucxx
  54. Hooks/InstallDev/Post += libtool_fixup_libdir
  55. endif