32036046824620d5d7fd6ca25b10115c1ad66d54
[openwrt/openwrt.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 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
9
10 autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2))
11
12 # prevent libtool from linking against host development libraries
13 define libtool_fixup_libdir
14 find $(1) -name '*.la' | $(XARGS) \
15 $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" \
16 -e "s,$(STAGING_DIR)/usr/lib/\(libstdc++\|libsupc++\).la,$(TOOLCHAIN_DIR)/lib/\1.la,g";
17 endef
18
19 # delete *.la-files from staging_dir - we can not yet remove respective lines within all package
20 # Makefiles, since backfire still uses libtool v1.5.x which (may) require those files
21 define libtool_remove_files
22 find $(1) -name '*.la' | $(XARGS) rm -f;
23 endef
24
25 define autoreconf
26 (cd $(PKG_BUILD_DIR); \
27 if [ -x ./autogen.sh ]; then \
28 ./autogen.sh; \
29 elif [ -f ./configure.ac ] || [ -f ./configure.in ]; then \
30 $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
31 $(patsubst %,-I %,$(PKG_LIBTOOL_PATHS)) $(PKG_LIBTOOL_PATHS); \
32 fi \
33 );
34 endef
35
36 Hooks/InstallDev/Post += libtool_remove_files
37
38 ifneq ($(filter libtool,$(PKG_FIXUP)),)
39 PKG_BUILD_DEPENDS += libtool
40 Hooks/Configure/Pre += autoreconf
41 Hooks/InstallDev/Post += libtool_fixup_libdir
42 endif
43
44 ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
45 PKG_BUILD_DEPENDS += libtool
46 Hooks/Configure/Pre += autoreconf
47 Hooks/InstallDev/Post += libtool_fixup_libdir
48 endif
49