Package: libtool
Version: 2.2.6a-4
Severity: normal

I tried to add --Wl,--as-needed to the library flags, but it seems that 
libtool adds this option after the -l arguments and makes it useless (it must 
stand before the libs and not after them).

Is there a workaround or can it be fixed in libtools? I saw different patches 
which does that, but maybe there is a more elegant way to do it.

The actual problem is that `pkg-config --libs gtk+-x11-2.0` isn't really fine 
grained and adds a lot of extra dependencies I don't use. --as-needed would be 
a nice way to fix it for me.


--- System information. ---
Architecture: amd64
Kernel:       Linux 2.6.31-1-amd64

Debian Release: squeeze/sid
  500 unstable        ftp.debian.org 

--- Package information. ---
Depends            (Version) | Installed
============================-+-===========
gcc                          | 4:4.3.4-1
 OR c-compiler               | 
cpp                          | 4:4.3.4-1
libc6-dev                    | 2.10.1-7
 OR libc-dev                 | 
file                         | 5.03-3
autotools-dev                | 20090611.1


Recommends       (Version) | Installed
==========================-+-===========
libltdl-dev                | 2.2.6a-4


Suggests                (Version) | Installed
=================================-+-===========
libtool-doc                       | 
autoconf                (>> 2.50) | 2.64-6
automaken                         | 
gfortran                          | 
 OR fortran95-compiler            | 
gcj                               | 




diff --git a/config/ltmain.sh b/config/ltmain.sh
index 0bf3848246321707ac514bb6566691c31aa4f08c..ec8e8d621cbad18b0769f2d32168f137a2765da2 100644
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -1807,6 +1807,11 @@ EOF
 	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
 	;;
 
+      -Wl,--as-needed)
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
       -Wl,*)
 	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
 	arg=
@@ -2150,6 +2155,15 @@ EOF
 	lib=
 	found=no
 	case $deplib in
+	-Wl,--as-needed)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    deplibs="$deplib $deplibs"
+	  fi
+	  continue
+	  ;;
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
 	  if test "$linkmode,$pass" = "prog,link"; then
 	    compile_deplibs="$deplib $compile_deplibs"

Reply via email to