From: Peter O'Gorman Date: Tue, 20 Jul 2004 14:53:11 +0000 (+0000) Subject: * ltmain.in [darwin](func_extract_archives): Because fat archives X-Git-Tag: release-1-9b~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a472ccc2b90cdb2923228a99806d712f6f07ded7;p=thirdparty%2Flibtool.git * ltmain.in [darwin](func_extract_archives): Because fat archives on darwin can not be extracted using ar, we need to use lipo to extract the thin archives and then use lipo again to generate the individual fat objects. This should allow people to run configure with CC set to "cc -arch ppc -arch ppc64" or "cc -arch ppc -arch i386" or whatever to match the toolchain they have available. --- diff --git a/ChangeLog b/ChangeLog index 722f550f2..602d761b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-07-18 Peter O'Gorman + + * ltmain.in [darwin](func_extract_archives): Because fat archives + on darwin can not be extracted using ar, we need to use lipo to + extract the thin archives and then use lipo again to generate the + individual fat objects. This should allow people to run configure + with CC set to "cc -arch ppc -arch ppc64" or "cc -arch ppc -arch + i386" or whatever to match the toolchain they have available. + 2004-07-18 Greg Eisenhauer * libltdl/loaders/Makefile.am: Use AM_MAKEFLAGS not MAKEFLAGS. diff --git a/ltmain.in b/ltmain.in index 7dc49b96b..9666660ac 100644 --- a/ltmain.in +++ b/ltmain.in @@ -515,36 +515,76 @@ func_extract_archives () { if test "$status" -ne 0 && test ! -d "$my_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 $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" + case $host in + *-darwin*) + darwin_orig_dir=`pwd` + $show "cd $my_xdir" + $run eval "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 | grep Architectures 2>/dev/null` + if test -n "$darwin_arches"; then + darwin_arches=`echo "$darwin_arches" | sed -e 's/.*are://'` + darwin_arch= + 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. + $run eval "$AR -d unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive} __.SYMDEF 2>/dev/null|| true" + $run eval "$AR -d unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive} __.SYMDEF\ SORTED 2>/dev/null|| true" + cd unfat-$$/${darwin_base_archive}-${darwin_arch} + $run eval "$AR -xo ${darwin_base_archive}" + $run eval "rm ${darwin_base_archive}" + cd $darwin_curdir + done + ## 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` + eval "lipo -create -output $darwin_file $darwin_files" + done + rm -rf unfat-$$ + cd $darwin_orig_dir + else + cd $darwin_orig_dir + $show "(cd $my_xdir && $AR x $my_xabs)" + $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $? + 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 $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 - # 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" + i=1 + while test "$i" -le "$count" do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + # 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 - $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 - + fi + ;; + esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done