$seen_libtool = 0;
$libtool_line = 0;
+# Files installed by libtoolize.
+@libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
+
# TRUE if we've seen AM_MAINTAINER_MODE.
$seen_maint_mode = 0;
{
# libtool requires some files.
&require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
- 'config.sub', 'config.guess',
- 'ltconfig', 'ltmain.sh')
+ @libtoolize_files)
if $seen_libtool;
# AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
}
# Return object extension. Just once, put some code into the output.
+# Argument is the name of the output file
sub get_object_extension
{
+ local ($out) = @_;
+
+ # Maybe require libtool library object files.
+ local ($l) = '';
+ $l = 'l' if ($out =~ /^lib.*\.la$/);
+
if (! $dir_holds_sources)
{
# Boilerplate.
}
# Check for automatic de-ANSI-fication.
- $dir_holds_sources = '.o';
+ $dir_holds_sources = 'o';
push (@suffixes, '.c', '.o');
push (@clean, 'compile');
+ if ($seen_libtool)
+ {
+ # Output the libtool compilation rules.
+ $output_rules .= &file_contents ('libtool');
+ &push_phony_cleaners ('libtool');
+
+ push (@suffixes, '.lo');
+ push (@clean, 'libtool');
+ }
+
if (defined $options{'ansi2knr'})
{
if (! $am_c_prototypes)
push (@clean, 'kr');
&push_phony_cleaners ('kr');
+
+ # FIXME - should be able to do libtool objects, too.
}
}
- return $dir_holds_sources;
+
+ return '.' . $l . $dir_holds_sources;
}
# Handle yacc and lex.
&define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
}
+ #
+ # Handle libtool.
+ #
+ local ($libtool) = '';
+ if ($seen_libtool)
+ {
+ &define_configure_variable ("LIBTOOL");
+ $libtool = '$(LIBTOOL) ';
+ }
+
#
# Now handle C++.
#
&define_configure_variable ("CXXFLAGS");
&define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
- &define_variable ('CXXLINK', '$(CXX) $(LDFLAGS) -o $@');
+ &define_variable ('CXXLINK', $libtool . '$(CXX) $(LDFLAGS) -o $@');
local ($ext);
foreach $ext (@cxx_list)
{
$output_rules .= ("$ext.o:\n"
. "\t\$(CXXCOMPILE) -c \$<\n");
+ $output_rules .= ("$ext.lo:\n"
+ . "\t\$(LIBTOOL) $(CXXCOMPILE) -c \$<\n")
+ if ($seen_libtool);
}
if (! defined $configure_vars{'CXX'})
&define_configure_variable ('CFLAGS');
&define_variable ('COMPILE',
'$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
- &define_variable ('LINK', '$(CC) $(LDFLAGS) -o $@');
+ &define_variable ('LINK', $libtool . '$(CC) $(LDFLAGS) -o $@');
if (! defined $configure_vars{'CC'})
{
local ($lex_ok) = $lex_seen ? 0 : 1;
local ($seen_libobjs) = 0;
+ local ($flagvar) = 0;
foreach $lsearch (&variable_value_as_list ($var))
{
# Skip -lfoo and -Ldir.
next if $lsearch =~ /^-[lL]/;
+ if (! $flagvar && $lsearch =~ /^-/)
+ {
+ if ($var =~ /^(.*)LDADD$/)
+ {
+ $flagvar = $1 . 'LDFLAGS';
+ }
+ if ($flagvar)
+ {
+ &am_line_error ($var, "linker flags such as \`$lsearch' belong in $flagvar");
+ }
+ else
+ {
+ # Only get this error once.
+ $flagvar = 1;
+ &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in $var");
+ }
+ }
# Assume we have a file of some sort, and push it onto the
# dependency list. Autoconf substitutions are not pushed;
# Handle C programs.
sub handle_programs
{
- local (@proglist) = &am_install_var ('-clean',
+ local (@proglist) = &am_install_var ('-clean', '-ltlibs',
'progs', 'PROGRAMS',
'bin', 'sbin', 'libexec', 'pkglib',
'noinst', 'check');
unless $seen_arg_prog;
$seen_arg_prog = 1;
- local ($obj) = &get_object_extension;
local ($one_file, $xname, $munge);
local ($seen_libobjs) = 0;
foreach $one_file (@proglist)
{
+ local ($obj) = &get_object_extension ($one_file);
+
# Canonicalize names.
($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
if ($xname ne $one_file)
{
local ($xt);
- foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
+ foreach $xt ('_LDADD', '_LDFLAGS', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
{
&am_line_error ($one_file . $xt,
"invalid variable \`" . $one_file . $xt
}
}
+ if (! &variable_defined ($xname . '_LDFLAGS'))
+ {
+ # Define the prog_LDFLAGS variable.
+ &define_variable ($xname . '_LDFLAGS', '');
+ }
+
if ($lex_file_seen)
{
&am_line_error ($one_file . $xt,
}
}
+
# Handle libraries.
sub handle_libraries
{
}
local ($onelib);
- local ($obj) = &get_object_extension;
local ($munge);
local ($xlib);
local ($seen_libobjs) = 0;
"\`$onelib' is not a standard library name");
}
+ local ($obj) = &get_object_extension ($onelib);
+
# Canonicalize names.
($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
if ($xlib ne $onelib)
local ($varname, $primary, $ckey);
foreach $varname (keys %contents)
{
- foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_DEPENDENCIES')
+ foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
{
if ($varname =~ /$primary$/ && ! $content_seen{$varname})
{
@common_sometimes =
(
"aclocal.m4", "acconfig.h", "config.h.top",
- "config.h.bot", "stamp-h.in", 'stamp-vti', 'ltconfig', 'ltmain.sh'
+ "config.h.bot", "stamp-h.in", 'stamp-vti', @libtoolize_files
);
$USAGE = "\
{
local (@args) = @_;
- local ($do_all, $do_clean) = (1, 0);
+ local ($do_clean, $do_ltlibs) = (0, 0);
while (@args)
{
if ($args[0] eq '-clean')
{
$do_clean = 1;
}
+ if ($args[0] eq '-ltlibs')
+ {
+ $do_ltlibs = 1;
+ }
elsif ($args[0] !~ /^-/)
{
last;
shift (@args);
}
local ($file, $primary, @prefixes) = @args;
+ unshift (@prefixes, 'lib') if ($do_ltlibs);
local (@used) = ();
local (@result) = ();
}
next;
}
+
+ if ($do_ltlibs)
+ {
+ if ($rcurs =~ /^lib.*\.l?a$/)
+ {
+ if (! $seen_libtool)
+ {
+ &am_line_error ($one_name,
+ "\`$rcurse' is a libtool library name, but AM_PROG_LIBTOOL is not in \`configure.in'");
+ $seen_libtool = 1;
+ }
+
+ # Check that libtool libraries go only into libdir.
+ if ($rcurs =~ /^lib.*\.la$/ && $X ne 'lib')
+ {
+ &am_line_error ($one_name,
+ "libtool library \`$rcurs' must only be installed in libdir");
+ }
+ elsif ($X =~ /^s?bin|libexec$/)
+ {
+ &am_line_error ($one_name,
+ "library \`$rcurs' must not be installed in a binary directory");
+ }
+ }
+ elsif ($X eq 'lib')
+ {
+ &am_line_error ($one_name,
+ "only libraries (not \`$rcurs') may be installed in libdir");
+ }
+ }
push (@result, $rcurs);
}
next;
}
- $output_rules .=
- &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
- $file);
+ if ($do_ltlibs && $X eq 'lib')
+ {
+ $output_rules .=
+ &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
+ 'ltlibs');
+ }
+ else
+ {
+ $output_rules .=
+ &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
+ $file);
+ }
push (@uninstall, 'uninstall-' . $X . $primary);
push (@phony, 'uninstall-' . $X . $primary);
# Push here because PRIMARY might be configure time determined.
push (@all, '$(' . $primary . ')')
- if $do_all && @used;
+ if @used;
return (@result);
}
# Only install missing files according to our desired
# strictness level.
- if ($add_missing && -f ($am_dir . '/' . $file))
+ if ($add_missing)
{
$trailer = "; installing";
$suppress = 1;
- # Install the missing file. Symlink if we can,
- # copy if we must. Note: delete the file first,
- # in case it is a dangling symlink.
- unlink ($errfile);
- if ($symlink_exists)
+
+ # Maybe run libtoolize.
+ if ($seen_libtool
+ && grep ($_ eq $file, @libtoolize_files)
+ && system ('libtoolize', '--automake'))
{
- if (! symlink ($am_dir . '/' . $file, $errfile))
- {
- $suppress = 0;
- $trailer .= "; error while making link: $!\n";
- }
+ $suppress = 0;
+ $trailer .= "; cannot run \`libtoolize': $!";
}
- else
+ elsif (-f ($am_dir . '/' . $file))
{
- if (! system ('cp', $am_dir . '/' . $file, $errfile))
+ # Install the missing file. Symlink if we
+ # can, copy if we must. Note: delete the file
+ # first, in case it is a dangling symlink.
+ unlink ($errfile);
+ if ($symlink_exists)
+ {
+ if (! symlink ($am_dir . '/' . $file, $errfile))
+ {
+ $suppress = 0;
+ $trailer .= "; error while making link: $!\n";
+ }
+ }
+ else
{
- $suppress = 0;
- $trailer .= "\n error while making link: $!\n";
+ if (! system ('cp', $am_dir . '/' . $file, $errfile))
+ {
+ $suppress = 0;
+ $trailer .= "\n error while making link: $!\n";
+ }
}
}
}
This is required if any C++ source is included.
@cvindex AC_PROG_CXX
-@c @item AM_PROG_LIBTOOL
-@c Automake will turn on processing for @code{libtool} (@pxref{Top, , The
-@c Libtool Manual, libtool.info, The Libtool Manual}). This work is
-@c still preliminary.
-@c @cvindex AM_PROG_LIBTOOL
+@item AM_PROG_LIBTOOL
+Automake will turn on processing for @code{libtool} (@pxref{Top, , The
+Libtool Manual, libtool.info, The Libtool Manual}).
+@cvindex AM_PROG_LIBTOOL
@item AC_PROG_YACC
If a Yacc source file is seen, then you must either use this macro or
rmt_SOURCES = @dots{}
@end example
+@samp{prog_LDADD} is inappropriate for passing program-specific linker
+flags (except for @samp{-l} and @samp{-L}). So, use the
+@samp{prog_LDFLAGS} variable for this purpose.
+@vindex _LDFLAGS
+
It is also occasionally useful to have a program depend on some other
target which is not actually part of that program. This can be done
using the @samp{prog_DEPENDENCIES} variable. Each program depends on
the contents of such a variable, but no further interpretation is done.
If @samp{prog_DEPENDENCIES} is not supplied, it is computed by Automake.
-The automatically-assigned value is the contents of @samp{prog_LDADD}
-with all the @samp{-l} and @samp{-L} options removed. Be warned that
-@file{configure} substitutions are preserved; this can lead to bad
-dependencies if you are not careful.
+The automatically-assigned value is the contents of @samp{prog_LDADD}.
+Be warned that @file{configure} substitutions are preserved; this can
+lead to bad dependencies if you are not careful.
@node A Library
libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
@end example
+@unnumberedsubsec Building Libraries with @code{libtool}
+
+The innovation used by GNU Libtool (@pxref{Top, , The Libtool Manual,
+libtool.info, The Libtool Manual}) is that libraries are programs.
+
+So, if you have GNU Libtool and want to use it to build your libraries,
+you should use the @samp{lib_PROGRAMS} variable (@pxref{Using Automake,
+, Using Automake with Libtool, libtool.info, The Libtool Manual}).
@node LIBOBJS
@section Special handling for LIBOBJS and ALLOCA
Some variables are inherited from Autoconf; these are @code{CC},
@code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
@code{LIBS}.
-
+@vindex LDFLAGS
There are some additional variables which Automake itself defines: