[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH PING] Support AC_CONFIG_LIBOBJ_DIR (fixes PR/401)
From: |
Alexandre Duret-Lutz |
Subject: |
Re: [PATCH PING] Support AC_CONFIG_LIBOBJ_DIR (fixes PR/401) |
Date: |
Sat, 14 May 2005 16:25:54 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Here is where I am. This fixes a couple of issues in the
original proposal (cleaning, dependency tracking, alloca
support). However it is does not support remove LIBOBJS usage
without subdir-objects (it took me a while before giving up on
this).
2005-04-25 Gary V. Vaughan <address@hidden>
Alexandre Duret-Lutz <address@hidden>
Support for remote LIBOBJS (and friends) with subdir-objects.
Fixes PR automake/401.
* automake.in (config_libobj_dir): New variable.
(scan_autoconf_traces): Set config_libobj_dir from AC_CONFIG_LIBOBJ_DIR.
(handle_LIBOBJS_or_ALLOCA, require_libsource_with_macro): New functions.
(handle_LIBOBJS, handle_ALLOCA): Use them. Adjust location of
dependency files, possibly in a subdirectory.
* tests/pr401.test, tests/pr401b.test, tests/pr401c.test: New tests.
* tests/Makefile.am (TESTS): Add them.
* doc/automake.texi (Optional) <AC_CONFIG_LIBOBJ_DIR>: Document.
(LIBOBJS): Document changes in behaviour of
LIBOBJS, ALLOCA, LTLIBOBJS & LTALLOCA in the presence of
subdir-objects and an invocation of AC_CONFIG_LIBOBJ_DIR.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.298
diff -u -r1.298 NEWS
--- NEWS 6 Feb 2005 12:33:30 -0000 1.298
+++ NEWS 14 May 2005 14:24:20 -0000
@@ -84,6 +84,11 @@
variables are used as ${VAR}, and AC_SUBSTed, then Automake will
be able to output rules anyway.
(See the Automake documentation for AC_CONFIG_FILES.)
+
+ - If `subdir-objects' is set, and AC_CONFIG_LIBOBJ_DIR is specified,
+ $(LIBOBJS), $(LTLIBOBJS), $(ALLOCA), and $(LTALLOCA) can be used
+ in different directories.
+
New in 1.9:
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1601
diff -u -r1.1601 automake.in
--- automake.in 3 Mar 2005 21:35:44 -0000 1.1601
+++ automake.in 14 May 2005 14:24:21 -0000
@@ -338,6 +338,10 @@
# in Makefiles.
my $am_config_aux_dir = '';
+# Directory to search for AC_LIBSOURCE files, as set by AC_CONFIG_LIBOBJ_DIR
+# in configure.ac.
+my $config_libobj_dir = '';
+
# Whether AM_GNU_GETTEXT has been seen in configure.ac.
my $seen_gettext = 0;
# Whether AM_GNU_GETTEXT([external]) is used.
@@ -1856,7 +1860,7 @@
$depfile =~ s/\.([^.]*)$/.P$1/;
$depfile =~ s/\$\(OBJEXT\)$/o/;
$dep_files{dirname ($depfile) . '/$(DEPDIR)/'
- . basename ($depfile)} = 1;
+ . basename ($depfile)} = 1;
}
}
@@ -1914,10 +1918,10 @@
# Arguments are:
# canonical (transformed) name of target to build
# actual target of object to build
-# object extension (i.e. either `.o' or `$o'.
+# object extension (i.e., either `.o' or `$o')
# location of the source variable
# extra arguments to pass to file_contents when producing rules
-# Return result is name of linker variable that must be used.
+# Return the name of the linker variable that must be used.
# Empty return means just use `LINK'.
sub handle_source_transform ($$$$%)
{
@@ -2108,6 +2112,42 @@
return $seen_libobjs;
}
+# handle_LIBOBJS_or_ALLOCA ($VAR)
+# -------------------------------
+# Definitions common to LIBOBJS and ALLOCA.
+# VAR should be one of LIBOBJS, LTLIBOBJS, ALLOCA, or LTALLOCA.
+sub handle_LIBOBJS_or_ALLOCA ($)
+{
+ my ($var) = @_;
+
+ my $dir = $config_libobj_dir ? "$config_libobj_dir/" : '';
+
+ # If LIBOBJS files must be built in another directory we have
+ # to define LIBOBJDIR and ensure the files get cleaned.
+ # Otherwise LIBOBJDIR can be left undefined, and the cleaning
+ # is achieved by `rm -f *.($OBJEXT)' in compile.am.
+ if ($config_libobj_dir
+ && $relative_dir ne $config_libobj_dir)
+ {
+ if (option 'subdir-objects')
+ {
+ define_variable ('LIBOBJDIR', "\$(top_builddir)/$dir", INTERNAL);
+ $clean_files{"\$($var)"} = MOSTLY_CLEAN;
+ # If LTLIBOBJS is used, we must also clear LIBOBJS (which might
+ # be created by libtool as a side-effect of creating LTLIBOBJS).
+ $clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//;
+
+ }
+ else
+ {
+ error ("`\$($var)' cannot be used outside `$dir' if"
+ . " `subdir-objects' is not set");
+ }
+ }
+
+ return $dir;
+}
+
sub handle_LIBOBJS ($$$)
{
my ($var, $cond, $lt) = @_;
@@ -2117,6 +2157,8 @@
$var->requires_variables ("address@hidden@ used", $lt . 'LIBOBJS')
if ! keys %libsources;
+ my $dir = handle_LIBOBJS_or_ALLOCA "${lt}LIBOBJS";
+
foreach my $iter (keys %libsources)
{
if ($iter =~ /\.[cly]$/)
@@ -2127,19 +2169,19 @@
if ($iter =~ /\.h$/)
{
- require_file_with_macro ($cond, $var, FOREIGN, $iter);
+ require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
}
elsif ($iter ne 'alloca.c')
{
my $rewrite = $iter;
$rewrite =~ s/\.c$/.P$myobjext/;
- $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
+ $dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1;
$rewrite = "^" . quotemeta ($iter) . "\$";
# Only require the file if it is not a built source.
my $bs = var ('BUILT_SOURCES');
if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive))
{
- require_file_with_macro ($cond, $var, FOREIGN, $iter);
+ require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
}
}
}
@@ -2150,10 +2192,12 @@
my ($var, $cond, $lt) = @_;
my $myobjext = ($lt ? 'l' : '') . 'o';
$lt ||= '';
+ my $dir = handle_LIBOBJS_or_ALLOCA "${lt}ALLOCA";
+
$var->requires_variables ("address@hidden@ used", $lt . 'ALLOCA');
- $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
- require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
- &saw_extension ('c');
+ $dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1;
+ require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c');
+ &saw_extension ('.c');
}
# Canonicalize the input parameter
@@ -4715,6 +4759,7 @@
AC_CONFIG_AUX_DIR => 1,
AC_CONFIG_FILES => 1,
AC_CONFIG_HEADERS => 1,
+ AC_CONFIG_LIBOBJ_DIR => 1,
AC_CONFIG_LINKS => 1,
AC_INIT => 0,
AC_LIBSOURCE => 1,
@@ -4811,6 +4856,12 @@
push @config_headers, $spec;
}
}
+ elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR')
+ {
+ $config_libobj_dir = $args[1];
+ $relative_dir = '.';
+ check_directory ($config_libobj_dir, $where);
+ }
elsif ($macro eq 'AC_CONFIG_LINKS')
{
foreach my $spec (split (' ', $args[1]))
@@ -7169,6 +7220,24 @@
require_file ($macro->rdef ($cond)->location, $mystrict, @files);
}
+# &require_libsource_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+# ----------------------------------------------------------------
+# Require an AC_LIBSOURCEd file. If AC_CONFIG_LIBOBJ_DIR was called, it
+# must be in that directory. Otherwise expect it in the current directory.
+sub require_libsource_with_macro ($$$@)
+{
+ my ($cond, $macro, $mystrict, @files) = @_;
+ $macro = rvar ($macro) unless ref $macro;
+ if ($config_libobj_dir)
+ {
+ require_file_internal ($macro->rdef ($cond)->location, $mystrict,
+ $config_libobj_dir, @files);
+ }
+ else
+ {
+ require_file ($macro->rdef ($cond)->location, $mystrict, @files);
+ }
+}
# &require_conf_file ($WHERE, $MYSTRICT, @FILES)
# ----------------------------------------------
Index: doc/automake.texi
===================================================================
RCS file: /cvs/automake/automake/doc/automake.texi,v
retrieving revision 1.114
diff -u -r1.114 automake.texi
--- doc/automake.texi 18 Apr 2005 07:10:46 -0000 1.114
+++ doc/automake.texi 14 May 2005 14:24:23 -0000
@@ -1450,23 +1450,17 @@
Currently recognized macros and their effects are:
@ftable @code
address@hidden AC_CONFIG_HEADERS
-Automake will generate rules to rebuild these headers. Older versions
-of Automake required the use of @code{AM_CONFIG_HEADER}
-(@pxref{Macros}); this is no longer the case today.
-
-As for @code{AC_CONFIG_FILES} (@pxref{Requirements}), parts of the
-specification using shell variables will be ignored as far as
-cleaning, distributing, and rebuilding is concerned.
-
address@hidden AC_CONFIG_LINKS
-Automake will generate rules to remove @file{configure} generated
-links on @samp{make distclean} and to distribute named source files as
-part of @samp{make dist}.
-
-As for @code{AC_CONFIG_FILES} (@pxref{Requirements}), parts of the
-specification using shell variables will be ignored as far as cleaning
-and distributing is concerned. (There is no rebuild rules for links.)
address@hidden AC_CANONICAL_BUILD
address@hidden AC_CANONICAL_HOST
address@hidden AC_CANONICAL_TARGET
address@hidden build_triplet
address@hidden host_triplet
address@hidden target_triplet
+Automake will ensure that @file{config.guess} and @file{config.sub}
+exist. Also, the @file{Makefile} variables @code{build_triplet},
address@hidden and @code{target_triplet} are introduced. See
address@hidden, , Getting the Canonical System Type, autoconf,
+The Autoconf Manual}.
@item AC_CONFIG_AUX_DIR
Automake will look for various helper scripts, such as
@@ -1491,21 +1485,32 @@
Required files from @code{AC_CONFIG_AUX_DIR} are automatically
distributed, even if there is no @file{Makefile.am} in this directory.
address@hidden AC_CANONICAL_BUILD
address@hidden AC_CANONICAL_HOST
address@hidden AC_CANONICAL_TARGET
address@hidden build_triplet
address@hidden host_triplet
address@hidden target_triplet
-Automake will ensure that @file{config.guess} and @file{config.sub}
-exist. Also, the @file{Makefile} variables @code{build_triplet},
address@hidden and @code{target_triplet} are introduced. See
address@hidden, , Getting the Canonical System Type, autoconf,
-The Autoconf Manual}.
address@hidden AC_CONFIG_LIBOBJ_DIR
+Automake will require the sources file declared with
address@hidden (see below) in the directory specified by this
+macro.
address@hidden AC_LIBSOURCE
address@hidden AC_CONFIG_HEADERS
+Automake will generate rules to rebuild these headers. Older versions
+of Automake required the use of @code{AM_CONFIG_HEADER}
+(@pxref{Macros}); this is no longer the case today.
+
+As for @code{AC_CONFIG_FILES} (@pxref{Requirements}), parts of the
+specification using shell variables will be ignored as far as
+cleaning, distributing, and rebuilding is concerned.
+
address@hidden AC_CONFIG_LINKS
+Automake will generate rules to remove @file{configure} generated
+links on @samp{make distclean} and to distribute named source files as
+part of @samp{make dist}.
+
+As for @code{AC_CONFIG_FILES} (@pxref{Requirements}), parts of the
+specification using shell variables will be ignored as far as cleaning
+and distributing is concerned. (There is no rebuild rules for links.)
+
address@hidden AC_LIBOBJ
address@hidden AC_LIBSOURCE
@itemx AC_LIBSOURCES
address@hidden AC_LIBOBJ
@vindex LIBOBJS
Automake will automatically distribute any file listed in
@code{AC_LIBSOURCE} or @code{AC_LIBSOURCES}.
@@ -4303,9 +4308,9 @@
The @code{AC_CONFIG_LIBOBJ_DIR} tells Autoconf that the source files
of these object files are to be found in the @file{lib/} directory.
-Automake does not yet use this information; it knows the source files
-are expected to be in the directory where the @samp{$(LIBOBJS)} and
address@hidden(ALLOCA)} variables are used.
+Automake can also use this information, otherwise it expects the
+source files are to be in the directory where the @samp{$(LIBOBJS)}
+and @samp{$(ALLOCA)} variables are used.
The @file{lib/} directory should therefore contain @file{malloc.c},
@file{memcmp.c}, @file{strdup.c}, @file{alloca.c}. Here is its
@@ -4349,13 +4354,25 @@
tool2_SOURCES = @dots{}
@end example
-Please note it would be wrong to use the variables @samp{$(LIBOBJS)} or
address@hidden(ALLOCA)} in @file{src/Makefile.am}, because these variables
-contains unprefixed object names, and, for instance,
address@hidden(OBJEXT)} is not buildable in the @file{src/} directory.
-(Actually if you try using @samp{$(LIBOBJS)} in @file{src/}, Automake
-will require a copy of @file{malloc.c}, @file{memcmp.c},
address@hidden, @file{alloca.c} in @file{src/} too.)
+When option @option{subdir-objects} is not used, as in the above
+example, the variables @samp{$(LIBOBJS)} or @samp{$(ALLOCA)} can only
+be used in the directory where their sources lie. E.g., here it would
+be wrong to use @samp{$(LIBOBJS)} or @samp{$(ALLOCA)} in
address@hidden/Makefile.am}. However if both @option{subdir-objects} and
address@hidden are used, it is OK to use these variables
+in other directories. For instance @file{src/Makefile.am} could be
+changed as follows.
+
address@hidden
+# src/Makefile.am
+
+AUTOMAKE_OPTIONS = subdir-objects
+LDADD = $(LIBOBJS) $(ALLOCA)
+
+bin_PROGRAMS = tool1 tool2 @dots{}
+tool1_SOURCES = @dots{}
+tool2_SOURCES = @dots{}
address@hidden example
Because @samp{$(LIBOBJS)} and @samp{$(ALLOCA)} contain object
file names that end with @samp{.$(OBJEXT)}, they are not suitable for
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.586
diff -u -r1.586 Makefile.am
--- tests/Makefile.am 29 Mar 2005 18:46:55 -0000 1.586
+++ tests/Makefile.am 14 May 2005 14:24:23 -0000
@@ -415,6 +415,9 @@
pr300-ltlib.test \
pr300-prog.test \
pr307.test \
+pr401.test \
+pr401b.test \
+pr401c.test \
prefix.test \
primary.test \
primary2.test \
Index: tests/pr401.test
===================================================================
RCS file: tests/pr401.test
diff -N tests/pr401.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/pr401.test 14 May 2005 14:24:23 -0000
@@ -0,0 +1,152 @@
+#! /bin/sh
+# Copyright (C) 2005 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.
+
+# Check support for AC_CONFIG_LIBOBJ_DIR vs LIBOBJS.
+# (pr401b.test and pr401c.test do the same for LTLIBOBJS and ALLOCA)
+
+required=gcc
+. ./defs || exit 1
+
+set -e
+
+mkdir lib src
+
+cat >lib/feep.c <<'EOF'
+char *
+feep ()
+{
+ return "feep";
+}
+EOF
+
+cat >src/feep.c <<'EOF'
+#include <stdio.h>
+
+extern char *feep ();
+
+int
+main (int argc, char **argv)
+{
+ puts (feep ());
+ return 0;
+}
+EOF
+
+cat >>configure.in << 'EOF'
+## These lines are activated for later tests
+#: AC_CONFIG_LIBOBJ_DIR([lib])
+AC_PROG_CC
+#: AM_PROG_CC_C_O
+AC_LIBOBJ([feep])
+AC_LIBSOURCE([feep.c])
+AC_PROG_RANLIB
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AC_OUTPUT
+EOF
+
+## ------------------------------------------ ##
+## First a test of traditional LIBOBJS usage. ##
+## ------------------------------------------ ##
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib src
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(LIBOBJS)
+EOF
+
+cat >src/Makefile.am <<'EOF'
+check_PROGRAMS = feep
+feep_LDADD = ../lib/libfeep.a
+
+TESTS = feep
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+
+## -------------------------------------------- ##
+## Test using LIBOBJS from a sibling directory. ##
+## -------------------------------------------- ##
+
+$PERL -pi -e 's/#: //' configure.in
+$PERL -pi -e 's/lib\/Makefile //' configure.in
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = src
+EOF
+
+cat > src/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(LIBOBJS)
+
+check_PROGRAMS = feep
+feep_LDADD = libfeep.a
+
+TESTS = feep
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE
+$MAKE check
+$MAKE distclean
+
+
+## ----------------------------------------- ##
+## Test using LIBOBJS from parent directory. ##
+## ----------------------------------------- ##
+
+$PERL -pi -e 's/^.*src\/Makefile.*$//' configure.in
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = lib/libfeep.a
+lib_libfeep_a_SOURCES =
+lib_libfeep_a_LIBADD = $(LIBOBJS)
+
+check_PROGRAMS = src/feep
+src_feep_SOURCES = src/feep.c
+src_feep_LDADD = lib/libfeep.a
+
+TESTS = src/feep
+
+check-local:
+ test -f src/feep.$(OBJEXT)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
Index: tests/pr401b.test
===================================================================
RCS file: tests/pr401b.test
diff -N tests/pr401b.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/pr401b.test 14 May 2005 14:24:23 -0000
@@ -0,0 +1,153 @@
+#! /bin/sh
+# Copyright (C) 2005 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.
+
+# Check support for AC_CONFIG_LIBOBJ_DIR vs LTLIBOBJS.
+# (pr401.test and pr401c.test do the same for LIBOBJS and ALLOCA)
+
+required='gcc libtoolize'
+. ./defs || exit 1
+
+set -e
+
+mkdir lib src
+
+cat >lib/feep.c <<'EOF'
+char *
+feep ()
+{
+ return "feep";
+}
+EOF
+
+cat >src/feep.c <<'EOF'
+#include <stdio.h>
+
+extern char *feep ();
+
+int
+main (int argc, char **argv)
+{
+ puts (feep ());
+ return 0;
+}
+EOF
+
+cat >>configure.in << 'EOF'
+## These lines are activated for later tests
+#: AC_CONFIG_LIBOBJ_DIR([lib])
+AC_PROG_CC
+#: AM_PROG_CC_C_O
+AC_LIBOBJ([feep])
+AC_LIBSOURCE([feep.c])
+AC_PROG_LIBTOOL
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AC_OUTPUT
+EOF
+
+## -------------------------------------------- ##
+## First a test of traditional LTLIBOBJS usage. ##
+## -------------------------------------------- ##
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib src
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LTLIBRARIES = libfeep.la
+libfeep_la_SOURCES =
+libfeep_la_LIBADD = $(LTLIBOBJS)
+EOF
+
+cat >src/Makefile.am <<'EOF'
+check_PROGRAMS = feep
+feep_LDADD = ../lib/libfeep.la
+
+TESTS = feep
+EOF
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE distcheck
+
+
+## ---------------------------------------------- ##
+## Test using LTLIBOBJS from a sibling directory. ##
+## ---------------------------------------------- ##
+
+$PERL -pi -e 's/#: //' configure.in
+$PERL -pi -e 's/lib\/Makefile //' configure.in
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = src
+EOF
+
+cat > src/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LTLIBRARIES = libfeep.la
+libfeep_la_SOURCES =
+libfeep_la_LIBADD = $(LTLIBOBJS)
+
+check_PROGRAMS = feep
+feep_LDADD = libfeep.la
+
+TESTS = feep
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE
+$MAKE check
+$MAKE distclean
+
+
+## ------------------------------------------- ##
+## Test using LTLIBOBJS from parent directory. ##
+## ------------------------------------------- ##
+
+$PERL -pi -e 's/^.*src\/Makefile.*$//' configure.in
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LTLIBRARIES = lib/libfeep.la
+lib_libfeep_la_SOURCES =
+lib_libfeep_la_LIBADD = $(LTLIBOBJS)
+
+check_PROGRAMS = src/feep
+src_feep_SOURCES = src/feep.c
+src_feep_LDADD = lib/libfeep.la
+
+TESTS = src/feep
+
+check-local:
+ test -f src/feep.$(OBJEXT)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
Index: tests/pr401c.test
===================================================================
RCS file: tests/pr401c.test
diff -N tests/pr401c.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/pr401c.test 14 May 2005 14:24:23 -0000
@@ -0,0 +1,154 @@
+#! /bin/sh
+# Copyright (C) 2005 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.
+
+# Check support for AC_CONFIG_LIBOBJ_DIR vs ALLOCA.
+# (pr401.test and pr401b.test do the same for LIBOBJS and LTLIBOBJS)
+
+required=gcc
+. ./defs || exit 1
+
+set -e
+
+mkdir lib src
+
+ac_cv_func_alloca_works=no
+export ac_cv_func_alloca_works
+
+cat >lib/alloca.c <<'EOF'
+char *
+feep ()
+{
+ return "feep";
+}
+EOF
+
+cat >src/feep.c <<'EOF'
+#include <stdio.h>
+
+extern char *feep ();
+
+int
+main (int argc, char **argv)
+{
+ puts (feep ());
+ return 0;
+}
+EOF
+
+cat >>configure.in << 'EOF'
+## These lines are activated for later tests
+#: AC_CONFIG_LIBOBJ_DIR([lib])
+AC_PROG_CC
+#: AM_PROG_CC_C_O
+AC_PROG_RANLIB
+AC_FUNC_ALLOCA
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AC_OUTPUT
+EOF
+
+## ----------------------------------------- ##
+## First a test of traditional ALLOCA usage. ##
+## ----------------------------------------- ##
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib src
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(ALLOCA)
+EOF
+
+cat >src/Makefile.am <<'EOF'
+check_PROGRAMS = feep
+feep_LDADD = ../lib/libfeep.a
+
+TESTS = feep
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+
+## ------------------------------------------- ##
+## Test using ALLOCA from a sibling directory. ##
+## ------------------------------------------- ##
+
+$PERL -pi -e 's/#: //' configure.in
+$PERL -pi -e 's/lib\/Makefile //' configure.in
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = src
+EOF
+
+cat > src/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun
+
+check_PROGRAMS = feep
+feep_LDADD = libfeep.a
+
+TESTS = feep
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE
+$MAKE check
+$MAKE distclean
+
+
+## ---------------------------------------- ##
+## Test using ALLOCA from parent directory. ##
+## ---------------------------------------- ##
+
+$PERL -pi -e 's/^.*src\/Makefile.*$//' configure.in
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = lib/libfeep.a
+lib_libfeep_a_SOURCES =
+lib_libfeep_a_LIBADD = $(ALLOCA)
+
+check_PROGRAMS = src/feep
+src_feep_SOURCES = src/feep.c
+src_feep_LDADD = lib/libfeep.a
+
+TESTS = src/feep
+
+check-local:
+ test -f src/feep.$(OBJEXT)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
--
Alexandre Duret-Lutz