updated/corrected documentation
[swftools.git] / ltmain.sh
index 46a9450..32384b6 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -48,6 +48,9 @@ EOF
   exit 0
 fi
 
+# define SED for historic ltconfig's generated by Libtool 1.3
+test -z "$SED" && SED=sed
+
 # The name of this program.
 progname=`$echo "$0" | ${SED} 's%^.*/%%'`
 modename="$progname"
@@ -55,8 +58,8 @@ modename="$progname"
 # Constants.
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.4.2a
-TIMESTAMP=" (1.922.2.100 2002/06/26 07:25:14)"
+VERSION=1.4.3
+TIMESTAMP=" (1.922.2.111 2002/10/23 02:54:36)"
 
 default_mode=
 help="Try \`$progname --help' for more information."
@@ -216,6 +219,17 @@ if test -n "$prevopt"; then
   exit 1
 fi
 
+# Mandrake: (gc) It's bad to link C++ code with GCC, so we need to use the compiler name if provided
+if test "$mode" = link && test -n "$archive_cmds" && test -x "/usr/bin/perl"; then
+    case $nonopt in
+    *cc | *++ | gcc* | *-gcc* | egcs*)
+           archive_cmds=`echo $archive_cmds | perl -pe 's/^\S+\s+//'`
+           archive_cmds="$nonopt $archive_cmds"
+           archive_expsym_cmds=`echo $archive_expsym_cmds | perl -pe 's/^\S+\s+//'`
+           archive_expsym_cmds="$nonopt $archive_expsym_cmds"
+    esac
+fi
+
 # If this variable is set in any of the actions, the command in it
 # will be execed at the end.  This prevents here-documents from being
 # left over by shells.
@@ -226,7 +240,7 @@ if test -z "$show_help"; then
   # Infer the operation mode.
   if test -z "$mode"; then
     case $nonopt in
-    *cc | *++ | gcc* | *-gcc*)
+    *cc | *++ | gcc* | *-gcc* | xlc*)
       mode=link
       for arg
       do
@@ -899,7 +913,7 @@ compiler."
          prev=
          continue
          ;;
-       inst_prefix)
+        inst_prefix)
          inst_prefix_dir="$arg"
          prev=
          continue
@@ -1006,9 +1020,9 @@ compiler."
        ;;
 
       -inst-prefix-dir)
-       prev=inst_prefix
-       continue
-       ;;
+       prev=inst_prefix
+       continue
+       ;;
 
       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
       # so, if we see these flags be careful not to treat them like -L
@@ -1857,14 +1871,6 @@ compiler."
                add="$dir/$linklib"
              elif test "$hardcode_minus_L" = yes; then
                add_dir="-L$dir"
-               # Try looking first in the location we're being installed to.
-               if test -n "$inst_prefix_dir"; then
-                 case "$libdir" in
-                 [\/]*)
-                   add_dir="-L$inst_prefix_dir$libdir $add_dir"
-                   ;;
-                 esac
-               fi
                add="-l$name"
              elif test "$hardcode_shlibpath_var" = yes; then
                add_shlibpath="$dir"
@@ -1912,7 +1918,16 @@ compiler."
            if test "$hardcode_direct" = yes; then
              add="$libdir/$linklib"
            elif test "$hardcode_minus_L" = yes; then
-             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             add_dir=
+             if test -n "$inst_prefix_dir"; then
+               case "$libdir" in
+               [\\/]*)
+                 add_dir="-L$inst_prefix_dir$libdir"
+                 ;;
+               esac
+             fi
+             add_dir="$add_dir -L$libdir"
              add="-l$name"
            elif test "$hardcode_shlibpath_var" = yes; then
              case :$finalize_shlibpath: in
@@ -1922,15 +1937,16 @@ compiler."
              add="-l$name"
            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.
+             add_dir=
              if test -n "$inst_prefix_dir"; then
                case "$libdir" in
-               [\/]*)
-                 add_dir="-L$inst_prefix_dir$libdir $add_dir"
+               [\\/]*)
+                 add_dir="-L$inst_prefix_dir$libdir"
                  ;;
                esac
              fi
+             add_dir="$add_dir -L$libdir"
              add="-l$name"
            fi
 
@@ -2263,7 +2279,7 @@ compiler."
 
        # Check that each of the things are valid numbers.
        case $current in
-       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+       [0-9]*) ;;
        *)
          $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
          $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2272,7 +2288,7 @@ compiler."
        esac
 
        case $revision in
-       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+       [0-9]*) ;;
        *)
          $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
          $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2281,7 +2297,7 @@ compiler."
        esac
 
        case $age in
-       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+       [0-9]*) ;;
        *)
          $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
          $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2350,7 +2366,7 @@ compiler."
          ;;
 
        osf)
-         major=`expr $current - $age`
+         major=.`expr $current - $age`
          versuffix=".$current.$age.$revision"
          verstring="$current.$age.$revision"
 
@@ -2638,6 +2654,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
@@ -3199,6 +3222,13 @@ EOF
        # On Rhapsody replace the C library is the System framework
        compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
        finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       case $host in
+       *darwin*)
+         # Don't allow lazy linking, it breaks C++ global constructors
+         compile_command="$compile_command ${wl}-bind_at_load"
+         finalize_command="$finalize_command ${wl}-bind_at_load"
+         ;;
+       esac
        ;;
       esac
 
@@ -3970,9 +4000,46 @@ fi\
                  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
                  exit 1
                fi
-               newdependency_libs="$newdependency_libs $libdir/$name"
+               # 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
+                 if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; 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.
+                 if test -n "`echo $deplib |grep -e "$S"`" && test "$S"; then
+                   mynewdependency_lib=""
+                 # We do not want portage's install root ($D) present.
+                 elif test -n "`echo $deplib |grep -e "$D"`" && 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
+                 if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; then
+                       newdependency_libs="$newdependency_libs $mynewdependency_lib"
+                 fi
+               fi
                ;;
-             *) newdependency_libs="$newdependency_libs $deplib" ;;
              esac
            done
            dependency_libs="$newdependency_libs"
@@ -4005,6 +4072,10 @@ fi\
          case $host,$output,$installed,$module,$dlname in
            *cygwin*,*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
@@ -4249,25 +4320,25 @@ relink_command=\"$relink_command\""
        dir="$dir$objdir"
 
        if test -n "$relink_command"; then
-          # Determine the prefix the user has applied to our future dir.
-          inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
-          # Don't allow the user to place us outside of our expected
-          # location b/c this prevents finding dependent libraries that
-          # are installed to the same prefix.
-          if test "$inst_prefix_dir" = "$destdir"; then
-            $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
-            exit 1
-          fi
-          if test -n "$inst_prefix_dir"; then
-            # Stick the inst_prefix_dir data into the link command.
-            relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
-          else
-            relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
-          fi
-
-         $echo "$modename: warning: relinking \`$file'" 1>&2
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         if test "$inst_prefix_dir" = "$destdir"; then
+           $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+           exit 1
+         fi
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
+         fi
+
+         $echo "$modename: warning: relinking \`$file'" 1>&2
          $show "$relink_command"
          if $run eval "$relink_command"; then :
          else
@@ -4435,7 +4506,11 @@ relink_command=\"$relink_command\""
            if test "$finalize" = yes && test -z "$run"; then
              tmpdir="/tmp"
              test -n "$TMPDIR" && tmpdir="$TMPDIR"
-             tmpdir="$tmpdir/libtool-$$"
+              tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null`
+              if test $? = 0 ; then :
+              else
+                tmpdir="$tmpdir/libtool-$$"
+              fi
              if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
              else
                $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2