]> sourceware.org Git - automake.git/commitdiff
* automake.in (&handle_source_transform): Calculate a default file
authorAlexandre Duret-Lutz <adl@gnu.org>
Sun, 30 Nov 2003 13:35:29 +0000 (13:35 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sun, 30 Nov 2003 13:35:29 +0000 (13:35 +0000)
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.

ChangeLog
NEWS
automake.in
doc/automake.texi
doc/stamp-vti
doc/version.texi
tests/Makefile.am
tests/Makefile.in
tests/ltlibsrc.test [new file with mode: 0755]

index e0e1e44c8f5d1632aee85b111fc44fec0a778dde..b0c2d55d2fb9ff5caa324323830479ce60e7c2df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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,
diff --git a/NEWS b/NEWS
index 5c6e37de159657091bc4a9a4219ae494563e4549..6cb9f5e10580fd2a39099bb739d8cf58d8c5c6d0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,14 @@ New in 1.7g:
 
 * 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
index cc29348d657324c6b82c13115325a41460969a8a..3752415dcc12a99dbbfd2a29531eb4c93697b624 100755 (executable)
@@ -1807,16 +1807,17 @@ sub handle_source_transform
     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);
     }
index 4f19f116565f73feac31689ea22ef7fdad71f3e0..cc02c1e2c55491e1d2845b91950f1763b95563d9 100644 (file)
@@ -2310,11 +2310,25 @@ corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
 
 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.
@@ -2869,6 +2883,13 @@ Ordinarily, Automake requires that a Library's name starts with
 @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
index 3ba12101688d79cce2e9eb363422be5e1b6a72c4..fdce8f00de08716a7050d954a8d7de1ee6b444eb 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 29 November 2003
+@set UPDATED 30 November 2003
 @set UPDATED-MONTH November 2003
 @set EDITION 1.7g
 @set VERSION 1.7g
index 3ba12101688d79cce2e9eb363422be5e1b6a72c4..fdce8f00de08716a7050d954a8d7de1ee6b444eb 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 29 November 2003
+@set UPDATED 30 November 2003
 @set UPDATED-MONTH November 2003
 @set EDITION 1.7g
 @set VERSION 1.7g
index e466f923ad6363f8bff65e3c3b20763e85469cd1..b7c21a4d89e22fadd06b8777540db67fb95f37a4 100644 (file)
@@ -293,6 +293,7 @@ ltcond2.test \
 ltconv.test \
 ltdeps.test \
 ltlibobjs.test \
+ltlibsrc.test \
 maintclean.test \
 make.test \
 makej.test \
index 5ab156d82ec0843731d55cdace435b94386eb14d..97800d7bf5281eb2c228e149230c4fbcc0613f9a 100644 (file)
@@ -407,6 +407,7 @@ ltcond2.test \
 ltconv.test \
 ltdeps.test \
 ltlibobjs.test \
+ltlibsrc.test \
 maintclean.test \
 make.test \
 makej.test \
diff --git a/tests/ltlibsrc.test b/tests/ltlibsrc.test
new file mode 100755 (executable)
index 0000000..fac0636
--- /dev/null
@@ -0,0 +1,59 @@
+#! /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
This page took 0.048215 seconds and 5 git commands to generate.