Allow Microsoft lib to be used as the archiver. archive-in-archive.at passes (unexpectedly) for Microsoft lib. Should AR_FLAGS be ARFLAGS instead? Automake uses that... This patch is against Libtool 2.2 * libltdl/m4/libtool.m4 (_LT_PROG_AR): New macro, detect the interface used by the archiver. In particullar, 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 hardcodeing the name, and allow different archivers. Index: libtool/Makefile.am =================================================================== --- libtool.orig/Makefile.am +++ libtool/Makefile.am @@ -471,6 +471,7 @@ EXTRA_DIST += $(srcdir)/$(TESTSUITE) 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)" \ OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \ SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \ Index: libtool/libltdl/config/ltmain.m4sh =================================================================== --- libtool.orig/libltdl/config/ltmain.m4sh +++ libtool/libltdl/config/ltmain.m4sh @@ -1115,8 +1115,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: libtool/libltdl/m4/libtool.m4 =================================================================== --- libtool.orig/libltdl/m4/libtool.m4 +++ libtool/libltdl/m4/libtool.m4 @@ -1338,14 +1338,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=: @@ -1357,7 +1405,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= @@ -4236,7 +4284,7 @@ _LT_EOF amigaos*) if test "$host_cpu" = m68k; then - _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 fi @@ -4459,7 +4507,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 @@ -4588,14 +4636,14 @@ _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 ;; amigaos*) if test "$host_cpu" = m68k; then - _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 fi @@ -5529,7 +5577,7 @@ if test "$_lt_caught_CXX_error" != yes; _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 ;; @@ -5837,7 +5885,7 @@ if test "$_lt_caught_CXX_error" != yes; _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: libtool/tests/archive-in-archive.at =================================================================== --- libtool.orig/tests/archive-in-archive.at +++ libtool/tests/archive-in-archive.at @@ -42,11 +42,16 @@ $LIBTOOL --mode=compile --tag=CC $CC $CP $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