]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Allow Microsoft lib to be used as the archiver.
authorPeter Rosin <peda@lysator.liu.se>
Sat, 2 Aug 2008 12:54:10 +0000 (14:54 +0200)
committerPeter Rosin <peda@lysator.liu.se>
Tue, 13 Jan 2009 09:02:57 +0000 (10:02 +0100)
* libltdl/m4/libtool.m4 (_LT_PROG_AR): New macro, detect the
interface used by the archiver. In particular, add the AR_SEP
variable to allow archivers that does not allow a space between
the options to create an archive and the archive name and the
ar_extract_one_by_one variable which indicates if the archiver
can extract all members in one go.
* libltdl/m4/libtool.m4: Add $AR_SEP between $AR_FLAGS and the
archive file name in all $AR commands.
* libltdl/config/ltmain.m4sh (func_extract_an_archive): Add support
for archivers that only supports extracting one member at a time
and otherwise adjust to the above libtool.m4 changes. Also, add
$AR_SEP to the $AR invocations.
* Makefile.am: Pass AR, AR_FLAGS and AR_SEP through to the
testsuite.
* tests/archive-in-archive.at: Extract archive name from the .la
file instead of hardcoding the name, and allow different archivers.

ChangeLog
Makefile.am
libltdl/config/ltmain.m4sh
libltdl/m4/libtool.m4
tests/archive-in-archive.at

index 9ba522dd196982243dc998da4969f72528c5b871..9fb8df597cc2bcb8a2ea65d15712005aa3e52a75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-08-02  Peter Rosin  <peda@lysator.liu.se>
+
+       Allow Microsoft lib to be used as the archiver.
+       * libltdl/m4/libtool.m4 (_LT_PROG_AR): New macro, detect the
+       interface used by the archiver. In particular, add the AR_SEP
+       variable to allow archivers that does not allow a space between
+       the options to create an archive and the archive name and the
+       ar_extract_one_by_one variable which indicates if the archiver
+       can extract all members in one go.
+       * libltdl/m4/libtool.m4: Add $AR_SEP between $AR_FLAGS and the
+       archive file name in all $AR commands.
+       * libltdl/config/ltmain.m4sh (func_extract_an_archive): Add support
+       for archivers that only supports extracting one member at a time
+       and otherwise adjust to the above libtool.m4 changes. Also, add
+       $AR_SEP to the $AR invocations.
+       * Makefile.am: Pass AR, AR_FLAGS and AR_SEP through to the
+       testsuite.
+       * tests/archive-in-archive.at: Extract archive name from the .la
+       file instead of hardcoding the name, and allow different archivers.
+
 2008-12-19  Akim Demaille  <demaille@gostai.com>
 
        Fix copyright notice.
index 86224e189716d360bcf08c34bc8f0b844a21efda..089a482603135481982442de3d7638d28b77b23e 100644 (file)
@@ -496,6 +496,7 @@ EXTRA_DIST     += $(srcdir)/$(TESTSUITE) $(TESTSUITE_AT) $(srcdir)/tests/package
 TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
        CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \
        LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \
+       AR="$(AR)" AR_FLAGS="${AR_FLAGS}" AR_SEP="${AR_SEP}" \
        STRIP="$(STRIP)" INSTALL="$(INSTALL)" \
        OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \
        SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \
index 20ca07bbe9c9df6a6d8c27c342b33c694fcba19e..432c8e57b3395651be8710d0d8df5743ebb2a327 100644 (file)
@@ -2216,8 +2216,15 @@ func_extract_an_archive ()
     $opt_debug
     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
+    if test "X$ar_extract_one_by_one" != "Xyes"; then
+      func_show_eval "(cd \$f_ex_an_ar_dir && $AR ${AR_XFLAGS}${AR_SEP}\"\$f_ex_an_ar_oldlib\")" 'exit $?'
+    else
+      $AR ${AR_TFLAGS}${AR_SEP}"$f_ex_an_ar_oldlib" | while read name
+      do
+       func_show_eval "(cd \$f_ex_an_ar_dir && $AR ${AR_XFLAGS}${AR_SEP}\$name \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+      done
+    fi
+    if ($AR ${AR_TFLAGS}${AR_SEP}"$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
      :
     else
       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
index b7b566d274b0c8bac5d2fca90ec68139515c58f9..fb7f3e22b0c4a68c4ee7a5d24d35517f74d8983b 100644 (file)
@@ -1280,14 +1280,62 @@ need_locks="$enable_libtool_lock"
 ])# _LT_ENABLE_LOCK
 
 
+# _LT_PROG_AR
+# -----------
+m4_defun([_LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar lib "link -lib"], false)
+: ${AR=ar}
+_LT_DECL([], [AR], [1], [The archiver])
+
+AC_CACHE_CHECK([the archiver ($AR) interface],[lt_cv_ar_interface],
+  [lt_cv_ar_interface="ar"
+  printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+  (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval "$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext" &>conftest.err)
+  ac_status=$?
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  test $ac_status = 0 && test -f conftest.lib && lt_cv_ar_interface="lib"
+  rm -f conftest*])
+
+case $lt_cv_ar_interface in
+ar)
+  : ${AR_FLAGS=cru}
+  : ${AR_TFLAGS=t}
+  : ${AR_XFLAGS=x}
+  test -z "$AR_SEP" && AR_SEP=' '
+  _LT_TAGVAR(ar_extract_one_by_one, $1)=no
+  ;;
+lib)
+  : ${AR_FLAGS="-NOLOGO -OUT:"}
+  : ${AR_TFLAGS="-NOLOGO -LIST "}
+  : ${AR_XFLAGS="-NOLOGO -EXTRACT:"}
+  test -z "$AR_SEP" && AR_SEP=''
+  _LT_TAGVAR(ar_extract_one_by_one, $1)=yes
+  # Don't use ranlib
+  : ${RANLIB=:}
+  ;;
+esac
+
+_LT_DECL([], [ar_extract_one_by_one], [1],
+  [Extract archive members one by one])
+
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
+_LT_DECL([], [AR_TFLAGS], [1], [Flags to list archive content])
+_LT_DECL([], [AR_XFLAGS], [1], [Flags to extract an archive])
+_LT_DECL([], [AR_SEP], [1], [Separator between AR flags and AR files])
+AC_SUBST([AR])
+AC_SUBST([AR_FLAGS])
+AC_SUBST([AR_TFLAGS])
+AC_SUBST([AR_SEP])
+])# LT_PROG_AR
+
+
 # _LT_CMD_OLD_ARCHIVE
 # -------------------
 m4_defun([_LT_CMD_OLD_ARCHIVE],
-[AC_CHECK_TOOL(AR, ar, false)
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-_LT_DECL([], [AR], [1], [The archiver])
-_LT_DECL([], [AR_FLAGS], [1])
+[_LT_PROG_AR
 
 AC_CHECK_TOOL(STRIP, strip, :)
 test -z "$STRIP" && STRIP=:
@@ -1299,7 +1347,7 @@ _LT_DECL([], [RANLIB], [1],
     [Commands used to install an old-style archive])
 
 # Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_archive_cmds='$AR $AR_FLAGS$AR_SEP$oldlib$oldobjs'
 old_postinstall_cmds='chmod 644 $oldlib'
 old_postuninstall_cmds=
 
@@ -4242,7 +4290,7 @@ _LT_EOF
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS$AR_SEP$lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
             _LT_TAGVAR(hardcode_minus_L, $1)=yes
         ;;
@@ -4461,7 +4509,7 @@ _LT_EOF
     aix3*)
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_TAGVAR(always_export_symbols, $1)=yes
-      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS$AR_SEP$lib $output_objdir/$soname'
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -4591,7 +4639,7 @@ _LT_EOF
          _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
          _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
          # This is similar to how AIX traditionally builds its shared libraries.
-         _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+         _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS$AR_SEP$output_objdir/$libname$release.a $output_objdir/$soname'
        fi
       fi
       ;;
@@ -4604,7 +4652,7 @@ _LT_EOF
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS$AR_SEP$lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
             _LT_TAGVAR(hardcode_minus_L, $1)=yes
         ;;
@@ -5547,7 +5595,7 @@ if test "$_lt_caught_CXX_error" != yes; then
            _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
            # This is similar to how AIX traditionally builds its shared
            # libraries.
-           _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+           _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS$AR_SEP$output_objdir/$libname$release.a $output_objdir/$soname'
           fi
         fi
         ;;
@@ -5855,7 +5903,7 @@ if test "$_lt_caught_CXX_error" != yes; then
              _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
                rm -rf $tpldir~
                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-               $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+               $AR $AR_FLAGS$AR_SEP$oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
                $RANLIB $oldlib'
              _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
                rm -rf $tpldir~
index a57dfdd90f3c69be04182f7830e659b14d185b85..dd4a122db49c9fa8686fe7b79a674e3bfd643290 100644 (file)
@@ -42,11 +42,16 @@ $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o bar.lo bar.c
 $LIBTOOL --mode=link --tag=CC --tag=disable-shared $CC $CFLAGS $LDFLAGS \
 -o libfoo.la foo.lo -version-info 1:0:0 -rpath $thisdir
 $LIBTOOL --mode=install cp libfoo.la $thisdir 
+eval `$EGREP '^(old_library)=' < libfoo.la`
+libfoo=$old_library
 AT_CHECK([$LIBTOOL --mode=link --tag=CC --tag=disable-shared $CC $CFLAGS $LDFLAGS \
-        -o libbar.la bar.lo ./libfoo.a -version-info 1:0:0 -rpath $thisdir],
+        -o libbar.la bar.lo $libfoo -version-info 1:0:0 -rpath $thisdir],
         [], [ignore], [ignore])
 AT_CHECK([$LIBTOOL --mode=install cp libbar.la $thisdir], [], [ignore], [ignore])
-AT_CHECK([ar -t libbar.a | grep libfoo.a],[1],[ignore],[ignore])
-archive_contents=`ar -t libbar.a`
-AT_XFAIL_IF([case "$archive_contents" in *"libfoo.a"*) : ;; esac])
+eval `$EGREP '^(old_library)=' < libbar.la`
+libbar=$old_library
+eval `$LIBTOOL --config | $EGREP '^(AR_TFLAGS|AR_SEP)='`
+AT_CHECK([$AR $AR_TFLAGS$AR_SEP$libbar | grep $libfoo],[1],[ignore],[ignore])
+archive_contents=`$AR $AR_TFLAGS$AR_SEP$libbar`
+AT_XFAIL_IF([case "$archive_contents" in *"$libfoo"*) : ;; esac])
 AT_CLEANUP