0.6.1.20061108-1 release
[manu/suphp.git] / config / ltmain.sh
index e0d11c7..8f7a6ac 100644 (file)
@@ -33,6 +33,9 @@ basename="s,^.*/,,g"
 # function.
 progpath="$0"
 
+# define SED for historic ltconfig's generated by Libtool 1.3
+test -z "$SED" && SED=sed
+
 # The name of this program:
 progname=`echo "$progpath" | $SED $basename`
 modename="$progname"
@@ -43,7 +46,7 @@ EXIT_FAILURE=1
 
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION="1.5.22 Debian 1.5.22-1"
+VERSION=1.5.22
 TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
 
 # See if we are running on zsh, and set the options which allow our
@@ -51,6 +54,13 @@ TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
 if test -n "${ZSH_VERSION+set}" ; then
   setopt NO_GLOB_SUBST
 fi
+# Same for EGREP, and just to be sure, do LTCC as well
+if test "X$EGREP" = X ; then
+    EGREP=egrep
+fi
+if test "X$LTCC" = X ; then
+    LTCC=${CC-gcc}
+fi
 
 # Check that we have a working $echo.
 if test "X$1" = X--no-reexec; then
@@ -137,6 +147,30 @@ preserve_args=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
 
+if test -z "$max_cmd_len"; then
+  i=0
+  testring="ABCD"
+  new_result=
+  
+  # If test is not a shell built-in, we'll probably end up computing a
+  # maximum length that is only half of the actual maximum length, but
+  # we can't tell.
+  while (test "X"`$SHELL $0 --fallback-echo "X$testring" 2>/dev/null` \
+             = "XX$testring") >/dev/null 2>&1 &&
+          new_result=`expr "X$testring" : ".*" 2>&1` &&
+          max_cmd_len="$new_result" &&
+          test "$i" != 17 # 1/2 MB should be enough
+  do
+    i=`expr $i + 1`
+    testring="$testring$testring"
+  done
+  testring=
+  # Add a significant safety factor because C++ compilers can tack on massive
+  # amounts of additional arguments before passing them to the linker.
+  # It appears as though 1/2 is a usable value.
+  max_cmd_len=`expr $max_cmd_len \/ 2`
+fi
+
 #####################################
 # Shell function definitions:
 # This seems to be the best place for them
@@ -257,7 +291,21 @@ func_infer_tag ()
            esac
            CC_quoted="$CC_quoted $arg"
          done
+           # user sometimes does CC=<HOST>-gcc so we need to match that to 'gcc'
+           trimedcc=`echo ${CC} | $SED -e "s/${host}-//g"`
+           # and sometimes libtool has CC=<HOST>-gcc but user does CC=gcc
+           extendcc=${host}-${CC}
+           # and sometimes libtool has CC=<OLDHOST>-gcc but user has CC=<NEWHOST>-gcc  
+           # (Gentoo-specific hack because we always export $CHOST)
+           mungedcc=${CHOST-${host}}-${trimedcc}
            case "$@ " in
+             "cc "* | " cc "* | "${host}-cc "* | " ${host}-cc "*|\
+             "gcc "* | " gcc "* | "${host}-gcc "* | " ${host}-gcc "*)
+             tagname=CC
+             break ;;
+             "$trimedcc "* | " $trimedcc "* | "`$echo $trimedcc` "* | " `$echo $trimedcc` "*|\
+             "$extendcc "* | " $extendcc "* | "`$echo $extendcc` "* | " `$echo $extendcc` "*|\
+             "$mungedcc "* | " $mungedcc "* | "`$echo $mungedcc` "* | " `$echo $mungedcc` "*|\
              " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
              # The compiler in the base compile command matches
              # the one in the tagged configuration.
@@ -851,7 +899,7 @@ if test -z "$show_help"; then
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
     if test "$need_locks" = yes; then
-      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
+      until $run ln "$srcfile" "$lockfile" 2>/dev/null; do
        $show "Waiting for $lockfile to be removed"
        sleep 2
       done
@@ -2082,10 +2130,7 @@ EOF
        case $pass in
        dlopen) libs="$dlfiles" ;;
        dlpreopen) libs="$dlprefiles" ;;
-       link)
-         libs="$deplibs %DEPLIBS%"
-         test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
-         ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
        esac
       fi
       if test "$pass" = dlopen; then
@@ -3204,11 +3249,6 @@ EOF
            age="$number_minor"
            revision="$number_minor"
            ;;
-         *)
-           $echo "$modename: unknown library version type \`$version_type'" 1>&2
-           $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
-           exit $EXIT_FAILURE
-           ;;
          esac
          ;;
        no)
@@ -3650,6 +3690,13 @@ EOF
                        *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
                        esac
                      done
+                     # It is ok to link against an archive when
+                     # building a shared library.
+                     if $AR -t $potlib > /dev/null 2>&1; then
+                       newdeplibs="$newdeplibs $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
                      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
                         | ${SED} 10q \
                         | $EGREP "$file_magic_regex" > /dev/null; then
@@ -5387,6 +5434,11 @@ else
        $echo >> $output "\
     if test \"\$libtool_execute_magic\" != \"$magic\"; then
       # Run the actual program with our arguments.
+
+      # Make sure env LD_LIBRARY_PATH does not mess us up
+      if test -n \"\${LD_LIBRARY_PATH+set}\"; then
+        export LD_LIBRARY_PATH=\$progdir:\$LD_LIBRARY_PATH
+      fi
 "
        case $host in
        # Backslashes separate directories on plain windows
@@ -5614,9 +5666,53 @@ fi\
                  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
                  exit $EXIT_FAILURE
                fi
-               newdependency_libs="$newdependency_libs $libdir/$name"
+               if test "X$EGREP" = X ; then
+                       EGREP=egrep
+               fi
+               # We do not want portage's install root ($D) present.  Check only for
+               # this if the .la is being installed.
+               if test "$installed" = yes && test "$D"; then
+                 eval mynewdependency_lib=`echo "$libdir/$name" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
+               else
+                 mynewdependency_lib="$libdir/$name"
+               fi
+               # Do not add duplicates
+               if test "$mynewdependency_lib"; then
+                 my_little_ninja_foo_1=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
+                 if test -z "$my_little_ninja_foo_1"; then
+                   newdependency_libs="$newdependency_libs $mynewdependency_lib"
+                 fi
+               fi
+               ;;
+                 *)
+               if test "$installed" = yes; then
+                 # Rather use S=WORKDIR if our version of portage supports it.
+                 # This is because some ebuild (gcc) do not use $S as buildroot.
+                 if test "$PWORKDIR"; then
+                   S="$PWORKDIR"
+                 fi
+                 # We do not want portage's build root ($S) present.
+                 my_little_ninja_foo_2=`echo $deplib |$EGREP -e "$S"`
+                 # We do not want portage's install root ($D) present.
+                 my_little_ninja_foo_3=`echo $deplib |$EGREP -e "$D"`
+                 if test -n "$my_little_ninja_foo_2" && test "$S"; then
+                   mynewdependency_lib=""
+                 elif test -n "$my_little_ninja_foo_3" && test "$D"; then
+                   eval mynewdependency_lib=`echo "$deplib" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
+                 else
+                   mynewdependency_lib="$deplib"
+                 fi
+               else
+                 mynewdependency_lib="$deplib"
+               fi
+               # Do not add duplicates
+               if test "$mynewdependency_lib"; then
+                 my_little_ninja_foo_4=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
+                 if test -z "$my_little_ninja_foo_4"; then
+                       newdependency_libs="$newdependency_libs $mynewdependency_lib"
+                 fi
+               fi
                ;;
-             *) newdependency_libs="$newdependency_libs $deplib" ;;
              esac
            done
            dependency_libs="$newdependency_libs"
@@ -5668,6 +5764,10 @@ fi\
          case $host,$output,$installed,$module,$dlname in
            *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
          esac
+         # Do not add duplicates
+         if test "$installed" = yes && test "$D"; then
+           install_libdir=`echo "$install_libdir" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
+         fi
          $echo > $output "\
 # $outputname - a libtool library file
 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP