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.
+2004-08-01 Alexandre Duret-Lutz <adl@gnu.org>
+ Derek R. Price <derek@ximbiot.com>
+
+ 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.
+
2004-07-28 Alexandre Duret-Lutz <adl@gnu.org>
* configure.ac, NEWS: Bump version to 1.9a.
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.
\f
New in 1.9:
# 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 ($)
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'],
'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',
'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'],
'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',
# 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));
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);
@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
+@code{maintainer-mode} is enabled, or when the files have been erased.
@cindex ylwrap
-@set UPDATED 28 July 2004
+@set UPDATED 29 July 2004
@set UPDATED-MONTH July 2004
@set EDITION 1.9a
@set VERSION 1.9a
-@set UPDATED 28 July 2004
+@set UPDATED 29 July 2004
@set UPDATED-MONTH July 2004
@set EDITION 1.9a
@set VERSION 1.9a
## 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
## 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%
+@MAINTAINER_MODE_FALSE@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%
## 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
## 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%
+@MAINTAINER_MODE_FALSE@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/' \
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%
missing2.test \
mkinst2.test \
mkinstall.test \
+mmodely.test \
multlib.test \
nobase.test \
nodef.test \
missing2.test \
mkinst2.test \
mkinstall.test \
+mmodely.test \
multlib.test \
nobase.test \
nodef.test \
--- /dev/null
+#! /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=gcc
+. ./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
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
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)
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'
$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