From: Peter Rosin Date: Thu, 8 Nov 1984 08:20:00 +0000 (+0200) Subject: patch libtool-ar.patch X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c17887ee34e73a2aeb127b94f5b76f45dc34017;p=thirdparty%2Flibtool.git patch libtool-ar.patch --- diff --git a/Makefile.am b/Makefile.am index 8ed48c364..f82f26537 100644 --- a/Makefile.am +++ b/Makefile.am @@ -498,7 +498,8 @@ 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}" \ + AR="$(AR)" AR_FLAGS="$(AR_FLAGS)" \ + LT_AR="$(LT_AR)" LT_ARFLAGS="$(LT_ARFLAGS)" \ STRIP="$(STRIP)" INSTALL="$(INSTALL)" \ OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \ SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \ diff --git a/doc/libtool.texi b/doc/libtool.texi index dce553bfd..dede66909 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -129,6 +129,7 @@ Invoking @code{libtool} * Finish mode:: Completing a library installation. * Uninstall mode:: Removing installed executables and libraries. * Clean mode:: Removing uninstalled executables and libraries. +* Archive mode:: Portably handle archives. Integrating libtool with your package @@ -1262,6 +1263,7 @@ by programs libtool invokes, rather than libtool itself. * Finish mode:: Completing a library installation. * Uninstall mode:: Removing installed executables and libraries. * Clean mode:: Removing uninstalled executables and libraries. +* Archive mode:: Portably handle archives. @end menu @node Compile mode @@ -1662,6 +1664,64 @@ files (typically @command{/bin/rm}). The remaining @var{mode-args} are either flags for the deletion program (beginning with a @samp{-}), or the names of files to delete. +@node Archive mode +@section Archive mode +@cindex archive mode +@cindex mode, archive + +@dfn{Archive} mode lets you handle archives portably on systems where +the archiver is weird. As an example, the Microsoft LIB.EXE archiver +expects @command{lib -OUT:example.lib some.obj objects.obj}, which is +impossible to fit into the variables @var{AR} and @var{AR_FLAGS} (note +that there is no space between @samp{-OUT:} and @file{example.lib}). +Also, many expect to be able to extract archives with @command{$AR x} +and list archive content with @command{$AR t}. Again using Microsoft +LIB.EXE as an example, archive extraction and listing do not always +work like that (@command{lib -EXTRACT:example.lib} and +@command{lib -LIST example.lib} respectively, note the absent colon +in the listing command). + +Libtool presents the archiver with a limited but common interface + +@var{mode-args} consist of an archiver command, an archive to operate +on and possibly a set of object files. + +The possible archiver command are + +@table @option +@item cru @file{archive-file} @file{object-file}@dots{} +Creates an archive. + +@example +ms$ @kbd{libtool --mode=ar cru example.lib some.obj objects.obj} +libtool: ar: lib -NOLOGO -OUT:example.lib some.obj objects.obj +ms$ +@end example + +@item x @file{archive-file} +Extracts an archive. + +@example +ms$ @kbd{libtool --mode=ar x example.lib} +libtool: ar: (cd . && lib -NOLOGO -EXTRACT:some.obj "example.lib") +libtool: ar: (cd . && lib -NOLOGO -EXTRACT:objects.obj "example.lib") +ms$ +@end example + +@item t @file{archive-file} +Lists the contents of an archive. The libtool option @option{--quiet} is +useful here, to avoid the first disgnostic line. + +@example +ms$ @kbd{libtool --mode=ar x example.lib} +libtool: ar: lib -NOLOGO -LIST example.lib +some.obj +objects.obj +ms$ +@end example + +@end table + @node Integrating libtool @chapter Integrating libtool with your package @@ -5529,7 +5589,7 @@ in cases where it is necessary. @node Archivers @subsection Archivers -On all known systems, building a static library can be accomplished by +On all sane systems, building a static library can be accomplished by running @kbd{ar cru lib@var{name}.a @var{obj1}.o @var{obj2}.o @dots{}}, where the @samp{.a} file is the output library, and each @samp{.o} file is an object file. @@ -5539,6 +5599,17 @@ must be used to ``bless'' the created library before linking against it, with the @kbd{ranlib lib@var{name}.a} command. Some systems, like Irix, use the @code{ar ts} command, instead. +On some not so sane systems (e.g. Windows with MSYS but w/o MinGW @code{ar} +and instead the Microsoft archiver LIB.EXE), @code{ar cru} obviously does +not work. Because of those systems, it is more portable to use +@code{libtool --mode=ar cru} instead. If you only want to go through the +libtool script when it is needed, use @code{$(LT_AR) $(LT_ARFLAGS)} in +Makefile.in, and configure will do the right thing. + +On some systems, it is required that you add more flags, e.g. 64-bit AIX +which needs @code{ar -X64 cru}. Or everything might just be named +differently, e.g some prefer @code{CC -ar -o} on Irix. + @node libtool script contents @section @code{libtool} script contents @cindex implementation of libtool diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index ae72f47ab..36dd3fbe3 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -51,6 +51,7 @@ m4_divert_push([SCRIPT])# @configure_input@ # # MODE must be one of the following: # +# ar handle archives # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program @@ -249,6 +250,9 @@ func_enable_tag () # Shorthand for --mode=foo, only valid as the first argument case $1 in + ar|a) + shift; set dummy --mode ar ${1+"$@"}; shift + ;; clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; @@ -298,6 +302,7 @@ func_enable_tag () --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break case $1 in # Valid mode arguments: + ar) ;; clean) ;; compile) ;; execute) ;; @@ -1061,6 +1066,22 @@ func_mode_help () func_help ;; + ar) + $ECHO \ +"Usage: $progname [OPTION]... --mode=ar COMMAND ARCHIVE [OBJECT...] + +Create and extract files from archives. + +This mode accepts the following archiver COMMANDs: + + cru create the ARCHIVE, consisting of the given OBJECTs. + x extract the ARCHIVE + t list the ARCHIVE content + +Note that this mode is not for creating static libtool libraries, it is +a compatibility layer for \"weird\" archivers." + ;; + clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... @@ -8223,6 +8244,54 @@ func_mode_uninstall () { test "$mode" = uninstall || test "$mode" = clean; } && func_mode_uninstall ${1+"$@"} + +# func_mode_ar arg... +func_mode_ar () +{ + $opt_debug + ar_action="$nonopt" + archive= + files= + + for arg + do + if test -z "$archive"; then + archive=$arg + else + files="$files $arg" + fi + done + + test -z "$archive" && \ + func_fatal_help "you must specify an archive" + + case "$ar_action" in + cru) + test -z "$files" && \ + func_fatal_help "you must specify some objects" + func_show_eval "$AR $AR_FLAGS$AR_SEP$archive $files" 'exit $?' + ;; + x) + if test "x$ar_extract_one_by_one" = xyes; then + func_extract_an_archive . "$archive" + exit $? + else + func_show_eval "$AR $AR_XFLAGS$AR_SEP$archive" 'exit $?' + fi + ;; + t) + func_show_eval "$AR $AR_TFLAGS$AR_SEP$archive" 'exit $?' + ;; + *) + func_fatal_help "bad archive action, either cru, x or t" + ;; + esac + + exit $EXIT_SUCCESS +} + +test "$mode" = ar && func_mode_ar ${1+"$@"} + test -z "$mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 32de8320a..e886d3d06 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -1320,6 +1320,18 @@ lib) ;; esac +if test -n "$AR_SEP" && + test "X$AR_TFLAGS" = Xt && + test "X$AR_XFLAGS" = Xx && + test "$ar_extract_one_by_one" = no +then + LT_AR='$(AR)' + LT_ARFLAGS='$(AR_FLAGS)' +else + LT_AR='$(SHELL) $(abs_top_builddir)/libtool --quiet --mode=ar' + LT_ARFLAGS=cru +fi + _LT_DECL([], [ar_extract_one_by_one], [1], [Extract archive members one by one]) _LT_DECL([], [archiver_list_spec], [1], @@ -1329,10 +1341,10 @@ _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([LT_AR]) +AC_SUBST([LT_ARFLAGS]) AC_SUBST([AR]) AC_SUBST([AR_FLAGS]) -AC_SUBST([AR_TFLAGS]) -AC_SUBST([AR_SEP]) ])# LT_PROG_AR diff --git a/tests/archive-in-archive.at b/tests/archive-in-archive.at index dd4a122db..551e254b9 100644 --- a/tests/archive-in-archive.at +++ b/tests/archive-in-archive.at @@ -50,8 +50,7 @@ AT_CHECK([$LIBTOOL --mode=link --tag=CC --tag=disable-shared $CC $CFLAGS $LDFLAG AT_CHECK([$LIBTOOL --mode=install cp libbar.la $thisdir], [], [ignore], [ignore]) 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_CHECK([$LT_AR t $libbar | grep $libfoo],[1],[ignore],[ignore]) +archive_contents=`$LT_AR t $libbar` AT_XFAIL_IF([case "$archive_contents" in *"$libfoo"*) : ;; esac]) AT_CLEANUP