[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: fixing AC_CONFIG_HEADERS rules (PR/355)
From: |
Alexandre Duret-Lutz |
Subject: |
Re: RFC: fixing AC_CONFIG_HEADERS rules (PR/355) |
Date: |
Sun, 26 Oct 2003 22:19:55 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:
adl> This patch attempts to improve the rebuild rules for
adl> AC_CONFIG_HEADERS, but there is one aspect of the patch I don't
adl> like and I hope you can help me.
adl> To Akim (with whom I've discussed another aspect of these
adl> rules): this mail is completely unrelated to the stamp-h handling.
adl> That patch does four things:
adl> - duplicate rebuild rules for AC_CONFIG_HEADERS in all
adl> directories (this is for PR/355)
adl> - call autoheader only for the first AC_CONFIG_HEADERS
adl> (this matches the autoheader behavior)
adl> - have config.h.in dependent on all configure dependencies
adl> (i.e., all m4_includes)
adl> - ensure that all AC_CONFIG_HEADERS *inputs* are up to
adl> date before running a complete config.status.
I'm installing a cut-down version of this patch. It only
addresses the second and third points. I'm no longer sure the
first is correct, and I haven't yet figured something "right"
for the latter.
2003-10-26 Alexandre Duret-Lutz <address@hidden>
* automake.in (handle_configure): Distribute all AC_CONFIG_HEADERS
sources, and without using require_file. Define %CONFIG_H_DEPS%
and %FIRST_CONFIG_HIN% while processing remake-hdr.am.
* lib/am/remake-hdr.am (%STAMP%): Use %CONFIG_H_DEPS% instead
of (srcdir)/%CONFIG_HIN%. Output the $(srcdir)/%CONFIG_HIN%
rule only for the first header (i.e., if %FIRST_CONFIG_HIN%).
* tests/autohdr4.test: New file.
* tests/Makefile.am (TESTS): Add autohdr4.test.
* tests/config.test: Do not grep, run things to see if they work.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1508
diff -u -r1.1508 automake.in
--- automake.in 6 Oct 2003 21:47:33 -0000 1.1508
+++ automake.in 26 Oct 2003 21:17:14 -0000
@@ -3437,20 +3437,14 @@
}
}
- # Compute relative path from directory holding output
- # header to directory holding input header. FIXME:
- # doesn't handle case where we have multiple inputs.
- my $in0_sans_dir;
- if (dirname ($ins[0]) eq $relative_dir)
+ # Distribute all inputs.
+ for my $in (@ins)
{
- $in0_sans_dir = basename ($ins[0]);
+ error $config_header_location, "required file `$in' not found"
+ unless -f $in;
+ push_dist_common (rewrite_inputs_into_dependencies (1, $in));
}
- else
- {
- $in0_sans_dir = backname ($relative_dir) . '/' . $ins[0];
- }
-
- require_file ($config_header_location, FOREIGN, $in0_sans_dir);
+ @ins = rewrite_inputs_into_dependencies (1, @ins);
# Header defined and in this directory.
my @files;
@@ -3475,11 +3469,13 @@
$output_rules .=
file_contents ('remake-hdr',
new Automake::Location,
- FILES => "@files",
- CONFIG_H => $cn_sans_dir,
- CONFIG_HIN => $in0_sans_dir,
- CONFIG_H_PATH => $config_h_path,
- STAMP => "$stamp");
+ FILES => "@files",
+ CONFIG_H => $cn_sans_dir,
+ CONFIG_HIN => $ins[0],
+ CONFIG_H_DEPS => "@ins",
+ CONFIG_H_PATH => $config_h_path,
+ FIRST_CONFIG_HIN => ($hdr_index == 1),
+ STAMP => "$stamp");
push @distclean_config, $cn_sans_dir, $stamp;
}
Index: lib/am/remake-hdr.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/remake-hdr.am,v
retrieving revision 1.38
diff -u -r1.38 remake-hdr.am
--- lib/am/remake-hdr.am 6 Sep 2003 05:36:57 -0000 1.38
+++ lib/am/remake-hdr.am 26 Oct 2003 21:17:14 -0000
@@ -28,11 +28,14 @@
else :; fi
-%STAMP%: $(srcdir)/%CONFIG_HIN% $(top_builddir)/config.status
+%STAMP%: %CONFIG_H_DEPS% $(top_builddir)/config.status
@rm -f %STAMP%
cd $(top_builddir) && $(SHELL) ./config.status %CONFIG_H_PATH%
+## Only the first file of AC_CONFIG_HEADERS is assumed to be generated
+## by autoheader.
+if %?FIRST_CONFIG_HIN%
$(srcdir)/%CONFIG_HIN%: %MAINTAINER-MODE% $(top_srcdir)/%CONFIGURE-AC%
$(ACLOCAL_M4) %FILES%
cd $(top_srcdir) && $(AUTOHEADER)
## Autoheader has the bad habit of not changing the time stamp if
@@ -41,3 +44,4 @@
## by config.status, there is no reason to make things complex for
## config.hin.
touch $(srcdir)/%CONFIG_HIN%
+endif %?FIRST_CONFIG_HIN%
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.520
diff -u -r1.520 Makefile.am
--- tests/Makefile.am 6 Oct 2003 21:47:34 -0000 1.520
+++ tests/Makefile.am 26 Oct 2003 21:17:14 -0000
@@ -46,6 +46,7 @@
asm.test \
autohdr.test \
autohdr2.test \
+autohdr4.test \
auxdir.test \
auxdir2.test \
backsl.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.669
diff -u -r1.669 Makefile.in
--- tests/Makefile.in 21 Oct 2003 13:05:55 -0000 1.669
+++ tests/Makefile.in 26 Oct 2003 21:17:14 -0000
@@ -156,6 +156,7 @@
asm.test \
autohdr.test \
autohdr2.test \
+autohdr4.test \
auxdir.test \
auxdir2.test \
backsl.test \
Index: tests/autohdr4.test
===================================================================
RCS file: tests/autohdr4.test
diff -N tests/autohdr4.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/autohdr4.test 26 Oct 2003 21:17:14 -0000
@@ -0,0 +1,71 @@
+#!/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.
+
+# Check rebuild rules for AC_CONFIG_HEADERS.
+# (This should also work without GNU Make.)
+
+required=gcc
+. ./defs
+
+set -e
+
+cat >>configure.in <<EOF
+AC_PROG_CC
+AC_CONFIG_HEADERS([defs.h config.h:sub1/config.top:sub2/config.bot])
+AC_CONFIG_FILES([sub3/Makefile])
+AC_OUTPUT
+EOF
+
+mkdir sub1 sub2 sub3
+
+: > sub1/config.top
+echo '#define NAME "grepme1"' >sub2/config.bot
+echo SUBDIRS = sub3 >Makefile.am
+echo noinst_PROGRAMS = run >sub3/Makefile.am
+
+cat >sub3/run.c <<'EOF'
+#include <defs.h>
+#include <config.h>
+#include <stdio.h>
+
+int
+main ()
+{
+ puts (NAME); /* from config.h */
+ puts (PACKAGE); /* from defs.h */
+}
+EOF
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+./configure
+$MAKE
+sub3/run | grep grepme1
+
+$sleep
+echo '#define NAME "grepme2"' > sub2/config.bot
+$MAKE
+sub3/run | grep grepme2
+
+$MAKE distcheck
Index: tests/config.test
===================================================================
RCS file: /cvs/automake/automake/tests/config.test,v
retrieving revision 1.8
diff -u -r1.8 config.test
--- tests/config.test 8 Sep 2002 13:07:55 -0000 1.8
+++ tests/config.test 26 Oct 2003 21:17:14 -0000
@@ -22,21 +22,29 @@
# idea is that if config.h is in a subdir, and there is no Makefile in
# that subdir, then we want to build config.h as the top level.
+required=GNUmake
. ./defs || exit 1
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+set -e
+
+cat >> configure.in << 'END'
AM_CONFIG_HEADER(subdir/config.h)
-AC_PROG_CC
-AC_OUTPUT(Makefile)
+AC_OUTPUT
END
: > Makefile.am
mkdir subdir
: > subdir/config.h.in
-$ACLOCAL || exit 1
-$AUTOMAKE || exit 1
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+$sleep
+echo '#define FOO' > subdir/config.h.in
+$MAKE subdir/config.h
+grep FOO subdir/config.h
-grep '^subdir/config.h:' Makefile.in
+$MAKE distcheck
--
Alexandre Duret-Lutz