]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* config/ltmain.m4sh (func_extract_archives,func_extract_an_archive):
authorPeter O'Gorman <peter@pogma.com>
Mon, 20 Dec 2004 15:03:39 +0000 (15:03 +0000)
committerPeter O'Gorman <peter@pogma.com>
Mon, 20 Dec 2004 15:03:39 +0000 (15:03 +0000)
On darwin, uniq can not take the flags -cd together, thanks to Ralf
for the fix, also ar does not accept N, so we use the fact that
ar x libfoo.a foo.o will always extract the first foo.o in the
archive and we then delete foo.o from the archive, which will also
delete only the first foo.o, then rinse and repeat. Also add markers
for the testuite.
* m4/libtool.m4 (_LT_CONFIG): Add a marker so that we can use a sed
expression to find the shell functions in libtool.
* tests/functests.at: Test this feature.
* tests/testsuite.at: Add the test.
* tests/Makefile.am: Add the test.

ChangeLog
config/ltmain.m4sh
m4/libtool.m4
tests/Makefile.am
tests/functests.at [new file with mode: 0644]
tests/testsuite.at

index ebe1596571174521d77b42f5d3cb70c7dabedf88..71409f1fee4ec4a941509adafba3bf21b0cb7166 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2004-12-20  Peter O'Gorman  <peter@pogma.com>
+
+       * config/ltmain.m4sh (func_extract_archives,func_extract_an_archive): 
+       On darwin, uniq can not take the flags -cd together, thanks to Ralf
+       for the fix, also ar does not accept N, so we use the fact that
+       ar x libfoo.a foo.o will always extract the first foo.o in the
+       archive and we then delete foo.o from the archive, which will also
+       delete only the first foo.o, then rinse and repeat. Also add markers
+       for the testuite.
+       * m4/libtool.m4 (_LT_CONFIG): Add a marker so that we can use a sed
+       expression to find the shell functions in libtool.
+       * tests/functests.at: Test this feature.
+       * tests/testsuite.at: Add the test.
+       * tests/Makefile.am: Add the test.
+
 2004-12-20  Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
 
        * libtoolize.m4sh: Install `install-sh' as well, needed for configure ..
index 4ec171959904543d963dadcb192d467a39196733..1ec0fd8e408cde2a951519b2fecd26467abc0f79 100644 (file)
@@ -393,6 +393,7 @@ Otherwise, only FILE itself is deleted using RM."
     exit $EXIT_SUCCESS
 }
 
+# TEST SUITE MARKER ## NON-FUNCTION
 # Parse options once, thoroughly.  This comes as soon as possible in
 # the script to make things like `libtool --version' happen quickly.
 {
@@ -535,7 +536,7 @@ Otherwise, only FILE itself is deleted using RM."
   # anything was wrong.
   $exit_cmd $EXIT_FAILURE
 }
-
+# TEST SUITE MARKER ## BEGIN SOURCABLE
 
 # func_check_version_match
 # Ensure that we are using m4 macros, and libtool script from the same
@@ -960,6 +961,42 @@ static const void *lt_preloaded_setup() {
     fi
 }
 
+# func_extract_an_archive dir oldlib
+func_extract_an_archive () {
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_basename "$f_ex_an_ar_oldlib"
+      f_ex_an_ar_lib="$func_basename_result"
+      func_warning "$modename: warning: object name conflicts; renaming object files" 1>&2
+      func_warning "$modename: warning: to ensure that they will not overwrite" 1>&2
+      func_show_eval "cp \$f_ex_an_ar_oldlib \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
+      $AR t "$f_ex_an_ar_oldlib" | sort | uniq -c | while read -r count name
+      do
+       # We don't want to do anything to objects with unique names
+        test "$count" -eq 1 && continue
+       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 "$f_ex_an_ar_dir/$name_to"
+           do
+           name_to=`$ECHO "X$name_to" | $Xsed -e "s/\([[^.]]*\)/\1-$i/"`
+         done
+         func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_lib '$name' && $MV '$name' '$name_to' && $AR d \$f_ex_an_ar_lib '$name')" || exit $?
+         i=`expr $i + 1`
+       done
+      done
+      func_show_eval "$RM \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
+    fi
+}
+
+
 # func_extract_archives gentop oldlib ...
 func_extract_archives () {
     my_gentop="$1"; shift
@@ -991,7 +1028,7 @@ func_extract_archives () {
          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`
+         darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
          if test -n "$darwin_arches"; then
            darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
            darwin_arch=
@@ -1000,12 +1037,10 @@ func_extract_archives () {
              func_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"
+             $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
+             func_extract_an_archive "unfat-$$/${darwin_base_archive}-${darwin_arch}" "${darwin_base_archive}"
+             $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
            done # $darwin_arches
             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
            darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
@@ -1019,38 +1054,12 @@ func_extract_archives () {
            cd "$darwin_orig_dir"
          else
            cd $darwin_orig_dir
-           (cd $my_xdir && $AR x $my_xabs) || exit $?
+           func_extract_an_archive "$my_xdir" "$my_xabs"
          fi # $darwin_arches
        } # !$opt_dry_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.
-       func_show_eval '(cd $my_xdir && $AR x $my_xabs)' 'exit $?'
-
-       if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
-         :
-       else
-         func_warning "object name conflicts; renaming object files"
-         func_warning "to ensure that they will not overwrite"
-         $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
-             func_show_eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $MV '$name' '$name_to')" 'exit $?'
-             i=`expr $i + 1`
-           done
-         done
-       fi
+        func_extract_an_archive "$my_xdir" "$my_xabs"
        ;;
       esac
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
@@ -6623,7 +6632,7 @@ func_mode_uninstall ()
 }
 
 
-
+# TEST SUITE MARKER ## NON-FUNCTION
 ## ----------- ##
 ##    Main.    ##
 ## ----------- ##
index 4bee33d5edd18fc5c07c1702e4363ff16988a493..8a0da3aa611a8d261fbc5e42ab9d70238b5f3aa8 100644 (file)
@@ -495,7 +495,7 @@ m4_defun([_LT_CONFIG],
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
 _LT_COPYING
-
+# TEST SUITE MARKER ## BEGIN SOURCABLE
 _LT_LIBTOOL_TAGS
 
 # ### BEGIN LIBTOOL CONFIG
index 5f58bfd2d7906ebb7a0e4310aafada831ccbb86c..7854c68a67a2a2edee698f96f46370195c857485 100644 (file)
@@ -23,7 +23,8 @@
 
 TESTSUITE      = testsuite
 TESTSUITE_AT   = testsuite.at \
-                 am-subdir.at
+                 am-subdir.at \
+                 functests.at
 
 EXTRA_DIST     = $(TESTSUITE) $(TESTSUITE_AT) package.m4
 
diff --git a/tests/functests.at b/tests/functests.at
new file mode 100644 (file)
index 0000000..e6a0522
--- /dev/null
@@ -0,0 +1,103 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2004 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
+AT_BANNER([Libtool's shell function tests.])
+
+AT_SETUP([func_extract_archives tests])
+
+sed -n -e '/^# TEST SUITE MARKER ## BEGIN SOURCABLE$/,/^# TEST SUITE MARKER ## NON-FUNCTION$/p' < ${abs_top_builddir}/libtool > ltdefs
+
+AT_DATA(func_extract_archives,
+[[#! /bin/sh
+# func_extract_archives
+. ./ltdefs
+SED=${SED-sed}
+Xsed="$SED -e s/^X//"
+progname=libtool
+mode=testing
+case $host in 
+*darwin*)
+  for afile in baz foobar foobaz
+  do
+    echo "ppc $afile" > $afile.ppc.o
+    echo "m68k $afile" > $afile.m68k.o
+    echo "i386 $afile" > $afile.i386.o
+    lipo -create -output $afile.o -arch ppc $afile.ppc.o -arch m68k \
+      $afile.m68k.o -arch i386 $afile.i386.o
+    rm -f $afile.*.o
+    ar -q libfoo.a $afile.o
+    rm -f $afile.o
+  done
+  for anum in 1 2 3 4 5 6 7 8 9 10 11 12
+  do
+    echo "ppc foo $anum" > foo.ppc.o
+    echo "m68k foo $anum" > foo.m68k.o
+    echo "i386 foo $anum" > foo.i386.o
+    lipo -create -output foo.o -arch ppc foo.ppc.o -arch m68k foo.m68k.o \
+      -arch i386 foo.i386.o
+    ar -q libfoo.a foo.o
+    rm -f foo.o foo.*.o
+    echo "ppc bar $anum" > bar.ppc.o
+    echo "m68k bar $anum" > bar.m68k.o
+    echo "i386 bar $anum" > bar.i386.o
+    lipo -create -output bar.o -arch ppc bar.ppc.o -arch m68k bar.m68k.o \
+      -arch i386 bar.i386.o
+    ar -q libfoo.a bar.o
+  done
+  test -d .libs || mkdir .libs
+  func_extract_archives ".libs/libfoo" "libfoo.a"
+  for anum in 1 2 3 4 5 6 7 8 9 10 11 12
+  do
+    test -f ".libs/libfoo/libfoo.a/foo-$anum.o" || exit 1
+    $EGREP -v "foo-$anum" ".libs/libfoo/libfoo.a/foo-$anum.o" || exit 1
+    rm -f ".libs/libfoo/libfoo.a/foo-$anum.o"
+  done
+esac
+rm -f foo.o bar.o libfoo.a
+
+for afile in baz foobar foobaz
+do
+    echo "$afile" > $afile.o
+    ar -q libfoo.a $afile.o
+    rm -f $afile.o
+done
+for anum in 1 2 3 4 5 6 7 8 9 10 11 12
+do
+    echo "foo $anum" > foo.o
+    echo "bar $anum" > bar.o
+    ar -q libfoo.a foo.o bar.o
+done
+test -d .libs || mkdir .libs
+
+func_extract_archives ".libs/libfoo" "libfoo.a"
+for anum in 1 2 3 4 5 6 7 8 9 10 11 12
+do
+  test -f ".libs/libfoo/libfoo.a/foo-$anum.o" || exit 1
+  $EGREP -v "foo-$anum" ".libs/libfoo/libfoo.a/foo-$anum.o" || exit 1
+  rm -f ".libs/libfoo/libfoo.a/foo-$anum.o"
+done
+rm -rf ".libs/libfoo"
+exit 0
+]])
+
+chmod +x func_extract_archives
+
+AT_CHECK([./func_extract_archives],[0],[ignore],[ignore])
+
+AT_CLEANUP
index 2eeb785d86d29cccef87d9a88ef504ee6cee3bfd..76ff23b67781a93f970d883cfa42f073fa1a1fd0 100644 (file)
@@ -62,3 +62,4 @@ AT_INIT
 
 # Torturing subdir-objects builds
 m4_include([am-subdir.at])
+m4_include([functests.at])