summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>1996-11-22 06:58:20 +0000
committerTom Tromey <tromey@redhat.com>1996-11-22 06:58:20 +0000
commit2f97b80cd8e38f9f26b07d5f2bc8b4a4e3559429 (patch)
tree0ed34f74309e21c7114db435412b8d9aa826144c
parentcfc7850dfaba0e391631ef6feb7c0be3bc7a2cd8 (diff)
downloadautomake-2f97b80cd8e38f9f26b07d5f2bc8b4a4e3559429.tar.gz
Merged in Gord's libtool patches
-rw-r--r--ChangeLog6
-rw-r--r--Makefile.am2
-rwxr-xr-xautomake.in182
-rw-r--r--automake.texi31
-rw-r--r--lib/am/Makefile.am2
-rw-r--r--lib/am/program.am2
-rw-r--r--lib/am/progs.am5
-rw-r--r--program.am2
-rw-r--r--progs.am5
9 files changed, 189 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f55c8220..e98ab4a35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,6 +62,12 @@ Fri Nov 15 18:58:04 1996 Tom Tromey <tromey@cygnus.com>
files.
(pretty_print_internal): Initialize $bol depending on the column.
+Mon Nov 18 19:11:53 1996 Gordon Matzigkeit <gord@gnu.ai.mit.edu>
+
+ * automake.in: Added a lot of libtool support. New variable
+ prog_LDFLAGS to pass linker flags. Use libtoolize to install
+ libtool support files.
+
Fri Nov 15 16:22:15 1996 Gordon Matzigkeit <gord@gnu.ai.mit.edu>
* library.am: Fixed references to LIBRARY according to new scheme.
diff --git a/Makefile.am b/Makefile.am
index 91e160dd7..37fbe77f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@ info_TEXINFOS = automake.texi
pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \
compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \
-header.am header-vars.am kr-extra.am libs.am library.am \
+header.am header-vars.am kr-extra.am libs.am library.am libtool.am ltlibs.am \
mans-vars.am program.am progs.am remake-hdr.am remake-subd.am \
remake.am scripts.am subdirs.am tags.am tags-clean.am \
texi-vers.am texinfos.am libs-clean.am \
diff --git a/automake.in b/automake.in
index aca276e2a..19bc1ac1f 100755
--- a/automake.in
+++ b/automake.in
@@ -167,6 +167,9 @@ $seen_arg_prog = 0;
$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;
@@ -411,8 +414,7 @@ sub generate_makefile
{
# 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
@@ -584,8 +586,15 @@ sub handle_options
}
# 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.
@@ -615,10 +624,20 @@ sub get_object_extension
}
# 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)
@@ -666,9 +685,12 @@ sub get_object_extension
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.
@@ -740,6 +762,16 @@ sub handle_yacc_lex_cxx
}
#
+ # Handle libtool.
+ #
+ local ($libtool) = '';
+ if ($seen_libtool)
+ {
+ &define_configure_variable ("LIBTOOL");
+ $libtool = '$(LIBTOOL) ';
+ }
+
+ #
# Now handle C++.
#
local (@cxx_list) = keys %cxx_extensions;
@@ -750,13 +782,16 @@ sub handle_yacc_lex_cxx
&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'})
@@ -784,7 +819,7 @@ sub handle_yacc_lex_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'})
{
@@ -1036,11 +1071,29 @@ sub handle_lib_objects
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;
@@ -1113,7 +1166,7 @@ sub handle_lib_objects
# 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');
@@ -1125,18 +1178,19 @@ sub handle_programs
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
@@ -1177,6 +1231,12 @@ sub handle_programs
}
}
+ if (! &variable_defined ($xname . '_LDFLAGS'))
+ {
+ # Define the prog_LDFLAGS variable.
+ &define_variable ($xname . '_LDFLAGS', '');
+ }
+
if ($lex_file_seen)
{
&am_line_error ($one_file . $xt,
@@ -1226,6 +1286,7 @@ sub handle_programs
}
}
+
# Handle libraries.
sub handle_libraries
{
@@ -1252,7 +1313,6 @@ sub handle_libraries
}
local ($onelib);
- local ($obj) = &get_object_extension;
local ($munge);
local ($xlib);
local ($seen_libobjs) = 0;
@@ -1266,6 +1326,8 @@ sub handle_libraries
"\`$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)
@@ -1327,7 +1389,7 @@ sub check_typos
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})
{
@@ -3756,7 +3818,7 @@ sub initialize_global_constants
@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 = "\
@@ -4054,13 +4116,17 @@ sub am_install_var
{
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;
@@ -4068,6 +4134,7 @@ sub am_install_var
shift (@args);
}
local ($file, $primary, @prefixes) = @args;
+ unshift (@prefixes, 'lib') if ($do_ltlibs);
local (@used) = ();
local (@result) = ();
@@ -4129,6 +4196,36 @@ sub am_install_var
}
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);
}
@@ -4160,9 +4257,18 @@ sub am_install_var
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);
@@ -4195,7 +4301,7 @@ sub am_install_var
# Push here because PRIMARY might be configure time determined.
push (@all, '$(' . $primary . ')')
- if $do_all && @used;
+ if @used;
return (@result);
}
@@ -4266,28 +4372,40 @@ sub require_file_internal
# 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";
+ }
}
}
}
diff --git a/automake.texi b/automake.texi
index 61757be6b..8e58e9aab 100644
--- a/automake.texi
+++ b/automake.texi
@@ -655,11 +655,10 @@ This is required if any libraries are built in the package.
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
@@ -934,16 +933,20 @@ mt_SOURCES = @dots{}
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
@@ -977,6 +980,14 @@ variable. This should be used for objects determined by
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
@@ -1002,7 +1013,7 @@ own compilation in some special cases.
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:
diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am
index 91e160dd7..37fbe77f7 100644
--- a/lib/am/Makefile.am
+++ b/lib/am/Makefile.am
@@ -10,7 +10,7 @@ info_TEXINFOS = automake.texi
pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \
compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \
-header.am header-vars.am kr-extra.am libs.am library.am \
+header.am header-vars.am kr-extra.am libs.am library.am libtool.am ltlibs.am \
mans-vars.am program.am progs.am remake-hdr.am remake-subd.am \
remake.am scripts.am subdirs.am tags.am tags-clean.am \
texi-vers.am texinfos.am libs-clean.am \
diff --git a/lib/am/program.am b/lib/am/program.am
index 03227793f..e91639ed6 100644
--- a/lib/am/program.am
+++ b/lib/am/program.am
@@ -16,4 +16,4 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
@PROGRAM@: $(@XPROGRAM@_OBJECTS) $(@XPROGRAM@_DEPENDENCIES)
- $(@XLINK@) $(@XPROGRAM@_OBJECTS) $(@XPROGRAM@_LDADD) $(LIBS)
+ $(@XLINK@) $(@XPROGRAM@_LDFLAGS) $(@XPROGRAM@_OBJECTS) $(@XPROGRAM@_LDADD) $(LIBS)
diff --git a/lib/am/progs.am b/lib/am/progs.am
index 406b2f89f..bd667e477 100644
--- a/lib/am/progs.am
+++ b/lib/am/progs.am
@@ -22,7 +22,10 @@ install-@DIR@PROGRAMS: $(@DIR@_PROGRAMS)
## a syntax error in sh.
list="$(@DIR@_PROGRAMS)"; for p in $$list; do \
if test -f $$p; then \
- $(INSTALL_PROGRAM) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
+## It is harmless to unconditionally use $(LIBTOOL) here because it
+## will be null in non-libtoolized packages, and even if it is set to
+## a real libtool, its behaviour is identical to normal INSTALL_PROGRAM.
+ $(LIBTOOL) $(INSTALL_PROGRAM) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
else :; fi; \
done
diff --git a/program.am b/program.am
index 03227793f..e91639ed6 100644
--- a/program.am
+++ b/program.am
@@ -16,4 +16,4 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
@PROGRAM@: $(@XPROGRAM@_OBJECTS) $(@XPROGRAM@_DEPENDENCIES)
- $(@XLINK@) $(@XPROGRAM@_OBJECTS) $(@XPROGRAM@_LDADD) $(LIBS)
+ $(@XLINK@) $(@XPROGRAM@_LDFLAGS) $(@XPROGRAM@_OBJECTS) $(@XPROGRAM@_LDADD) $(LIBS)
diff --git a/progs.am b/progs.am
index 406b2f89f..bd667e477 100644
--- a/progs.am
+++ b/progs.am
@@ -22,7 +22,10 @@ install-@DIR@PROGRAMS: $(@DIR@_PROGRAMS)
## a syntax error in sh.
list="$(@DIR@_PROGRAMS)"; for p in $$list; do \
if test -f $$p; then \
- $(INSTALL_PROGRAM) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
+## It is harmless to unconditionally use $(LIBTOOL) here because it
+## will be null in non-libtoolized packages, and even if it is set to
+## a real libtool, its behaviour is identical to normal INSTALL_PROGRAM.
+ $(LIBTOOL) $(INSTALL_PROGRAM) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
else :; fi; \
done