+2003-11-30 Gary V. Vaughan <gary@gnu.org>
+
+ * automake.in (&handle_source_transform): Calculate a default file
+ for use in the absence of an appropriate _SOURCES declaration by
+ first stripping any suffix from the unxformed target name, and
+ appending `.c'.
+ * doc/automake.texi (Program Sources, Libtool Modules): Document this.
+ * tests/ltlibsrc.test: New file.
+ * tests/Makefile.am (TESTS): Add ltlibsrc.test.
+
2003-11-29 Alexandre Duret-Lutz <adl@gnu.org>
* lib/Automake/Variable.pm (loc_and_value_as_list_recursive,
* New features
+ - Default source file names in the absence of a _SOURCES declaration
+ are made by removing any target extension before appending `.c', so
+ to make the libtool module `foo.la' from `foo.c', you only need to
+ do this:
+
+ lib_LTLIBRARIES = foo.la
+ foo_la_LDFLAGS = -module
+
- AR's `cru' flags are now set in a global ARFLAGS variable instead
of being hard-coded in each $(AR) invocation, so they can be
substituted from configure.ac. This has been requested by people
my @keys = sort keys %used_pfx;
if (scalar @keys == 0)
{
- &define_variable ($one_file . "_SOURCES", $unxformed . ".c", $where);
- push (@sources, $unxformed . '.c');
- push (@dist_sources, $unxformed . '.c');
+ (my $default_source = $unxformed) =~ s/(\..*)?$/.c/;
+ &define_variable ($one_file . "_SOURCES", $default_source, $where);
+ push (@sources, $default_source);
+ push (@dist_sources, $default_source);
%linkers_used = ();
my (@result) =
&handle_single_transform_list ($one_file . '_SOURCES',
$one_file . '_SOURCES',
$one_file, $obj,
- "$unxformed.c");
+ $default_source);
$linker ||= &resolve_linker (%linkers_used);
define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result);
}
If @samp{hello_SOURCES} is not specified, then it defaults to the single
file @file{hello.c}; that is, the default is to compile a single C file
-whose base name is the name of the program itself. (This is a terrible
-default but we are stuck with it for historical reasons.)
+whose base name is the name of the program itself. In this context,
+the base name is always the name that would have gone to the left of
+the @samp{_SOURCES} primary, before canonicalization and with any
+suffixes replaced with @samp{.c} (This is a terrible default but we
+are stuck with it for historical reasons.)
@vindex _SOURCES
@vindex SOURCES
+For example if you have the following somewhere in your
+@file{Makefile.am} with no corresponding @samp{libfoo_a_SOURCES}:
+
+@example
+lib_LIBRARIES = libfoo.a
+@end example
+
+@noindent
+@file{libfoo.a} will be built using a default source file named
+@file{libfoo.c}.
+
Multiple programs can be built in a single directory. Multiple programs
can share a single source file, which must be listed in each
@samp{_SOURCES} definition.
@samp{lib}. However, when building a dynamically loadable module you
might wish to use a "nonstandard" name.
+If @samp{mymodule_SOURCES} is not specified, then it defaults to the single
+file @file{mymodule.c}; that is, the default is to compile a single C file
+whose base name is the name of the module itself. (This is a terrible
+default but we are stuck with it for historical reasons.)
+@vindex _SOURCES
+@vindex SOURCES
+
@node Libtool Flags
@subsection _LIBADD and _LDFLAGS
@cindex _LIBADD, libtool
-@set UPDATED 29 November 2003
+@set UPDATED 30 November 2003
@set UPDATED-MONTH November 2003
@set EDITION 1.7g
@set VERSION 1.7g
-@set UPDATED 29 November 2003
+@set UPDATED 30 November 2003
@set UPDATED-MONTH November 2003
@set EDITION 1.7g
@set VERSION 1.7g
ltconv.test \
ltdeps.test \
ltlibobjs.test \
+ltlibsrc.test \
maintclean.test \
make.test \
makej.test \
ltconv.test \
ltdeps.test \
ltlibobjs.test \
+ltlibsrc.test \
maintclean.test \
make.test \
makej.test \
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test to make sure a sensible default source for libraries is used.
+
+required='libtool gcc'
+. ./defs || exit 1
+
+cat > configure.in << 'END'
+AC_INIT([foo], [0.1])
+AC_CONFIG_SRCDIR([foo.c])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+pkglib_LTLIBRARIES = foo.la
+foo_la_LDFLAGS = -module
+END
+
+cat > foo.c << 'END'
+int foo (void) { return 0; }
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir sub
+cd sub
+
+../configure
+$MAKE || exit 1
+
+test -f foo.la || exit 1
+:
+
+exit 0