autotools.mk 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. # prevent libtool from linking against host development libraries
  31. define libtool_fixup_libdir
  32. find $(1) -name '*.la' | $(XARGS) \
  33. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" \
  34. -e "s,$(STAGING_DIR)/usr/lib/\(libstdc++\|libsupc++\).la,$(TOOLCHAIN_DIR)/usr/lib/\1.la,g"
  35. endef
  36. define remove_version_check
  37. if [ -f "$(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure" ]; then \
  38. $(SED) \
  39. 's,\(gentoo\|pardus\)_ltmain_version=.*,\1_ltmain_version="$$$$\1_lt_version",' \
  40. $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure; \
  41. fi
  42. endef
  43. ifneq ($(filter libtool,$(PKG_FIXUP)),)
  44. PKG_BUILD_DEPENDS += libtool
  45. Hooks/Configure/Pre += update_libtool remove_version_check
  46. Hooks/Configure/Post += update_libtool
  47. Hooks/InstallDev/Post += libtool_fixup_libdir
  48. endif
  49. ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
  50. PKG_BUILD_DEPENDS += libtool
  51. Hooks/Configure/Pre += update_libtool_ucxx remove_version_check
  52. Hooks/Configure/Post += update_libtool_ucxx
  53. Hooks/InstallDev/Post += libtool_fixup_libdir
  54. endif