From: Akim Demaille Date: Mon, 9 Apr 2001 09:58:56 +0000 (+0000) Subject: * automake.in (&condition_negate): New. X-Git-Tag: handle-languages~101 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=55c83f46d31173ed64461fa4e769d0a3a6683054;p=automake.git * automake.in (&condition_negate): New. (&variable_conditions_permutations): Use it. (&read_am_file, &file_contents): Use it on `else' clauses to support `if FALSE'. (&output_yacc_build_rule): Output this... * yacc.am: New file. --- diff --git a/ChangeLog b/ChangeLog index 05306fc0..c4eb82e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-04-09 Akim Demaille + + * automake.in (&condition_negate): New. + (&variable_conditions_permutations): Use it. + (&read_am_file, &file_contents): Use it on `else' clauses to + support `if FALSE'. + (&output_yacc_build_rule): Output this... + * yacc.am: New file. + 2001-04-09 Akim Demaille * automake.in (&make_paragraphs): Transform TOPDIR_P and TOPDIR. diff --git a/Makefile.am b/Makefile.am index 8da2d3da..ba257991 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,7 +16,7 @@ distdir.am footer.am header-vars.am header.am install.am java.am \ kr-extra.am library.am libs.am libtool.am lisp.am ltlib.am \ ltlibrary.am mans-vars.am mans.am multilib.am program.am progs.am \ python.am remake-hdr.am remake.am scripts.am subdirs.am tags.am \ -texi-vers.am texibuild.am texinfos.am +texi-vers.am texibuild.am texinfos.am yacc.am dist_pkgdata_DATA = COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \ $(amfiles) diff --git a/Makefile.in b/Makefile.in index de98e157..5352795f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -89,7 +89,7 @@ distdir.am footer.am header-vars.am header.am install.am java.am \ kr-extra.am library.am libs.am libtool.am lisp.am ltlib.am \ ltlibrary.am mans-vars.am mans.am multilib.am program.am progs.am \ python.am remake-hdr.am remake.am scripts.am subdirs.am tags.am \ -texi-vers.am texibuild.am texinfos.am +texi-vers.am texibuild.am texinfos.am yacc.am dist_pkgdata_DATA = COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \ diff --git a/automake.in b/automake.in index 9d5c3213..ec6a0726 100755 --- a/automake.in +++ b/automake.in @@ -1495,28 +1495,13 @@ sub output_yacc_build_rule { my ($yacc_suffix, $use_ylwrap) = @_; - my $c_suffix = $yacc_suffix; - $c_suffix =~ tr/y/c/; - push (@suffixes, $yacc_suffix, $c_suffix); + (my $c_suffix = $yacc_suffix) =~ tr/y/c/; # Generate rule for c/c++. - $output_rules .= "$yacc_suffix$c_suffix:\n\t"; - - if ($use_ylwrap) - { - $output_rules .= ('$(SHELL) $(YLWRAP)' - . ' "$(YACC)" $< y.tab.c $*' . $c_suffix - . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)'); - } - else - { - $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*' - . $c_suffix . "\n" - . "\tif test -f y.tab.h; then \\\n" - . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n" - . "\telse :; fi"); - } - $output_rules .= "\n"; + $output_rules .= &file_contents ('yacc', + ('YACC_SUFFIX' => $yacc_suffix, + 'C_SUFFIX' => $c_suffix, + 'YLWRAP' => $use_ylwrap)); } sub output_lex_build_rule @@ -5589,6 +5574,19 @@ sub conditionals_true_when (@@) return 1; } + +sub condition_negate ($) +{ + my ($cond) = @_; + + $cond =~ s/TRUE$/TRUEO/; + $cond =~ s/FALSE$/TRUE/; + $cond =~ s/TRUEO$/FALSE/; + + return $cond; +} + + # Check for an ambiguous conditional. This is called when a variable # or target is being defined conditionally. If we already know about # a definition that is true under the same conditions, then we have an @@ -5967,10 +5965,8 @@ sub variable_conditions_permutations my $comp = shift (@comps); return &variable_conditions_permutations (@comps) if $comp eq ''; - my $neg = $comp; - $neg =~ s/TRUE$/TRUEO/; - $neg =~ s/FALSE$/TRUE/; - $neg =~ s/TRUEO$/FALSE/; + my $neg = condition_negate ($comp); + my @ret; foreach my $sub (&variable_conditions_permutations (@comps)) { @@ -6459,14 +6455,14 @@ sub read_am_file { &am_line_error ($., "else without if"); } - elsif ($conditional_stack[$#conditional_stack] =~ /^(.*_)?FALSE$/) + elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE$/) { &am_line_error ($., "else after else"); } else { $conditional_stack[$#conditional_stack] - =~ s/TRUE$/FALSE/; + = condition_negate ($conditional_stack[$#conditional_stack]); $cond = conditional_string (@conditional_stack); } } @@ -6827,14 +6823,15 @@ sub file_contents_internal ($%) { &am_error ("else without if"); } - elsif ($cond_stack[$#cond_stack] =~ /^(.*_)?FALSE$/) + elsif ($cond_stack[$#cond_stack] =~ /_FALSE$/) { &am_error ("else after else"); } else { - $cond_stack[$#cond_stack] =~ s/TRUE$/FALSE/; - $cond = conditional_string (@cond_stack); + $cond_stack[$#cond_stack] = + condition_negate ($cond_stack[$#cond_stack]); + $cond = conditional_string (@cond_stack); } } elsif (/$ENDIF_PATTERN/o) diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index 8da2d3da..ba257991 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -16,7 +16,7 @@ distdir.am footer.am header-vars.am header.am install.am java.am \ kr-extra.am library.am libs.am libtool.am lisp.am ltlib.am \ ltlibrary.am mans-vars.am mans.am multilib.am program.am progs.am \ python.am remake-hdr.am remake.am scripts.am subdirs.am tags.am \ -texi-vers.am texibuild.am texinfos.am +texi-vers.am texibuild.am texinfos.am yacc.am dist_pkgdata_DATA = COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \ $(amfiles) diff --git a/lib/am/yacc.am b/lib/am/yacc.am new file mode 100644 index 00000000..5800ca2d --- /dev/null +++ b/lib/am/yacc.am @@ -0,0 +1,32 @@ +## automake - create Makefile.in from Makefile.am +## Copyright 1998, 1999, 2001 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 +## the Free Software Foundation; either version 2, or (at your option) +## any later version. + +## This program 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 this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. + +## Generate rule for c/c++. +%YACC_SUFFIX%%C_SUFFIX%: +if %?YLWRAP% + $(SHELL) $(YLWRAP) $(YACC) $< y.tab.c $*%C_SUFFIX% y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS) +else + $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*%C_SUFFIX% + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then \ + rm -f y.tab.h; \ + else \ + mv y.tab.h $*.h; \ + fi; \ + fi +endif %?YLWRAP% diff --git a/yacc.am b/yacc.am new file mode 100644 index 00000000..5800ca2d --- /dev/null +++ b/yacc.am @@ -0,0 +1,32 @@ +## automake - create Makefile.in from Makefile.am +## Copyright 1998, 1999, 2001 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 +## the Free Software Foundation; either version 2, or (at your option) +## any later version. + +## This program 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 this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. + +## Generate rule for c/c++. +%YACC_SUFFIX%%C_SUFFIX%: +if %?YLWRAP% + $(SHELL) $(YLWRAP) $(YACC) $< y.tab.c $*%C_SUFFIX% y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS) +else + $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*%C_SUFFIX% + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then \ + rm -f y.tab.h; \ + else \ + mv y.tab.h $*.h; \ + fi; \ + fi +endif %?YLWRAP%