* 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
* 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
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
@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.
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
#
# 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
# 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
;;
--mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
case $1 in
# Valid mode arguments:
+ ar) ;;
clean) ;;
compile) ;;
execute) ;;
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...
{ 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"
;;
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],
_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