[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] Re: CVS Bug? or User error?
From: |
Alexandre Duret-Lutz |
Subject: |
Re: [Bug-gnulib] Re: CVS Bug? or User error? |
Date: |
Thu, 29 Jul 2004 23:41:37 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
Here is my proposal.
The repeated occurrences of
?GENERIC? $(am__skiplex) \
?!GENERIC??DIST_SOURCE? $(am__skiplex)\
in yacc.am are ugly, but I wouldn't worry about it. Akim
suggested some months ago to remove the !MORE-THAN-ONE part of
yacc.am and lex.am and always use depcomp to simplify Automake
and limit the code duplication. I plan to do this; so that will
remove all this cruft.
2004-07-29 Alexandre Duret-Lutz <address@hidden>
Derek R. Price <address@hidden>
Disable Lex and Yacc rules whenever possible if AM_MAINTAINER_MODE
is used and maintainer-mode disabled.
* automake.in (Automake::struct): Define nodist_specific.
Set it in languages yacc, yaccxx, lex, and lexxx.
(register_language): Default nodist_specific to 0.
(handle_single_transform): Honor nodist_specific.
* lib/am/yacc.am (am__skipyacc): Define this in maintainer mode.
(%EXT%%DERIVED-EXT%, %OBJ%): Use $(am__skipyacc) to disable these
rules when needed.
* lib/am/lex.am (am__skiplex): Define this in maintainer mode.
(%EXT%%DERIVED-EXT%, %OBJ%): Use $(am__skiplex) to disable these
rules when needed.
* tests/mmodely.test: New file.
* tests/pr204.test: Augment to check AM_MAINTAINER_MODE and nodist_
parsers.
* tests/Makefile.am (TESTS): Add mmodely.test.
* doc/automake.texi (Yacc and Lex): Note dependence on maintainer mode.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.284
diff -u -r1.284 NEWS
--- NEWS 28 Jul 2004 20:51:36 -0000 1.284
+++ NEWS 29 Jul 2004 21:31:23 -0000
@@ -1,4 +1,8 @@
New in 1.9a:
+
+ - The rebuild rules for distributed Yacc and Lex output will avoid
+ overwriting existing files if AM_MAINTAINER_MODE and maintainer-mode
+ is not enabled.
New in 1.9:
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1569
diff -u -r1.1569 automake.in
--- automake.in 28 Jul 2004 20:05:15 -0000 1.1569
+++ automake.in 29 Jul 2004 21:31:28 -0000
@@ -100,7 +100,11 @@
# This is a subroutine which is called whenever we finally
# determine the context in which a source file will be
# compiled.
- '_target_hook' => "\$");
+ '_target_hook' => "\$",
+
+ # If TRUE, nodist_ sources will be compiled using specific rules
+ # (i.e. not inference rules). The default is FALSE.
+ 'nodist_specific' => "\$");
sub finish ($)
@@ -732,7 +736,8 @@
return ($ext,) },
'rule_file' => 'yacc',
'_finish' => \&lang_yacc_finish,
- '_target_hook' => \&lang_yacc_target_hook);
+ '_target_hook' => \&lang_yacc_target_hook,
+ 'nodist_specific' => 1);
register_language ('name' => 'yaccxx',
'Name' => 'Yacc (C++)',
'config_vars' => ['YACC'],
@@ -744,7 +749,8 @@
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'_finish' => \&lang_yacc_finish,
- '_target_hook' => \&lang_yacc_target_hook);
+ '_target_hook' => \&lang_yacc_target_hook,
+ 'nodist_specific' => 1);
# Lex (C & C++).
register_language ('name' => 'lex',
@@ -758,7 +764,8 @@
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
- '_target_hook' => \&lang_lex_target_hook);
+ '_target_hook' => \&lang_lex_target_hook,
+ 'nodist_specific' => 1);
register_language ('name' => 'lexxx',
'Name' => 'Lex (C++)',
'config_vars' => ['LEX'],
@@ -770,7 +777,8 @@
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
- '_target_hook' => \&lang_lex_target_hook);
+ '_target_hook' => \&lang_lex_target_hook,
+ 'nodist_specific' => 1);
# Assembler.
register_language ('name' => 'asm',
@@ -1643,8 +1651,11 @@
# Using inference rules for subdir-objects has been tested
# with GNU make, Solaris make, Ultrix make, BSD make,
# HP-UX make, and OSF1 make successfully.
- if ($renamed ||
- ($directory ne '' && ! option 'subdir-objects'))
+ if ($renamed
+ || ($directory ne '' && ! option 'subdir-objects')
+ # We must also use specific rules for a nodist_ source
+ # if its language requests it.
+ || ($lang->nodist_specific && ! $transform{'DIST_SOURCE'}))
{
my $obj_sans_ext = substr ($object, 0,
- length ($this_obj_ext));
@@ -5447,6 +5458,8 @@
unless defined $option{'flags'};
$option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
unless defined $option{'output_extensions'};
+ $option{'nodist_specific'} = 0
+ unless defined $option{'nodist_specific'};
my $lang = new Language (%option);
Index: doc/automake.texi
===================================================================
RCS file: /cvs/automake/automake/doc/automake.texi,v
retrieving revision 1.44
diff -u -r1.44 automake.texi
--- doc/automake.texi 28 Jul 2004 19:58:36 -0000 1.44
+++ doc/automake.texi 29 Jul 2004 21:31:33 -0000
@@ -3765,6 +3765,9 @@
@samp{AM_LFLAGS}. The former is a user variable and the latter is
intended for the @file{Makefile.am} author.
+When @code{AM_MAINTAINER_MODE} (@pxref{maintainer-mode}) is used, the
+rebuild rule for distributed Yacc and Lex sources are only used when
address@hidden is enabled, or when the files have been erased.
@cindex ylwrap
Index: lib/am/lex.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/lex.am,v
retrieving revision 1.11
diff -u -r1.11 lex.am
--- lib/am/lex.am 28 Jul 2004 19:58:37 -0000 1.11
+++ lib/am/lex.am 29 Jul 2004 21:31:33 -0000
@@ -1,5 +1,5 @@
## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -16,17 +16,28 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
+## See the comment about am__skipyacc in yacc.am.
+if %?MAINTAINER-MODE%
+if %?FIRST%
address@hidden@am__skiplex = test -f $@ ||
+endif %?FIRST%
+endif %?MAINTAINER-MODE%
+
?GENERIC?%EXT%%DERIVED-EXT%:
?!GENERIC?%OBJ%: %SOURCE%
if %?MORE-THAN-ONE%
-?GENERIC? $(SHELL) $(YLWRAP) %SOURCE% $(LEX_OUTPUT_ROOT).c %OBJ% --
%COMPILE%
+?GENERIC? $(am__skiplex) $(SHELL) $(YLWRAP) %SOURCE% $(LEX_OUTPUT_ROOT).c
%OBJ% -- %COMPILE%
+?!GENERIC??DIST_SOURCE? $(am__skiplex) \
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
?!GENERIC? $(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo
'$(srcdir)/'`%SOURCE% $(LEX_OUTPUT_ROOT).c %OBJ% -- %COMPILE%
else !%?MORE-THAN-ONE%
-?GENERIC? %COMPILE% %SOURCE%
+?GENERIC? $(am__skiplex) %COMPILE% %SOURCE%
+?!GENERIC??DIST_SOURCE? $(am__skiplex) \
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
?!GENERIC? %COMPILE% `test -f %SOURCE% || echo '$(srcdir)/'`%SOURCE%
## Edit out `#line' or `#' directives.
- sed '/^#/ s|$(LEX_OUTPUT_ROOT)\.c|%OBJ%|' $(LEX_OUTPUT_ROOT).c >%OBJ%
- rm -f $(LEX_OUTPUT_ROOT).c
+?GENERIC? $(am__skiplex) \
+?!GENERIC??DIST_SOURCE? $(am__skiplex)\
+ { sed '/^#/ s|$(LEX_OUTPUT_ROOT)\.c|%OBJ%|' $(LEX_OUTPUT_ROOT).c >%OBJ%
&& \
+ rm -f $(LEX_OUTPUT_ROOT).c; }
endif !%?MORE-THAN-ONE%
Index: lib/am/yacc.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/yacc.am,v
retrieving revision 1.18
diff -u -r1.18 yacc.am
--- lib/am/yacc.am 28 Jul 2004 19:58:37 -0000 1.18
+++ lib/am/yacc.am 29 Jul 2004 21:31:33 -0000
@@ -1,5 +1,5 @@
## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004 Free Software Foundation,
Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -16,19 +16,47 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
+## We want to disable the Yacc rebuild rule when
+## 1. AM_MAINTAINER_MODE is used, and
+## 2. --enable-maintainer-mode is not specified, and
+## 3. parser.c already exist, and
+## 4. parser.y and parser.c are distributed.
+## Point #3 is because `make maintainer-clean' erases parser.c, yet
+## the GNU Coding Standards require that ./configure; make works even
+## after that.
+## Point #4 is because parsers listed in nodist_*_SOURCES are always
+## built on the user's side, so it makes no sense to disable them.
+##
+## Points #1, #2, #3 are solved by unconditionally prefixing the rules
+## with $(am__skipyacc) defined below only when needed.
+##
+## Point #4 requires a condition on whether parser.y/parser.c are
+## distributed or not. We cannot have a generic rule that works in
+## both cases, so we ensure in automake that nodist_ parsers always
+## use non-generic rules.
+if %?MAINTAINER-MODE%
+if %?FIRST%
address@hidden@am__skipyacc = test -f $@ ||
+endif %?FIRST%
+endif %?MAINTAINER-MODE%
+
?GENERIC?%EXT%%DERIVED-EXT%:
?!GENERIC?%OBJ%: %SOURCE%
if %?MORE-THAN-ONE%
-?GENERIC? $(SHELL) $(YLWRAP) %SOURCE% y.tab.c %OBJ% y.tab.h %BASE%.h
y.output %BASE%.output -- %COMPILE%
+?GENERIC? $(am__skipyacc) $(SHELL) $(YLWRAP) %SOURCE% y.tab.c %OBJ%
y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE%
+?!GENERIC??DIST_SOURCE? $(am__skipyacc) \
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
?!GENERIC? $(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo
'$(srcdir)/'`%SOURCE% y.tab.c %OBJ% y.tab.h %BASE%.h y.output %BASE%.output --
%COMPILE%
else !%?MORE-THAN-ONE%
-?GENERIC? %COMPILE% %SOURCE%
+?GENERIC? $(am__skipyacc) %COMPILE% %SOURCE%
+?!GENERIC??DIST_SOURCE? $(am__skipyacc) \
## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
?!GENERIC? %COMPILE% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
## Edit out Bison multiple inclusion guards. It may be BISON_Y_TAB_H,
## or Y_TAB_H depending upon the version, that's why the regexp is
## so loose.
+?GENERIC? $(am__skipyacc) \
+?!GENERIC??DIST_SOURCE? $(am__skipyacc) \
if test -f y.tab.h; then \
to=`echo "%BASE%_H" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
@@ -41,10 +69,14 @@
mv %BASE%.ht %BASE%.h; \
fi; \
fi
+?GENERIC? $(am__skipyacc) \
+?!GENERIC??DIST_SOURCE? $(am__skipyacc) \
if test -f y.output; then \
mv y.output %BASE%.output; \
fi
+?GENERIC? $(am__skipyacc) \
+?!GENERIC??DIST_SOURCE? $(am__skipyacc) \
## Edit out `#line' or `#' directives.
- sed '/^#/ s|y\.tab\.c|%OBJ%|' y.tab.c >%OBJ%t && mv %OBJ%t %OBJ%
- rm -f y.tab.c
+ { sed '/^#/ s|y\.tab\.c|%OBJ%|' y.tab.c >%OBJ%t && mv %OBJ%t %OBJ% && \
+ rm -f y.tab.c; }
endif !%?MORE-THAN-ONE%
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.565
diff -u -r1.565 Makefile.am
--- tests/Makefile.am 11 Jul 2004 22:07:24 -0000 1.565
+++ tests/Makefile.am 29 Jul 2004 21:31:33 -0000
@@ -333,6 +333,7 @@
missing2.test \
mkinst2.test \
mkinstall.test \
+mmodely.test \
multlib.test \
nobase.test \
nodef.test \
Index: tests/mmodely.test
===================================================================
RCS file: tests/mmodely.test
diff -N tests/mmodely.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/mmodely.test 29 Jul 2004 21:31:33 -0000
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2004 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.
+
+# Verify that intermediate files are only built from Yacc and Lex
+# sources in maintainer mode.
+# From Derek R. Price.
+
+required='bison flex'
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+AM_PROG_LEX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+YACC = false
+LEX = false
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.y joe.l
+LDADD = @LEXLIB@
+END
+
+# The point of this test is that it is not dependant on a working lex or yacc.
+cat > joe.c <<EOF
+int joe (int arg)
+{
+ return arg * 2;
+}
+EOF
+cat > zardoz.c <<EOF
+int joe (int arg);
+int main (int argc, char **argv)
+{
+ exit (joe (argc));
+}
+EOF
+
+# Ensure a later timestamp for our Lex & Yacc sources.
+$sleep
+: > joe.l
+: > zardoz.y
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+
+# make maintainer-clean; ./configure; make should always work,
+# per GNU Standard.
+$MAKE maintainer-clean
+./configure
+YACC='echo>y.tab.c' LEX='echo>lex.yy.c' $MAKE -e zardoz.c joe.c
+grep zardoz.y zardoz.c
+grep joe.l joe.c
Index: tests/pr204.test
===================================================================
RCS file: /cvs/automake/automake/tests/pr204.test,v
retrieving revision 1.7
diff -u -r1.7 pr204.test
--- tests/pr204.test 14 Jul 2004 14:49:09 -0000 1.7
+++ tests/pr204.test 29 Jul 2004 21:31:33 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -29,6 +29,7 @@
cat > configure.in <<'EOF'
AC_INIT(pr204, 0.1)
AM_INIT_AUTOMAKE
+AM_MAINTAINER_MODE
AC_PROG_CC
AC_PROG_YACC
AC_CONFIG_FILES(Makefile)
@@ -43,6 +44,14 @@
EXTRA_PROGRAMS = foo
PARSE2 = parse2.y
nodist_foo_SOURCES = parse.y $(PARSE2)
+
+distdirtest: distdir
+ test ! -f $(distdir)/parse.c
+ test ! -f $(distdir)/parse.y
+ test ! -f $(distdir)/parse.h
+ test ! -f $(distdir)/parse2.c
+ test ! -f $(distdir)/parse2.y
+ test ! -f $(distdir)/parse2.h
EOF
cat > parse.y << 'END'
@@ -60,12 +69,16 @@
$AUTOCONF
$AUTOMAKE -a
./configure
-$MAKE distdir
-test -f pr204-0.1/parse.c && exit 1
-test -f pr204-0.1/parse.y && exit 1
-test -f pr204-0.1/parse.h && exit 1
-test -f pr204-0.1/parse2.c && exit 1
-test -f pr204-0.1/parse2.y && exit 1
-test -f pr204-0.1/parse2.h && exit 1
+$MAKE distdirtest
# Make sure parse.c and parse2.c are still targets.
$MAKE parse.c parse2.c
+test -f parse.c
+test -f parse2.c
+
+# Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
+# it's a nodist_ parser.
+$sleep
+touch parse.y
+$sleep
+$MAKE parse.c parse2.c
+test `ls -1t parse.c parse.y | sed 1q` = parse.c
--
Alexandre Duret-Lutz