autotools.mk: Add PKG_LIBTOOL_PATHS variable.
[openwrt/svn-archive/archive.git] / include / autotools.mk
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
8 define replace
9 if [ -f "$(PKG_BUILD_DIR)/$(3)$(1)" -a -e "$(2)/$(if $(4),$(4),$(1))" ]; then \
10 rm -f $(PKG_BUILD_DIR)/$(3)$(1); \
11 ln -s $(2)/$(if $(4),$(4),$(1)) $(PKG_BUILD_DIR)/$(3)$(1); \
12 fi
13
14 endef
15
16 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
17
18 # replace copies of ltmain.sh with the build system's version
19 update_libtool_common = \
20 $(foreach p,$(LIBTOOL_PATHS), \
21 $(call replace,ltmain.sh,$(STAGING_DIR)/host/share/libtool,$(p)/) \
22 $(call replace,libtool.m4,$(STAGING_DIR)/host/share/aclocal,$(p)/) \
23 )
24 update_libtool = \
25 $(foreach p,$(PKG_LIBTOOL_PATHS), \
26 $(call replace,libtool,$(STAGING_DIR)/host/bin,$(p)/) \
27 ) \
28 $(call update_libtool_common)
29 update_libtool_ucxx = \
30 $(foreach p,$(PKG_LIBTOOL_PATHS), \
31 $(call replace,libtool,$(STAGING_DIR)/host/bin,$(p)/,libtool-ucxx) \
32 ) \
33 $(call update_libtool_common)
34
35
36 # prevent libtool from linking against host development libraries
37 define libtool_fixup_libdir
38 find $(1) -name '*.la' | $(XARGS) \
39 $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" \
40 -e "s,$(STAGING_DIR)/usr/lib/\(libstdc++\|libsupc++\).la,$(TOOLCHAIN_DIR)/usr/lib/\1.la,g"
41 find $(2) -name '*.la' | $(XARGS) \
42 $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" \
43 -e "s,$(STAGING_DIR)/usr/lib/\(libstdc++\|libsupc++\).la,$(TOOLCHAIN_DIR)/usr/lib/\1.la,g"
44 endef
45
46 define remove_version_check
47 if [ -f "$(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure" ]; then \
48 $(SED) \
49 's,\(gentoo\|pardus\)_ltmain_version=.*,\1_ltmain_version="$$$$\1_lt_version",' \
50 $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure; \
51 fi
52 endef
53
54 ifneq ($(filter libtool,$(PKG_FIXUP)),)
55 PKG_BUILD_DEPENDS += libtool
56 Hooks/Configure/Pre += update_libtool remove_version_check
57 Hooks/Configure/Post += update_libtool
58 Hooks/InstallDev/Post += libtool_fixup_libdir
59 endif
60
61 ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
62 PKG_BUILD_DEPENDS += libtool
63 Hooks/Configure/Pre += update_libtool_ucxx remove_version_check
64 Hooks/Configure/Post += update_libtool_ucxx
65 Hooks/InstallDev/Post += libtool_fixup_libdir
66 endif
67