libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH-1.5] Backport func_extract_archives


From: Peter O'Gorman
Subject: [PATCH-1.5] Backport func_extract_archives
Date: Fri, 30 Jul 2004 11:18:34 +0900
User-agent: Mozilla Thunderbird 0.6 (Macintosh/20040502)

Okay to apply?

Peter
--
Peter O'Gorman - http://www.pogma.com

Index: ChangeLog
2004-07-30  Peter O'Gorman  <address@hidden>

        * libtool.m4 [darwin]: $GREP is not defined here, use $EGREP.
        * ltmain.in (func_extract_archives): Backport func_extract_archives
        from cvs HEAD to redude code size and enable the darwin fat archive
        extraction.

Index: libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/Attic/libtool.m4,v
retrieving revision 1.314.2.40
diff -u -3 -p -u -r1.314.2.40 libtool.m4
--- libtool.m4 28 Jul 2004 13:02:20 -0000 1.314.2.40
+++ libtool.m4 30 Jul 2004 02:16:07 -0000
@@ -2892,7 +2892,7 @@ case $host_os in
     if test "$GXX" = yes ; then
       lt_int_apple_cc_single_mod=no
       output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $GREP 'single_module' >/dev/null ; then
+      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
        lt_int_apple_cc_single_mod=yes
       fi
       if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/ltmain.in,v
retrieving revision 1.334.2.35
diff -u -3 -p -u -r1.334.2.35 ltmain.in
--- ltmain.in 28 Jul 2004 13:02:20 -0000 1.334.2.35
+++ ltmain.in 30 Jul 2004 02:16:10 -0000
@@ -240,6 +240,120 @@ func_infer_tag () {
       esac
     fi
 }
+# func_extract_archives gentop oldlib ...
+func_extract_archives () {
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+    my_status=""
+
+    $show "${rm}r $my_gentop"
+    $run ${rm}r "$my_gentop"
+    $show "$mkdir $my_gentop"
+    $run $mkdir "$my_gentop"
+    my_status=$?
+    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
+      exit $my_status
+    fi
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+       [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+       *) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
+      my_xdir="$my_gentop/$my_xlib"
+
+      $show "${rm}r $my_xdir"
+      $run ${rm}r "$my_xdir"
+      $show "$mkdir $my_xdir"
+      $run $mkdir "$my_xdir"
+      status=$?
+      if test "$status" -ne 0 && test ! -d "$my_xdir"; then
+       exit $status
+      fi
+      case $host in
+      *-darwin*)
+       $show "Extracting $my_xabs"
+       # Do not bother doing anything if just a dry run
+       if test -z "$run"; then
+         darwin_orig_dir=`pwd`
+         cd $my_xdir || exit $?
+         darwin_archive=$my_xabs
+         darwin_curdir=`pwd`
+         darwin_base_archive=`basename $darwin_archive`
+         darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP 
Architectures 2>/dev/null`
+         if test -n "$darwin_arches"; then 
+           darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
+           darwin_arch=
+           $show "$darwin_base_archive has multiple architectures 
$darwin_arches"
+           for darwin_arch in  $darwin_arches ; do
+             mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             lipo -thin $darwin_arch -output 
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 
"${darwin_archive}"
+             # Remove the table of contents from the thin files.
+             $AR -d 
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 
__.SYMDEF 2>/dev/null || true
+             $AR -d 
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 
__.SYMDEF\ SORTED 2>/dev/null || true
+             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             $AR -xo "${darwin_base_archive}"
+             rm "${darwin_base_archive}"
+             cd "$darwin_curdir"
+           done # $darwin_arches
+      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
+           darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | 
$NL2SP`
+           darwin_file=
+           darwin_files=
+           for darwin_file in $darwin_filelist; do
+             darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+             lipo -create -output "$darwin_file" $darwin_files
+           done # $darwin_filelist
+           rm -rf unfat-$$
+           cd "$darwin_orig_dir"
+         else
+           cd $darwin_orig_dir
+           (cd $my_xdir && $AR x $my_xabs) || exit $?
+         fi # $darwin_arches
+       fi # $run
+      ;;
+      *)
+       # We will extract separately just the conflicting names and we will
+       # no longer touch any unique names. It is faster to leave these
+       # extract automatically by $AR in one run.
+       $show "(cd $my_xdir && $AR x $my_xabs)"
+       $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
+       if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         $echo "$modename: warning: object name conflicts; renaming object 
files" 1>&2
+         $echo "$modename: warning: to ensure that they will not overwrite" 
1>&2
+         $AR t "$my_xabs" | sort | uniq -cd | while read -r count name
+         do
+           i=1
+           while test "$i" -le "$count"
+           do
+             # Put our $i before any first dot (extension)
+             # Never overwrite any file
+             name_to="$name"
+             while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to"
+             do
+               name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+             done
+             $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' 
'$name_to')"
+             $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv 
'$name' '$name_to')" || exit $?
+             i=`expr $i + 1`
+           done
+         done
+       fi
+       ;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name 
\*.lo -print | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
 # End of Shell function definitions
 #####################################
 
@@ -3687,67 +3801,13 @@ EOF
            eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
          else
            gentop="$output_objdir/${outputname}x"
-           $show "${rm}r $gentop"
-           $run ${rm}r "$gentop"
-           $show "$mkdir $gentop"
-           $run $mkdir "$gentop"
-           status=$?
-           if test "$status" -ne 0 && test ! -d "$gentop"; then
-             exit $status
-           fi
            generated="$generated $gentop"
 
-           for xlib in $convenience; do
-             # Extract the objects.
-             case $xlib in
-             [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
-             *) xabs=`pwd`"/$xlib" ;;
-             esac
-             xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
-             xdir="$gentop/$xlib"
-
-             $show "${rm}r $xdir"
-             $run ${rm}r "$xdir"
-             $show "$mkdir $xdir"
-             $run $mkdir "$xdir"
-             status=$?
-             if test "$status" -ne 0 && test ! -d "$xdir"; then
-               exit $status
-             fi
-             # We will extract separately just the conflicting names and we 
will no
-             # longer touch any unique names. It is faster to leave these 
extract
-             # automatically by $AR in one run.
-             $show "(cd $xdir && $AR x $xabs)"
-             $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
-             if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
-               :
-             else
-               $echo "$modename: warning: object name conflicts; renaming 
object files" 1>&2
-               $echo "$modename: warning: to ensure that they will not 
overwrite" 1>&2
-               $AR t "$xabs" | sort | uniq -cd | while read -r count name
-               do
-                 i=1
-                 while test "$i" -le "$count"
-                 do
-                  # Put our $i before any first dot (extension)
-                  # Never overwrite any file
-                  name_to="$name"
-                  while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
-                  do
-                    name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
-                  done
-                  $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' 
'$name_to')"
-                  $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv 
'$name' '$name_to')" || exit $?
-                  i=`expr $i + 1`
-                 done
-               done
-             fi
-
-             libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name 
\*.lo -print | $NL2SP`
-           done
+           func_extract_archives $gentop $convenience
+           libobjs="$libobjs $func_extract_archives_result"
          fi
        fi
-
+       
        if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
          eval flag=\"$thread_safe_flag_spec\"
          linker_flags="$linker_flags $flag"
@@ -3985,64 +4045,10 @@ EOF
          eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
        else
          gentop="$output_objdir/${obj}x"
-         $show "${rm}r $gentop"
-         $run ${rm}r "$gentop"
-         $show "$mkdir $gentop"
-         $run $mkdir "$gentop"
-         status=$?
-         if test "$status" -ne 0 && test ! -d "$gentop"; then
-           exit $status
-         fi
          generated="$generated $gentop"
 
-         for xlib in $convenience; do
-           # Extract the objects.
-           case $xlib in
-           [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
-           *) xabs=`pwd`"/$xlib" ;;
-           esac
-           xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
-           xdir="$gentop/$xlib"
-
-           $show "${rm}r $xdir"
-           $run ${rm}r "$xdir"
-           $show "$mkdir $xdir"
-           $run $mkdir "$xdir"
-           status=$?
-           if test "$status" -ne 0 && test ! -d "$xdir"; then
-             exit $status
-           fi
-           # We will extract separately just the conflicting names and we will 
no
-           # longer touch any unique names. It is faster to leave these extract
-           # automatically by $AR in one run.
-           $show "(cd $xdir && $AR x $xabs)"
-           $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
-           if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
-             :
-           else
-             $echo "$modename: warning: object name conflicts; renaming object 
files" 1>&2
-             $echo "$modename: warning: to ensure that they will not 
overwrite" 1>&2
-             $AR t "$xabs" | sort | uniq -cd | while read -r count name
-             do
-               i=1
-               while test "$i" -le "$count"
-               do
-                # Put our $i before any first dot (extension)
-                # Never overwrite any file
-                name_to="$name"
-                while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
-                do
-                  name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
-                done
-                $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' 
'$name_to')"
-                $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv 
'$name' '$name_to')" || exit $?
-                i=`expr $i + 1`
-               done
-             done
-           fi
-
-           reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print 
-o -name \*.lo -print | $NL2SP`
-         done
+         func_extract_archives $gentop $convenience
+         reload_conv_objs="$reload_objs $func_extract_archives_result"
        fi
       fi
 
@@ -5000,65 +5006,10 @@ fi\
 
       if test -n "$addlibs"; then
        gentop="$output_objdir/${outputname}x"
-       $show "${rm}r $gentop"
-       $run ${rm}r "$gentop"
-       $show "$mkdir $gentop"
-       $run $mkdir "$gentop"
-       status=$?
-       if test "$status" -ne 0 && test ! -d "$gentop"; then
-         exit $status
-       fi
        generated="$generated $gentop"
 
-       # Add in members from convenience archives.
-       for xlib in $addlibs; do
-         # Extract the objects.
-         case $xlib in
-         [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
-         *) xabs=`pwd`"/$xlib" ;;
-         esac
-         xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
-         xdir="$gentop/$xlib"
-
-         $show "${rm}r $xdir"
-         $run ${rm}r "$xdir"
-         $show "$mkdir $xdir"
-         $run $mkdir "$xdir"
-         status=$?
-         if test "$status" -ne 0 && test ! -d "$xdir"; then
-           exit $status
-         fi
-         # We will extract separately just the conflicting names and we will no
-         # longer touch any unique names. It is faster to leave these extract
-         # automatically by $AR in one run.
-         $show "(cd $xdir && $AR x $xabs)"
-         $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
-         if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
-           :
-         else
-           $echo "$modename: warning: object name conflicts; renaming object 
files" 1>&2
-           $echo "$modename: warning: to ensure that they will not overwrite" 
1>&2
-           $AR t "$xabs" | sort | uniq -cd | while read -r count name
-           do
-             i=1
-             while test "$i" -le "$count"
-             do
-              # Put our $i before any first dot (extension)
-              # Never overwrite any file
-              name_to="$name"
-              while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
-              do
-                name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
-              done
-              $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' 
'$name_to')"
-              $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' 
'$name_to')" || exit $?
-              i=`expr $i + 1`
-             done
-           done
-         fi
-
-         oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name 
\*.lo -print | $NL2SP`
-       done
+       func_extract_archives $gentop $addlibs
+       oldobjs="$oldobjs $func_extract_archives_result"
       fi
 
       # Do each command in the archive commands.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]