[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Archiver handling
From: |
Peter Rosin |
Subject: |
Archiver handling |
Date: |
Tue, 13 Jan 2009 10:48:49 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (Windows/20081209) |
Den 2009-01-13 10:39 skrev Peter Rosin:
libtool-ar.patch
http://lists.gnu.org/archive/html/libtool-patches/2008-09/msg00003.html
No ChangeLog entry written yet.
Sorry 'bout that...
Cheers,
Peter
>From e71c3c45eccb25dd2601dfc51b2b86c24bc03cd6 Mon Sep 17 00:00:00 2001
From: Peter Rosin <address@hidden>
Date: Thu, 8 Nov 1984 10:20:00 +0200
Subject: [PATCH] patch libtool-ar.patch
---
Makefile.am | 3 +-
doc/libtool.texi | 73 ++++++++++++++++++++++++++++++++++++++++++-
libltdl/config/ltmain.m4sh | 69 ++++++++++++++++++++++++++++++++++++++++
libltdl/m4/libtool.m4 | 16 ++++++++-
tests/archive-in-archive.at | 5 +--
5 files changed, 159 insertions(+), 7 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 1049289..334bc97 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -476,7 +476,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 5c46ece..344e37a 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -127,6 +127,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
@@ -1217,6 +1218,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
@@ -1620,6 +1622,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.
address@hidden Archive mode
address@hidden Archive mode
address@hidden archive mode
address@hidden mode, archive
+
address@hidden 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
address@hidden -LIST example.lib} respectively, note the absent colon
+in the listing command).
+
+Libtool presents the archiver with a limited but common interface
+
address@hidden consist of an archiver command, an archive to operate
+on and possibly a set of object files.
+
+The possible archiver command are
+
address@hidden @option
address@hidden cru @file{archive-file} @address@hidden
+Creates an archive.
+
address@hidden
+ms$ @kbd{libtool --mode=ar cru example.lib some.obj objects.obj}
+libtool: ar: lib -NOLOGO -OUT:example.lib some.obj objects.obj
+ms$
address@hidden example
+
address@hidden x @file{archive-file}
+Extracts an archive.
+
address@hidden
+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$
address@hidden example
+
address@hidden t @file{archive-file}
+Lists the contents of an archive. The libtool option @option{--quiet} is
+useful here, to avoid the first disgnostic line.
+
address@hidden
+ms$ @kbd{libtool --mode=ar x example.lib}
+libtool: ar: lib -NOLOGO -LIST example.lib
+some.obj
+objects.obj
+ms$
address@hidden example
+
address@hidden table
+
@node Integrating libtool
@chapter Integrating libtool with your package
@@ -5487,7 +5547,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 address@hidden @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.
@@ -5497,6 +5557,17 @@ must be used to ``bless'' the created library before
linking against it,
with the @kbd{ranlib address@hidden 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
address@hidden --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 b78d7ac..2cb4a57 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -47,6 +47,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
@@ -256,6 +257,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
;;
@@ -305,6 +309,7 @@ func_enable_tag ()
--mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
case $1 in
# Valid mode arguments:
+ ar) ;;
clean) ;;
compile) ;;
execute) ;;
@@ -1050,6 +1055,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...
@@ -8045,6 +8066,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 a9f9035..3de4520 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -1394,6 +1394,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],
@@ -1403,10 +1415,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 dd4a122..551e254 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
--
1.6.0.4