autotools.mk: implement PKG_FIXUP:=patch-libtool This change allows to apply OpenWrt...
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 1 Aug 2011 00:22:53 +0000 (00:22 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 1 Aug 2011 00:22:53 +0000 (00:22 +0000)
SVN-Revision: 27855

include/autotools.mk
tools/libtool/files/libtool-v1.5.patch [new file with mode: 0644]
tools/libtool/files/libtool-v2.2.patch [new file with mode: 0644]
tools/libtool/files/libtool-v2.4.patch [new file with mode: 0644]

index 7fe376c..1472b5a 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2007-2010 OpenWrt.org
+# Copyright (C) 2007-2011 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -49,6 +49,20 @@ define autoreconf
        );
 endef
 
+# 1: build dir
+define patch_libtool
+       (cd $(1); \
+               for lt in $$$$($$(STAGING_DIR_HOST)/bin/find . -name ltmain.sh); do \
+                       lt_version="$$$$($$(STAGING_DIR_HOST)/bin/sed -ne 's,^[[:space:]]*VERSION=\([0-9]\.[0-9]\+\).*,\1,p' $$$$lt)"; \
+                       case "$$$$lt_version" in \
+                               1.5|2.2|2.4) echo "autotools.mk: Found libtool v$$$$lt_version - applying patch to $$$$lt"; \
+                                       (cd $$$$(dirname $$$$lt) && $$(PATCH) -s -p1 < $$(TOPDIR)/tools/libtool/files/libtool-v$$$$lt_version.patch) ;; \
+                               *) echo "autotools.mk: error: Unsupported libtool version v$$$$lt_version - cannot patch $$$$lt"; exit 1 ;; \
+                       esac; \
+               done; \
+       );
+endef
+
 
 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
 PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
@@ -64,6 +78,15 @@ define autoreconf_target
     $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
 endef
 
+define patch_libtool_target
+  $(strip $(call patch_libtool, \
+    $(PKG_BUILD_DIR)))
+endef
+
+ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
+  Hooks/Configure/Pre += patch_libtool_target
+endif
+
 ifneq ($(filter libtool,$(PKG_FIXUP)),)
   PKG_BUILD_DEPENDS += libtool libintl libiconv
  ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
@@ -98,6 +121,19 @@ define autoreconf_host
     $(HOST_MACRO_PATHS)))
 endef
 
+define patch_libtool_host
+  $(strip $(call patch_libtool, \
+    $(HOST_BUILD_DIR)))
+endef
+
+ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
+  Hooks/HostConfigure/Pre += patch_libtool_host
+endif
+
+ifneq ($(filter patch-libtool,$(HOST_FIXUP)),)
+  Hooks/HostConfigure/Pre += $(strip $(call patch_libtool,$(HOST_BUILD_DIR)))
+endif
+
 ifneq ($(filter libtool,$(HOST_FIXUP)),)
  ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
   Hooks/HostConfigure/Pre += autoreconf_host
diff --git a/tools/libtool/files/libtool-v1.5.patch b/tools/libtool/files/libtool-v1.5.patch
new file mode 100644 (file)
index 0000000..485dfc7
--- /dev/null
@@ -0,0 +1,118 @@
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -35,7 +35,7 @@ progpath="$0"
+ # The name of this program:
+ progname=`echo "$progpath" | $SED $basename`
+-modename="$progname"
++modename="OpenWrt-$progname-patched-1.5"
+ # Global variables:
+ EXIT_SUCCESS=0
+@@ -297,8 +297,8 @@ func_infer_tag ()
+       # line option must be used.
+       if test -z "$tagname"; then
+         $echo "$modename: unable to infer tagged configuration"
+-        $echo "$modename: specify a tag with \`--tag'" 1>&2
+-        exit $EXIT_FAILURE
++        $echo "$modename: defaulting to \`CC'"
++        $echo "$modename: if this is not correct, specify a tag with \`--tag'"
+ #        else
+ #          $echo "$modename: using $tagname tagged configuration"
+       fi
+@@ -2462,8 +2462,14 @@ EOF
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+-          dir="$libdir"
+-          absdir="$libdir"
++          # Adding 'libdir' from the .la file to our library search paths
++          # breaks crosscompilation horribly.  We cheat here and don't add
++          # it, instead adding the path where we found the .la.  -CL
++          dir="$lt_sysroot$abs_ladir"
++          absdir="$abs_ladir"
++          libdir="$abs_ladir"
++          #dir="$libdir"
++          #absdir="$libdir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+@@ -2602,7 +2608,7 @@ EOF
+          { test "$use_static_libs" = no || test -z "$old_library"; }; then
+         if test "$installed" = no; then
+           notinst_deplibs="$notinst_deplibs $lib"
+-          need_relink=yes
++          need_relink=no
+         fi
+         # This is a shared library
+@@ -2804,7 +2810,6 @@ EOF
+           if test "$hardcode_direct" = yes; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+-            add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+@@ -2820,8 +2825,6 @@ EOF
+               add="$libdir/$linklib"
+             fi
+           else
+-            # We cannot seem to hardcode it, guess we'll fake it.
+-            add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case $libdir in
+@@ -5687,6 +5690,10 @@ fi\
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
++            # Replacing uninstalled with installed can easily break crosscompilation,
++            # since the installed path is generally the wrong architecture.  -CL
++            newdependency_libs="$newdependency_libs $deplib"
++            continue
+             case $deplib in
+             *.la)
+               name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+@@ -5999,8 +6006,12 @@ relink_command=\"$relink_command\""
+       dir="$dir$objdir"
+       if test -n "$relink_command"; then
++        # Strip any trailing slash from the destination.
++        s_libdir=`$echo "X$libdir" | $Xsed -e 's%/$%%'`
++        s_destdir=`$echo "X$destdir" | $Xsed -e 's%/$%%'`
++
+         # Determine the prefix the user has applied to our future dir.
+-        inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
++        inst_prefix_dir=`$echo "$s_destdir" | $SED "s%$s_libdir\$%%"`
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+@@ -6008,10 +6019,13 @@ relink_command=\"$relink_command\""
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+-        if test "$inst_prefix_dir" = "$destdir"; then
+-          $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+-          exit $EXIT_FAILURE
+-        fi
++        #
++        # This breaks install into our staging area.  -PB
++        #
++        # if test "$inst_prefix_dir" = "$destdir"; then
++        #   $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
++        #   exit $EXIT_FAILURE
++        # fi
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+@@ -6020,6 +6034,9 @@ relink_command=\"$relink_command\""
+           relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
+         fi
++        relink_command=`$ECHO "$relink_command" | $SED "s%-L[[:space:]]*/lib[^[:space:]]*%%"`
++        relink_command=`$ECHO "$relink_command" | $SED "s%-L[[:space:]]*/usr/lib[^[:space:]]*%%"`
++
+         $echo "$modename: warning: relinking \`$file'" 1>&2
+         $show "$relink_command"
+         if $run eval "$relink_command"; then :
diff --git a/tools/libtool/files/libtool-v2.2.patch b/tools/libtool/files/libtool-v2.2.patch
new file mode 100644 (file)
index 0000000..03994ba
--- /dev/null
@@ -0,0 +1,123 @@
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -243,7 +243,7 @@ opt_warning=:
+ # name if it has been set yet.
+ func_echo ()
+ {
+-    $ECHO "$progname${mode+: }$mode: $*"
++    $ECHO "OpenWrt-$progname-patched-2.2${mode+: }$mode: $*"
+ }
+ # func_verbose arg...
+@@ -262,14 +262,14 @@ func_verbose ()
+ # Echo program name prefixed message to standard error.
+ func_error ()
+ {
+-    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
++    $ECHO "OpenWrt-$progname-patched-2.2${mode+: }$mode: "${1+"$@"} 1>&2
+ }
+ # func_warning arg...
+ # Echo program name prefixed warning message to standard error.
+ func_warning ()
+ {
+-    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
++    $opt_warning && $ECHO "OpenWrt-$progname-patched-2.2${mode+: }$mode: warning: "${1+"$@"} 1>&2
+     # bash bug again:
+     :
+@@ -1048,8 +1048,8 @@ func_infer_tag ()
+       # was found and let the user know that the "--tag" command
+       # line option must be used.
+       if test -z "$tagname"; then
+-        func_echo "unable to infer tagged configuration"
+-        func_fatal_error "specify a tag with \`--tag'"
++        func_echo "defaulting to \`CC'"
++        func_echo "if this is not correct, specify a tag with \`--tag'"
+ #     else
+ #       func_verbose "using $tagname tagged configuration"
+       fi
+@@ -2009,8 +2009,15 @@ func_mode_install ()
+       dir="$dir$objdir"
+       if test -n "$relink_command"; then
++        # Strip any trailing slash from the destination.
++        func_stripname '' '/' "$libdir"
++        s_libdir=$func_stripname_result
++
++        func_stripname '' '/' "$destdir"
++        s_destdir=$func_stripname_result
++
+         # Determine the prefix the user has applied to our future dir.
+-        inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
++        inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$s_libdir\$%%"`
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+@@ -2018,8 +2025,11 @@ func_mode_install ()
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+-        test "$inst_prefix_dir" = "$destdir" && \
+-          func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
++        #
++        # This breaks install into our staging area.  -PB
++        #
++        # test "$inst_prefix_dir" = "$destdir" && \
++        #   func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+@@ -2028,6 +2038,9 @@ func_mode_install ()
+           relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+         fi
++        relink_command=`$ECHO "$relink_command" | $SED "s%-L[[:space:]]*/lib[^[:space:]]*%%"`
++        relink_command=`$ECHO "$relink_command" | $SED "s%-L[[:space:]]*/usr/lib[^[:space:]]*%%"`
++
+         func_warning "relinking \`$file'"
+         func_show_eval "$relink_command" \
+           'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+@@ -5412,8 +5425,12 @@ func_mode_link ()
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+-          dir="$libdir"
+-          absdir="$libdir"
++          # Adding 'libdir' from the .la file to our library search paths
++          # breaks crosscompilation horribly.  We cheat here and don't add
++          # it, instead adding the path where we found the .la.  -CL
++          dir="$abs_ladir"
++          absdir="$abs_ladir"
++          libdir="$abs_ladir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+@@ -5564,7 +5581,7 @@ func_mode_link ()
+         *)
+           if test "$installed" = no; then
+             notinst_deplibs="$notinst_deplibs $lib"
+-            need_relink=yes
++            need_relink=no
+           fi
+           ;;
+         esac
+@@ -5768,7 +5785,6 @@ func_mode_link ()
+              test "$hardcode_direct_absolute" = no; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+-            add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+@@ -8052,6 +8068,10 @@ EOF
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
++            # Replacing uninstalled with installed can easily break crosscompilation,
++            # since the installed path is generally the wrong architecture.  -CL
++            newdependency_libs="$newdependency_libs $deplib"
++            continue
+             case $deplib in
+             *.la)
+               func_basename "$deplib"
diff --git a/tools/libtool/files/libtool-v2.4.patch b/tools/libtool/files/libtool-v2.4.patch
new file mode 100644 (file)
index 0000000..afc754a
--- /dev/null
@@ -0,0 +1,160 @@
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -443,7 +443,7 @@ opt_warning=:
+ # name if it has been set yet.
+ func_echo ()
+ {
+-    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
++    $ECHO "OpenWrt-$progname-patched-2.4: ${opt_mode+$opt_mode: }$*"
+ }
+ # func_verbose arg...
+@@ -469,14 +469,14 @@ func_echo_all ()
+ # Echo program name prefixed message to standard error.
+ func_error ()
+ {
+-    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
++    $ECHO "OpenWrt-$progname-patched-2.4: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
+ }
+ # func_warning arg...
+ # Echo program name prefixed warning message to standard error.
+ func_warning ()
+ {
+-    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
++    $opt_warning && $ECHO "OpenWrt-$progname-patched-2.4: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+     # bash bug again:
+     :
+@@ -1416,8 +1416,8 @@ func_infer_tag ()
+       # was found and let the user know that the "--tag" command
+       # line option must be used.
+       if test -z "$tagname"; then
+-        func_echo "unable to infer tagged configuration"
+-        func_fatal_error "specify a tag with \`--tag'"
++        func_echo "defaulting to \`CC'"
++        func_echo "if this is not correct, specify a tag with \`--tag'"
+ #     else
+ #       func_verbose "using $tagname tagged configuration"
+       fi
+@@ -2953,8 +2953,15 @@ func_mode_install ()
+       func_append dir "$objdir"
+       if test -n "$relink_command"; then
++        # Strip any trailing slash from the destination.
++        func_stripname '' '/' "$libdir"
++        s_libdir=$func_stripname_result
++
++        func_stripname '' '/' "$destdir"
++        s_destdir=$func_stripname_result
++
+         # Determine the prefix the user has applied to our future dir.
+-        inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
++        inst_prefix_dir=`$ECHO "$s_destdir" | $SED -e "s%$s_libdir\$%%"`
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+@@ -2962,8 +2969,11 @@ func_mode_install ()
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+-        test "$inst_prefix_dir" = "$destdir" && \
+-          func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
++        #
++        # This breaks install into our staging area.  -PB
++        #
++        # test "$inst_prefix_dir" = "$destdir" && \
++        #   func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+@@ -2972,6 +2982,9 @@ func_mode_install ()
+           relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+         fi
++        relink_command=`$ECHO "$relink_command" | $SED "s%-L[[:space:]]*/lib[^[:space:]]*%%"`
++        relink_command=`$ECHO "$relink_command" | $SED "s%-L[[:space:]]*/usr/lib[^[:space:]]*%%"`
++
+         func_warning "relinking \`$file'"
+         func_show_eval "$relink_command" \
+           'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+@@ -6504,8 +6517,12 @@ func_mode_link ()
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+-          dir="$lt_sysroot$libdir"
+-          absdir="$lt_sysroot$libdir"
++          # Adding 'libdir' from the .la file to our library search paths
++          # breaks crosscompilation horribly.  We cheat here and don't add
++          # it, instead adding the path where we found the .la.  -CL
++          dir="$lt_sysroot$abs_ladir"
++          absdir="$abs_ladir"
++          libdir="$abs_ladir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+@@ -6683,7 +6700,7 @@ func_mode_link ()
+         *)
+           if test "$installed" = no; then
+             func_append notinst_deplibs " $lib"
+-            need_relink=yes
++            need_relink=no
+           fi
+           ;;
+         esac
+@@ -6887,7 +6904,6 @@ func_mode_link ()
+              test "$hardcode_direct_absolute" = no; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+-            add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+@@ -6903,8 +6919,6 @@ func_mode_link ()
+               add="$libdir/$linklib"
+             fi
+           else
+-            # We cannot seem to hardcode it, guess we'll fake it.
+-            add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case $libdir in
+@@ -7059,7 +7073,17 @@ func_mode_link ()
+                 fi
+                 ;;
+               *)
+-                path="-L$absdir/$objdir"
++                # OE sets installed=no in staging. We need to look in $objdir and $absdir,
++                # preferring $objdir. RP 31/04/2008
++                if test -f "$absdir/$objdir/$depdepl" ; then
++                  depdepl="$absdir/$objdir/$depdepl"
++                  path="-L$absdir/$objdir"
++                elif test -f "$absdir/$depdepl" ; then
++                  depdepl="$absdir/$depdepl"
++                  path="-L$absdir"
++                else
++                  path="-L$absdir/$objdir"
++                fi
+                 ;;
+               esac
+               else
+@@ -8050,7 +8074,7 @@ EOF
+           elif test -n "$runpath_var"; then
+             case "$perm_rpath " in
+             *" $libdir "*) ;;
+-            *) func_apped perm_rpath " $libdir" ;;
++            *) func_append perm_rpath " $libdir" ;;
+             esac
+           fi
+         done
+@@ -9257,6 +9281,10 @@ EOF
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
++            # Replacing uninstalled with installed can easily break crosscompilation,
++            # since the installed path is generally the wrong architecture.  -CL
++            newdependency_libs="$newdependency_libs $deplib"
++            continue
+             case $deplib in
+             *.la)
+               func_basename "$deplib"