Root/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
8define 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    
14endef
15
16PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
17
18# replace copies of ltmain.sh with the build system's version
19update_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    )
24update_libtool = \
25    $(foreach p,$(PKG_LIBTOOL_PATHS), \
26        $(call replace,libtool,$(STAGING_DIR)/host/bin,$(p)/) \
27    ) \
28    $(call update_libtool_common)
29update_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
35autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2))
36
37# prevent libtool from linking against host development libraries
38define libtool_fixup_libdir
39    find $(1) -name '*.la' | $(XARGS) \
40        $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" \
41            -e "s,$(STAGING_DIR)/usr/lib/\(libstdc++\|libsupc++\).la,$(TOOLCHAIN_DIR)/usr/lib/\1.la,g"
42endef
43
44define remove_version_check
45    if [ -f "$(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure" ]; then \
46        $(SED) \
47            's,\(gentoo\|pardus\)_ltmain_version=.*,\1_ltmain_version="$$$$\1_lt_version",' \
48            $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/configure; \
49    fi
50endef
51
52define autoreconf
53    (cd $(PKG_BUILD_DIR); \
54        $(patsubst %,rm -f %;,$(PKG_REMOVE_FILES)) \
55        if [ -x ./autogen.sh ]; then \
56            ./autogen.sh || true; \
57        elif [ -f ./configure.ac ] || [ -f ./configure.in ]; then \
58            [ -f ./aclocal.m4 ] && [ ! -f ./acinclude.m4 ] && mv aclocal.m4 acinclude.m4; \
59            [ -d ./autom4te.cache ] && rm -rf autom4te.cache; \
60            $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
61                -B $(STAGING_DIR)/host/share/aclocal \
62                $(patsubst %,-I %,$(PKG_LIBTOOL_PATHS)) $(PKG_LIBTOOL_PATHS) || true; \
63        fi \
64    );
65endef
66
67ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
68  Hooks/Configure/Pre += autoreconf
69endif
70
71ifneq ($(filter libtool,$(PKG_FIXUP)),)
72  PKG_BUILD_DEPENDS += libtool libintl libiconv
73  Hooks/Configure/Pre += update_libtool remove_version_check
74  Hooks/Configure/Post += update_libtool
75  Hooks/InstallDev/Post += libtool_fixup_libdir
76endif
77
78ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
79  PKG_BUILD_DEPENDS += libtool libintl libiconv
80  Hooks/Configure/Pre += update_libtool_ucxx remove_version_check
81  Hooks/Configure/Post += update_libtool_ucxx
82  Hooks/InstallDev/Post += libtool_fixup_libdir
83endif
84
85

Archive Download this file



interactive