Many changes from Franc,ois
authorTom Tromey <tromey@redhat.com>
Tue, 2 Jan 1996 02:20:18 +0000 (02:20 +0000)
committerTom Tromey <tromey@redhat.com>
Tue, 2 Jan 1996 02:20:18 +0000 (02:20 +0000)
54 files changed:
ChangeLog
Makefile.am
Makefile.in
automake.in
clean-kr.am
clean.am
compile-kr.am
compile-vars.am
compile.am
data.am
depend.am
dist-subd-top.am
dist-subd.am
dist-vars.am
dist.am
footer.am
header-vars.am
kr-vars.am
lib/am/Makefile.am
lib/am/clean.am
lib/am/compile.am
lib/am/data.am
lib/am/depend.am
lib/am/footer.am
lib/am/header-vars.am
lib/am/library.am
lib/am/mans-vars.am
lib/am/program.am
lib/am/remake-hdr.am
lib/am/scripts.am
lib/am/subdirs.am
lib/am/tags.am
lib/am/texinfos.am
libraries-clean.am
libraries-vars.am
libraries.am
library.am
mans-vars.am
program.am
programs-clean.am
programs.am
remake-hdr.am
remake-subd.am
remake.am
scripts-clean.am
scripts.am
subdirs.am
tags-clean.am
tags-subd.am
tags.am
texi-clean.am
texi-version.am
texinfos-vars.am
texinfos.am

index ffb2b3a..87e4389 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,46 @@
 Mon Jan  1 15:43:25 1996  Tom Tromey  <tromey@cambric.colorado.edu>
 
+       * automake.in (handle_merge_targets): 'check' target depends on
+       'all'.
+       (file_contents): Don't be so verbose.
+       (read_am_file): Ditto.
+       (read_am_file): Must use substr to check for trailing \.
+       (am_install_var): Use push_phony_cleaners.
+       (file_contents): Set $was_rule when assuming a rule is seen.
+       (read_am_file): Ditto.
+       (do_one_clean_target): Removed spurious newline.
+
+       Some changes from François Pinard:
+       * Removed trailing whitespace from all '.am' files.
+       * tags-subd.am (ID): Use &&, not ;.
+       (TAGS): Ditto.
+       * automake.in (parse_arguments): Removed useless message.
+       (parse_arguments): Don't explicitly referenced STDERR.
+       (require_argument): Ditto.
+       (am_error): Ditto.
+       (set_strictness): Ditto.
+       (file_contents): Ditto.
+       (read_am_file): Ditto.
+       (generate_makefile): Style tweaks.
+       (handle_programs): Ditto.
+       (handle_libraries): Ditto.
+       (handle_texinfo): Ditto.
+       (handle_man_pages): Ditto.
+       (handle_tags): Ditto.
+       (handle_dist): Ditto.
+       (handle_subdirs): Ditto.
+       (handle_configure): Ditto.
+       (handle_footer): Don't put newline before footer.am contents.
+       (handle_merge_targets): Style tweaks.
+       (do_one_clean_target): Ditto.
+       (dirname): Ditto.
+       (am_variable): Ditto.
+       Defined some new constants.
+       (generate_makefile): Don't call generate_header.
+       (generate_header): Removed.
+       (file_contents): Rewrote.
+       (read_am_file): Rewrote.
+
        * automake.in (generate_makefile): Handle phony target.
        (do_one_clean_target): Pretty-print dependencies.
        (handle_installdirs): Pretty-print rule.
index 3ede9f9..f818a14 100644 (file)
@@ -49,7 +49,7 @@ automake: automake.in
 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
 cvs-dist: maintainer-check
-       if sed 1q NEWS | grep -e "$(VERSION)"; then :; else \
+       @if sed 1q NEWS | grep -e "$(VERSION)"; then :; else \
          echo "NEWS not updated; not releasing" 1>&2; \
          exit 1;                               \
        fi
index 3cf67fa..8e6e774 100644 (file)
@@ -1,20 +1,5 @@
 # Makefile.in generated automatically by automake 0.26 from Makefile.am
-# Copyright (C) 1994, 1995 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.
 
 SHELL = /bin/sh
 
@@ -72,13 +57,11 @@ DIST_SUBDIRS = samples/cpio/*Makefile.am
 # The following requires a fixed version of the Emacs 19.30 etags.
 ETAGS_ARGS = automake.in --lang=none \
  --regex='/^@node[ \t]+\([^,]+\)/\1/' automake.texi
-
-
 SCRIPTS= $(bin_SCRIPTS)
 
+
 MAKEINFO = makeinfo
 TEXI2DVI = texi2dvi
-
 INFOS = automake.info*
 INFO_DEPS = automake.info
 DVIS = automake.dvi
@@ -90,14 +73,15 @@ DIST_COMMON = mkinstalldirs configure Makefile.in stamp-vti configure.in \
 ChangeLog THANKS README version.texi mdate-sh TODO INSTALL Makefile.am \
 texinfo.tex NEWS aclocal.m4 install-sh
 
+
 PACKAGE = @PACKAGE@
 VERSION = @VERSION@
 
 DISTFILES = $(SOURCES) $(HEADERS) $(TEXINFOS) $(INFOS) $(MANS) \
        $(DIST_OTHER) $(DIST_COMMON) $(DATA)
-
 default: all
 
+
 mostlyclean-binSCRIPTS:
 
 clean-binSCRIPTS:
@@ -143,9 +127,9 @@ distclean-vti:
 
 maintainer-clean-vti:
        rm -f stamp-vti version.texi
-
 automake.info: automake.texi version.texi
 
+
 .texi.info:
        $(MAKEINFO) -I$(srcdir) $<
 
@@ -208,12 +192,12 @@ $(srcdir)/configure: configure.in $(ACLOCAL)
 id: ID
 
 ID:
-       here=`pwd`; cd $(srcdir) && mkid -f $$here/ID $(SOURCES) $(HEADERS)
+       here=`pwd` && cd $(srcdir) && mkid -f $$here/ID $(SOURCES) $(HEADERS)
 
 tags: TAGS
 
 TAGS:
-       here=`pwd`; cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
+       here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
 
 mostlyclean-tags:
 
@@ -242,14 +226,13 @@ dist: $(DISTFILES)
        chmod -R a+r $(distdir)
        tar -chozf $(distdir).tar.gz $(distdir)
        rm -rf $(distdir)
-
 all: info $(SCRIPTS) $(DATA)
 
 info: $(INFO_DEPS)
 
 dvi: $(DVIS)
 
-check:
+check: all
 
 installcheck:
 
@@ -265,6 +248,7 @@ uninstall: uninstall-binSCRIPTS uninstall-info uninstall-pkgdataDATA
 installdirs:
        $(top_srcdir)/mkinstalldirs  $(bindir) $(infodir) $(pkgdatadir)
 
+
 mostlyclean-generic:
        test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
@@ -277,37 +261,34 @@ distclean-generic:
 
 maintainer-clean-generic:
        test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-
 mostlyclean:  mostlyclean-binSCRIPTS mostlyclean-vti mostlyclean-info \
 mostlyclean-tags mostlyclean-generic
 
-
 clean:  clean-binSCRIPTS clean-vti clean-info clean-tags clean-generic \
 mostlyclean 
 
-
 distclean:  distclean-binSCRIPTS distclean-vti distclean-info \
 distclean-tags distclean-generic clean 
-
        rm -f config.status
 
 maintainer-clean:  maintainer-clean-binSCRIPTS maintainer-clean-vti \
 maintainer-clean-info maintainer-clean-tags maintainer-clean-generic \
 distclean 
-
        @echo "This command is intended for maintainers to use;"
        @echo "it deletes files that may require special tools to rebuild."
        rm -f config.status
 
-.PHONY: default binSCRIPTS uninstall-binSCRIPTS mostlyclean-vti \
-distclean-vti clean-vti maintainer-clean-vti install-info \
-uninstall-info mostlyclean-info distclean-info clean-info \
+.PHONY: default mostlyclean-binSCRIPTS distclean-binSCRIPTS \
+clean-binSCRIPTS maintainer-clean-binSCRIPTS uninstall-binSCRIPTS \
+mostlyclean-vti distclean-vti clean-vti maintainer-clean-vti \
+install-info uninstall-info mostlyclean-info distclean-info clean-info \
 maintainer-clean-info uninstall-pkgdataDATA tags id mostlyclean-tags \
 distclean-tags clean-tags maintainer-clean-tags dist all info dvi check \
 installcheck install-exec install-data install uninstall installdirs \
 mostlyclean-generic distclean-generic clean-generic \
 maintainer-clean-generic clean mostlyclean distclean maintainer-clean
 
+
 # Some simple checks:
 # * syntax check with perl4 and perl5.
 # * make sure the scripts don't use 'true'
@@ -333,17 +314,15 @@ automake: automake.in
 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
 cvs-dist: maintainer-check
-       if sed 1q NEWS | grep -e "$(VERSION)"; then :; else \
+       @if sed 1q NEWS | grep -e "$(VERSION)"; then :; else \
          echo "NEWS not updated; not releasing" 1>&2; \
          exit 1;                               \
        fi
        cvs tag `echo "Release-$(VERSION)" | sed 's/\./-/g'`
        $(MAKE) dist
-
 .SUFFIXES:
 .SUFFIXES: .texi .info .dvi
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
-
index 3672510..0ebcb1b 100755 (executable)
@@ -32,7 +32,13 @@ $VERSION = "@VERSION@";
 $prefix = "@prefix@";
 $am_dir = "@datadir@/@PACKAGE@";
 
-\f
+# String constants.
+$IGNORE_PATTERN = "^##([^#].*)?\$";
+$WHITE_PATTERN = "^[ \t]*\$";
+$COMMENT_PATTERN = "^#";
+$RULE_PATTERN = "^([a-zA-Z_.][-.a-zA-Z0-9_.]*) *:";
+$MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)\$";
+
 
 # Constants to define the "strictness" level.
 $NORMAL = 0;
@@ -150,8 +156,7 @@ sub parse_arguments
        }
        elsif ($arglist[0] =~ /^-/)
        {
-           print STDERR "automake: unrecognized option -- \`$arglist[0]'\n";
-           exit 1;
+           die "automake: unrecognized option -- \`$arglist[0]'\n";
        }
        else
        {
@@ -172,15 +177,8 @@ sub parse_arguments
            push (@make_list, $_);
        }
 
-       if ($#make_list >= 0)
-       {
-           print "automake: using ", join (' ', @make_list), "\n";
-       }
-       else
-       {
-           print STDERR "automake: no \"Makefile.am\" found or specified\n";
-           exit 1;
-       }
+       die "automake: no \"Makefile.am\" found or specified\n"
+           if $#make_list < 0;
     }
 
     return (@make_list);
@@ -190,11 +188,8 @@ sub parse_arguments
 sub require_argument
 {
     local ($arg, @arglist) = @_;
-    if ($#arglist >= 0)
-    {
-       print STDERR "automake: no argument given for option \`$arg'\n";
-       exit 1;
-    }
+    die "automake: no argument given for option \`$arg'\n"
+       if $#arglist >= 0;
 }
 
 ################################################################
@@ -211,13 +206,8 @@ sub generate_makefile
     # FIXME with new 'dist' target, don't need Makefile.in.  Probably
     # should remove it here.
     &push_dist_common ('Makefile.in', 'Makefile.am');
-    push (@sources, '$(SOURCES)') if (defined $contents{'SOURCES'});
-    push (@objects, '$(OBJECTS)') if (defined $contents{'OBJECTS'});
-
-    # Generate header before reading .am file.  The header must come
-    # before anything else, and read_am_file copies code into the
-    # output.
-    &generate_header;
+    push (@sources, '$(SOURCES)') if defined $contents{'SOURCES'};
+    push (@objects, '$(OBJECTS)') if defined $contents{'OBJECTS'};
 
     # This is always the default target.  This gives us freedom to do
     # things in whatever order is convenient.
@@ -273,18 +263,6 @@ sub generate_makefile
 
 ################################################################
 
-# Generate header of Makefile.in.
-sub generate_header
-{
-    $output_vars =
-       ($output_vars
-        . "# Makefile.in generated automatically by automake "
-        . $VERSION
-        . " from Makefile.am\n");
-
-    $output_vars .= &file_contents ('header-vars');
-}
-
 # Return object extension.  Just once, put some code into the output.
 sub get_object_extension
 {
@@ -388,7 +366,7 @@ sub handle_programs
                                         'programs', 'PROGRAMS',
                                         'bin', 'sbin', 'libexec', 'noinst');
     # FIXME error if PROGRAMS defined but no blah_PROGRAMS defined.
-    return if ($#proglist < 0);
+    return if $#proglist < 0;
 
     local ($obj) = &get_object_extension;
     local ($one_file, $munge);
@@ -415,7 +393,7 @@ sub handle_libraries
                                        'libraries', 'LIBRARIES',
                                        'lib', 'pkglib', 'noinst');
     # FIXME error if LIBRARIES defined but no blah_LIBRARIES defined.
-    return if ($#liblist < 0);
+    return if $#liblist < 0;
 
     # Generate _LIBFILES variables.  Too bad we can't do this in
     # am_install_var.
@@ -475,7 +453,7 @@ sub handle_scripts
 sub handle_texinfo
 {
     local ($texis) = &am_variable ('TEXINFOS');
-    return if (!$texis);
+    return if ! $texis;
 
     local (@texis) = split (/\s+/, $texis);
     if ($#texis > 0)
@@ -552,7 +530,7 @@ sub handle_texinfo
 # Handle any man pages.
 sub handle_man_pages
 {
-    return if (! defined $contents{'MANS'});
+    return if ! defined $contents{'MANS'};
 
     # We generate the manpage install code by hand to avoid the use of
     # basename in the generated Makefile.
@@ -560,7 +538,8 @@ sub handle_man_pages
     local (%sections, %inames, %secmap, %fullsecmap);
     foreach (@mans)
     {
-       m/^(.*)\.([0-9])([a-z]*)$/;
+       # FIXME: statement without effect:
+       /^(.*)\.([0-9])([a-z]*)$/;
        $sections{$2} = 1;
        $inames{$1} = $_;
        $secmap{$1} = $2;
@@ -624,12 +603,12 @@ sub handle_tags
     local ($tagging) = 0;
 
     push (@phony, 'tags');
-    if (defined ($contents{'SUBDIRS'}))
+    if (defined $contents{'SUBDIRS'})
     {
        $output_rules .= &file_contents ('tags');
        $tagging = 1;
     }
-    elsif ($dir_holds_sources || defined ($contents{'ETAGS_ARGS'}))
+    elsif ($dir_holds_sources || defined $contents{'ETAGS_ARGS'})
     {
        $output_rules .= &file_contents ('tags-subd');
        push (@phony, 'id');
@@ -677,7 +656,7 @@ sub handle_dist
     }
     else
     {
-       $output_rules .= &file_contents (defined ($contents{'SUBDIRS'})
+       $output_rules .= &file_contents (defined $contents{'SUBDIRS'}
                                         ? 'dist-subd-top'
                                         : 'dist');
     }
@@ -725,7 +704,7 @@ sub handle_dependencies
 # Handle subdirectories.
 sub handle_subdirs
 {
-    return if (! defined ($contents{'SUBDIRS'}));
+    return if ! defined $contents{'SUBDIRS'};
 
     $output_rules .= &file_contents ('subdirs');
 
@@ -788,8 +767,8 @@ sub handle_configure
        &require_file ($NORMAL, 'mkinstalldirs');
     }
 
-    if (defined ($contents{'CONFIG_HEADER'})
-       && $contents{'CONFIG_HEADER'} !~ m,/,)
+    if (defined $contents{'CONFIG_HEADER'}
+       && $contents{'CONFIG_HEADER'} !~ /\//)
     {
        # Header defined and in this directory.
        if (-f 'acconfig.h')
@@ -848,7 +827,7 @@ sub handle_footer
     {
        $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
     }
-    $output_trailer .= "\n" . &file_contents ('footer');
+    $output_trailer .= &file_contents ('footer');
 }
 
 # Deal with installdirs target.
@@ -876,6 +855,7 @@ sub handle_merge_targets
     &do_one_merge_target ('all', @all);
     &do_one_merge_target ('info', @info);
     &do_one_merge_target ('dvi', @dvi);
+    push (@check, 'all');
     &do_one_merge_target ('check', @check);
     &do_one_merge_target ('installcheck', @installcheck);
 
@@ -944,7 +924,7 @@ sub handle_merge_targets
        $output_rules .= ("install-exec: "
                          . join (' ', @install_exec)
                          . "\n\n");
-       push (@install, 'install-exec') if (!$recursive_install);
+       push (@install, 'install-exec') if !$recursive_install;
        push (@phony, 'install-exec');
     }
     if ($#install_data >= 0)
@@ -952,7 +932,7 @@ sub handle_merge_targets
        $output_rules .= ("install-data: "
                          . join (' ', @install_data)
                          . "\n\n");
-       push (@install, 'install-data') if (!$recursive_install);
+       push (@install, 'install-data') if !$recursive_install;
        push (@phony, 'install-data');
     }
 
@@ -1023,10 +1003,7 @@ sub do_one_clean_target
     # clean<-mostlyclean derivation).  In this case the target is
     # implicitly known to be 'clean'.
     local ($flag) = $target;
-    if (!$flag)
-    {
-       $target = 'clean';
-    }
+    $target = 'clean' if ! $flag;
 
     grep (($_ = $name . 'clean-' . $_) && 0, @deps);
     if ($flag)
@@ -1037,7 +1014,6 @@ sub do_one_clean_target
        }
     }
     &pretty_print_rule ($name . $target . ": ", '', @deps);
-    $output_rules .= "\n";
 
     # FIXME shouldn't we really print these messages before running
     # the dependencies?
@@ -1139,30 +1115,73 @@ sub read_am_file
 {
     local ($amfile) = @_;
 
-    if (! open (AMFILE, $amfile))
-    {
-       print STDERR "automake: couldn't open $amfile: $!\n";
-       exit 1;
-    }
+    local ($header_vars) = &file_contents ('header-vars');
+
+    open (AM_FILE, $amfile) || die "automake: couldn't open $amfile: $!\n";
+
+    $output_vars .= ("# Makefile.in generated automatically by automake "
+                    . $VERSION . " from Makefile.am\n");
 
     local ($saw_bk) = 0;
     local ($was_rule) = 0;
+    local ($spacing) = '';
+    local ($comment) = '';
     local ($last_var_name) = '';
-    local ($saved_comments) = '';
 
-    while (<AMFILE>)
+    while (<AM_FILE>)
     {
-       chop;
+       if (/$IGNORE_PATTERN/o)
+       {
+           # Merely delete comments beginning with two hashes.
+       }
+       elsif (/$WHITE_PATTERN/o)
+       {
+           # Stick a single white line before the incoming macro or rule.
+           $spacing = "\n";
+       }
+       elsif (/$COMMENT_PATTERN/o)
+       {
+           # Stick comments before the incoming macro or rule.
+           $comment .= $spacing . $_;
+           $spacing = '';
+       }
+       else
+       {
+           last;
+       }
+    }
+
+    $output_vars .= $comment . "\n" . $header_vars;
+    $comment = '';
+    $spacing = "\n";
 
-       if ($saw_bk)
+    while ($_)
+    {
+       if (/$IGNORE_PATTERN/o)
+       {
+           # Merely delete comments beginning with two hashes.
+       }
+       elsif (/$WHITE_PATTERN/o)
+       {
+           # Stick a single white line before the incoming macro or rule.
+           $spacing = "\n";
+       }
+       elsif (/$COMMENT_PATTERN/o)
+       {
+           # Stick comments before the incoming macro or rule.
+           $comment .= $spacing . $_;
+           $spacing = '';
+       }
+       elsif ($saw_bk)
        {
            if ($was_rule)
            {
-               $output_trailer .= $_ . "\n";
+               $output_trailer .= $_;
+               $saw_bk = /\\$/;
            }
            else
            {
-               $output_vars .= $_ . "\n";
+               $output_vars .= $_;
                if (substr ($_, -1) eq "\\")
                {
                    $contents{$last_var_name} .= substr ($_, 0,
@@ -1172,33 +1191,25 @@ sub read_am_file
                {
                    $contents{$last_var_name} .= $_;
                }
+               $saw_bk = /\\$/;
            }
        }
-       elsif (/^\#/)
-       {
-           # Got a comment.  We save comments until we get a
-           # non-comment, and then we add the last comments.
-           $saved_comments .= $_ . "\n";
-       }
-       elsif ($_ eq '@kr@')
-       {
-           # Special case: this means we want automatic
-           # de-ANSI-fication.  FIXME think of a better way.
-           $contents{'@kr@'} = 1;
-       }
-       elsif (m/^ *([a-zA-Z_.][-.a-zA-Z0-9_.]*) *:/)
+       elsif (/$RULE_PATTERN/o)
        {
+           # warn "** Saw rule .$1.\n";
            # Found a rule.
            $was_rule = 1;
            # Value here doesn't matter; for targets we only note
            # existence.
            $contents{$1} = 1;
-           $output_trailer .= $saved_comments . $_ . "\n";
-           $saved_comments = '';
+           $output_trailer .= $comment . $spacing . $_;
+           $comment = $spacing = '';
+           $saw_bk = /\\$/;
        }
-       elsif (m/^ *([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)$/)
+       elsif (/$MACRO_PATTERN/o)
        {
-           # Found a variable reference.
+           # warn "** Saw macro .$1.\n";
+           # Found a macro definition.
            $was_rule = 0;
            $last_var_name = $1;
            if (substr ($2, -1) eq "\\")
@@ -1209,39 +1220,30 @@ sub read_am_file
            {
                $contents{$1} = $2;
            }
-           $output_vars .= $saved_comments . $_ . "\n";
-           $saved_comments = '';
+           $output_vars .= $comment . $spacing . $_;
+           $comment = $spacing = '';
+           $saw_bk = /\\$/;
        }
-       elsif (m/^$/)
+       elsif ($_ eq "\@kr\@\n")
        {
-           # Special rule: if looking at a blank line, append it to
-           # whatever we saw last.
-           if ($was_rule)
-           {
-               $output_trailer .= $saved_comments . "\n";
-           }
-           else
-           {
-               $output_vars .= $saved_comments . "\n";
-           }
-           $saved_comments = '';
+           # Special case: this means we want automatic
+           # de-ANSI-fication.  FIXME think of a better way.
+           $contents{'@kr@'} = 1;
        }
        else
        {
            # This isn't an error; it is probably a continued rule.
            # In fact, this is what we assume.
-           $output_trailer .= $_ . "\n";
+           $was_rule = 1;
+           $output_trailer .= $comment . $spacing . $_;
+           $comment = $spacing = '';
+           $saw_bk = /\\$/;
        }
 
-       $saw_bk = (substr ($_, -1) eq "\\");
+       $_ = <AM_FILE>;
     }
 
-    # Include trailing comments with variables for now.
-    $output_vars .= $saved_comments;
-
-    # Include some space after user code.
-    $output_vars .= "\n";
-    $output_trailer .= "\n";
+    $output_trailer .= $comment;
 }
 
 ################################################################
@@ -1368,26 +1370,87 @@ sub initialize_per_input
 
 ################################################################
 
-# Return contents of a file from $am_dir.
+# Return contents of a file from $am_dir, automatically skipping
+# macros or rules which are already known.
 sub file_contents
 {
     local ($basename) = @_;
     local ($file) = $am_dir . '/' . $basename . '.am';
 
-    if (! open (FC_FILE, $file))
-    {
-       print STDERR "automake: installation error: cannot open \"$file\"\n";
-       exit 1;
-    }
+    open (FC_FILE, $file)
+       || die "automake: installation error: cannot open \"$file\"\n";
+
+    local ($was_rule) = 0;
+    local ($result_vars) = '';
+    local ($result_rules) = '';
+    local ($comment) = '';
+    local ($spacing) = "\n";
+    local ($skipping) = 0;
 
-    # Lines starting with "##" are comments for developer use only.
-    local ($result) = '';
     while (<FC_FILE>)
     {
-       $result .= $_ unless ( m/^##/);
+       if (/$IGNORE_PATTERN/o)
+       {
+           # Merely delete comments beginning with two hashes.
+       }
+       elsif (/$WHITE_PATTERN/o)
+       {
+           # Stick a single white line before the incoming macro or rule.
+           $spacing = "\n";
+       }
+       elsif (/$COMMENT_PATTERN/o)
+       {
+           # Stick comments before the incoming macro or rule.
+           $comment .= $spacing . $_;
+           $spacing = '';
+       }
+       elsif ($saw_bk)
+       {
+           if ($was_rule)
+           {
+               $result_rules .= $_ if ! $skipping;
+           }
+           else
+           {
+               $result_vars .= $_ if ! $skipping;
+           }
+           $saw_bk = /\\$/;
+       }
+       elsif (/$RULE_PATTERN/o)
+       {
+           # warn "** Found rule .$1.\n";
+           # Found a rule.
+           $was_rule = 1;
+           $skipping = defined $contents{$1};
+           warn "** Skip $skipping\n" if $skipping;
+           $result_rules .= $comment . $spacing . $_ if ! $skipping;
+           $comment = $spacing = '';
+           $saw_bk = /\\$/;
+       }
+       elsif (/$MACRO_PATTERN/o)
+       {
+           # warn "** Found macro .$1.\n";
+           # Found a variable reference.
+           $was_rule = 0;
+           $skipping = defined $contents{$1};
+           warn "** Skip $skipping\n" if $skipping;
+           $result_vars .= $comment . $spacing . $_ if ! $skipping;
+           $comment = $spacing = '';
+           $saw_bk = /\\$/;
+       }
+       else
+       {
+           # This isn't an error; it is probably a continued rule.
+           # In fact, this is what we assume.
+           $was_rule = 1;
+           $result_rules .= $comment . $spacing . $_ if ! $skipping;
+           $comment = $spacing = '';
+           $saw_bk = /\\$/;
+       }
     }
+
     close (FC_FILE);
-    return $result;
+    return $result_vars . $result_rules . $comment;
 }
 
 # Return contents of some Makefile.am variable.  Allow for AM_ style
@@ -1396,7 +1459,7 @@ sub am_variable
 {
     local ($varname) = @_;
 
-    return (defined ($contents{'AM_' . $varname})
+    return (defined $contents{'AM_' . $varname}
            ? $contents{'AM_' . $varname}
            : $contents{$varname});
 }
@@ -1455,7 +1518,7 @@ sub am_install_var
                ($munge = $clean_templ) =~ s/\@DIR\@/$_/g;
                $output_rules .= $munge;
                push (@clean, $_ . $primary);
-               push (@phony, $_ . $primary);
+               &push_phony_cleaners ($_ . $primary);
            }
 
            push (@used, '$(' . $one_name . ')');
@@ -1586,8 +1649,7 @@ sub set_strictness
     }
     else
     {
-       print STDERR "automake: level \`$name' not recognized\n";
-       exit 1;
+       die "automake: level \`$name' not recognized\n";
     }
 }
 
@@ -1601,11 +1663,7 @@ sub dirname
     local ($sub);
 
     ($sub = $file) =~ s,/+[^/]+,,g;
-    if ($sub eq $file)
-    {
-       $sub = '.';
-    }
-
+    $sub = '.' if $sub eq $file;
     return $sub;
 }
 
@@ -1621,7 +1679,7 @@ sub mkdir
 # Print an error message and set exit status.
 sub am_error
 {
-    print STDERR "automake: ${am_file}.am: ", join (' ', @_), "\n";
+    warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
     $exit_status = 1;
 }
 
index 5938cb5..c6fdbdc 100644 (file)
@@ -7,4 +7,3 @@ distclean-kr:
        rm -f ansi2knr
 
 maintainer-clean-kr:
-
index 927272b..8561896 100644 (file)
--- a/clean.am
+++ b/clean.am
@@ -12,4 +12,3 @@ distclean-generic:
 
 maintainer-clean-generic:
        test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-
index f014f54..8c2ef45 100644 (file)
@@ -17,4 +17,3 @@ ansi2knr: ansi2knr.o
 
 $(OBJECTS): $(ANSI2KNR)
 ansi2knr.o: $(CONFIG_HEADER)
-
index 41ea771..d44f6c8 100644 (file)
@@ -10,4 +10,3 @@ LIBS = @LIBS@
 
 COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
 LINK = $(CC) $(LDFLAGS) -o $@
-
index 36371bc..2570db7 100644 (file)
@@ -2,6 +2,7 @@
        $(COMPILE) $<
 
 mostlyclean-compile:
+## Don't remove 'core.*' because some distributions have eg "core.c".
        rm -f *.o core
 
 clean-compile:
@@ -10,4 +11,3 @@ distclean-compile:
        rm -f *.tab.c
 
 maintainer-clean-compile:
-
diff --git a/data.am b/data.am
index f07b81e..64270a5 100644 (file)
--- a/data.am
+++ b/data.am
@@ -8,4 +8,3 @@ uninstall-@DIR@DATA:
        for p in $(@DIR@_DATA); do              \
          rm -f $(@DIR@dir)/$$p;                \
        done
-
index 25b74a8..2ebc5d6 100644 (file)
--- a/depend.am
+++ b/depend.am
@@ -22,8 +22,7 @@ $(DEP_FILES): $(srcdir)/.deps/.P
 
 $(srcdir)/.deps/%.P: $(srcdir)/%.c
        @echo "mkdeps $< > $@"
-       @$(MKDEP) $< > $@-tmp
+       @$(MKDEP) $< | sed 's,$(srcdir)/,,g' > $@-tmp
        @mv $@-tmp $@
 
 # End of maintainer-only section
-
index 34d2a7e..85b135b 100644 (file)
@@ -35,4 +35,3 @@ dist: $(DISTFILES)
        chmod -R a+r $(distdir)
        tar -chozf $(distdir).tar.gz $(distdir)
        rm -rf $(distdir)
-
index 826cc53..1ea36ae 100644 (file)
@@ -6,4 +6,3 @@ dist: $(DISTFILES)
            || ln $(srcdir)/$$file $(distdir)/$$file \
            || cp -p $(srcdir)/$$file $(distdir)/$$file; \
        done
-
index 80c8a94..71165cd 100644 (file)
@@ -3,4 +3,3 @@ VERSION = @VERSION@
 
 DISTFILES = $(SOURCES) $(HEADERS) $(TEXINFOS) $(INFOS) $(MANS) \
        $(DIST_OTHER) $(DIST_COMMON) $(DATA)
-
diff --git a/dist.am b/dist.am
index aaf0762..391b264 100644 (file)
--- a/dist.am
+++ b/dist.am
@@ -17,4 +17,3 @@ dist: $(DISTFILES)
        chmod -R a+r $(distdir)
        tar -chozf $(distdir).tar.gz $(distdir)
        rm -rf $(distdir)
-
index ddf006f..739cc53 100644 (file)
--- a/footer.am
+++ b/footer.am
@@ -1,4 +1,3 @@
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
-
index df4831d..1cfd360 100644 (file)
@@ -1,20 +1,3 @@
-# Copyright (C) 1994, 1995 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.
-
 SHELL = /bin/sh
 
 srcdir = @srcdir@
@@ -46,4 +29,3 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 transform = @program_transform_name@
-
index a5f77e4..1dd941d 100644 (file)
@@ -1,3 +1,2 @@
 ANSI2KNR = @ANSI2KNR@
 kr = @U@
-
index 3ede9f9..f818a14 100644 (file)
@@ -49,7 +49,7 @@ automake: automake.in
 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
 cvs-dist: maintainer-check
-       if sed 1q NEWS | grep -e "$(VERSION)"; then :; else \
+       @if sed 1q NEWS | grep -e "$(VERSION)"; then :; else \
          echo "NEWS not updated; not releasing" 1>&2; \
          exit 1;                               \
        fi
index 927272b..8561896 100644 (file)
@@ -12,4 +12,3 @@ distclean-generic:
 
 maintainer-clean-generic:
        test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-
index 36371bc..2570db7 100644 (file)
@@ -2,6 +2,7 @@
        $(COMPILE) $<
 
 mostlyclean-compile:
+## Don't remove 'core.*' because some distributions have eg "core.c".
        rm -f *.o core
 
 clean-compile:
@@ -10,4 +11,3 @@ distclean-compile:
        rm -f *.tab.c
 
 maintainer-clean-compile:
-
index f07b81e..64270a5 100644 (file)
@@ -8,4 +8,3 @@ uninstall-@DIR@DATA:
        for p in $(@DIR@_DATA); do              \
          rm -f $(@DIR@dir)/$$p;                \
        done
-
index 25b74a8..2ebc5d6 100644 (file)
@@ -22,8 +22,7 @@ $(DEP_FILES): $(srcdir)/.deps/.P
 
 $(srcdir)/.deps/%.P: $(srcdir)/%.c
        @echo "mkdeps $< > $@"
-       @$(MKDEP) $< > $@-tmp
+       @$(MKDEP) $< | sed 's,$(srcdir)/,,g' > $@-tmp
        @mv $@-tmp $@
 
 # End of maintainer-only section
-
index ddf006f..739cc53 100644 (file)
@@ -1,4 +1,3 @@
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
-
index df4831d..1cfd360 100644 (file)
@@ -1,20 +1,3 @@
-# Copyright (C) 1994, 1995 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.
-
 SHELL = /bin/sh
 
 srcdir = @srcdir@
@@ -46,4 +29,3 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 transform = @program_transform_name@
-
index f45e632..e8e7550 100644 (file)
@@ -2,4 +2,3 @@ lib@LIBRARY@.a: $(@LIBRARY@_OBJECTS) $(@LIBRARY@_LIBADD)
        rm -f lib@LIBRARY@.a
        $(AR) cru lib@LIBRARY@.a $(@LIBRARY@_OBJECTS) $(@LIBRARY@_LIBADD)
        $(RANLIB) lib@LIBRARY@.a
-
index d0f9723..2c44703 100644 (file)
@@ -1,2 +1 @@
 NROFF = nroff
-
index da98793..f37fd91 100644 (file)
@@ -1,3 +1,2 @@
 @PROGRAM@: $(@PROGRAM@_OBJECTS)
        $(LINK) $(@PROGRAM@_OBJECTS) $(@PROGRAM@_LDADD) $(LIBS)
-
index a7475d2..5c1cd8e 100644 (file)
@@ -5,4 +5,3 @@ $(srcdir)/$(CONFIG_HEADER).in: stamp-h.in
 $(srcdir)/stamp-h.in: configure.in $(ACLOCAL) $(ACCONFIG) $(CONFIG_TOP) $(CONFIG_BOT)
        cd $(srcdir) && autoheader
        echo timestamp > $(srcdir)/stamp-h.in
-
index 0ea6734..382ff82 100644 (file)
@@ -10,4 +10,3 @@ uninstall-@DIR@SCRIPTS:
        for p in $(@DIR@_SCRIPTS); do           \
          rm -f $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
        done
-
index c835340..6d6a666 100644 (file)
@@ -20,4 +20,3 @@ maintainer-clean-recursive:
 ## recursive rule.
           || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
        done && test -z "$$fail"
-
index 0b718ed..1ef7e44 100644 (file)
@@ -13,4 +13,3 @@ TAGS:
 ## Make sure we have something to run etags on.
        test -z "$(ETAGS_ARGS)$(CONFIG_HEADER)$(SOURCES)$(HEADERS)$$tags" \
          || etags $(ETAGS_ARGS) $$tags $(CONFIG_HEADER) $(SOURCES) $(HEADERS)
-
index aa4d9e1..7fb2d5a 100644 (file)
@@ -32,4 +32,3 @@ uninstall-info:
        cd $(srcdir) && for file in *.info*; do \
          rm -f $(infodir)/$$file; \
        done
-
index b232e69..07687cf 100644 (file)
@@ -6,4 +6,3 @@ clean-@DIR@LIBRARIES:
 distclean-@DIR@LIBRARIES:
 
 maintainer-clean-@DIR@LIBRARIES:
-
index 42d214b..ee51c07 100644 (file)
@@ -1,3 +1,2 @@
 AR = ar
 RANLIB = @RANLIB@
-
index 3f88d42..f52a460 100644 (file)
@@ -12,4 +12,3 @@ uninstall-@DIR@LIBRARIES:
        for p in $(@DIR@_LIBFILES); do          \
          rm -f $(@DIR@dir)/$$p;                \
        done
-
index f45e632..e8e7550 100644 (file)
@@ -2,4 +2,3 @@ lib@LIBRARY@.a: $(@LIBRARY@_OBJECTS) $(@LIBRARY@_LIBADD)
        rm -f lib@LIBRARY@.a
        $(AR) cru lib@LIBRARY@.a $(@LIBRARY@_OBJECTS) $(@LIBRARY@_LIBADD)
        $(RANLIB) lib@LIBRARY@.a
-
index d0f9723..2c44703 100644 (file)
@@ -1,2 +1 @@
 NROFF = nroff
-
index da98793..f37fd91 100644 (file)
@@ -1,3 +1,2 @@
 @PROGRAM@: $(@PROGRAM@_OBJECTS)
        $(LINK) $(@PROGRAM@_OBJECTS) $(@PROGRAM@_LDADD) $(LIBS)
-
index 84f2f64..d0e57f6 100644 (file)
@@ -6,4 +6,3 @@ clean-@DIR@PROGRAMS:
 distclean-@DIR@PROGRAMS:
 
 maintainer-clean-@DIR@PROGRAMS:
-
index dd8e62d..91055b4 100644 (file)
@@ -10,4 +10,3 @@ uninstall-@DIR@PROGRAMS:
        for p in $(@DIR@_PROGRAMS); do \
          rm -f $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
        done
-
index a7475d2..5c1cd8e 100644 (file)
@@ -5,4 +5,3 @@ $(srcdir)/$(CONFIG_HEADER).in: stamp-h.in
 $(srcdir)/stamp-h.in: configure.in $(ACLOCAL) $(ACCONFIG) $(CONFIG_TOP) $(CONFIG_BOT)
        cd $(srcdir) && autoheader
        echo timestamp > $(srcdir)/stamp-h.in
-
index 59188ac..4c4739f 100644 (file)
@@ -3,4 +3,3 @@ $(srcdir)/Makefile.in: Makefile.am
 
 Makefile: ../config.status Makefile.in
        cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
-
index bb9b9ed..15b5c23 100644 (file)
--- a/remake.am
+++ b/remake.am
@@ -9,4 +9,3 @@ config.status: configure
        ./config.status --recheck
 $(srcdir)/configure: configure.in $(ACLOCAL)
        cd $(srcdir) && autoconf
-
index 3ee5d19..3abceee 100644 (file)
@@ -6,4 +6,3 @@ clean-@DIR@SCRIPTS:
 distclean-@DIR@SCRIPTS:
 
 maintainer-clean-@DIR@SCRIPTS:
-
index 0ea6734..382ff82 100644 (file)
@@ -10,4 +10,3 @@ uninstall-@DIR@SCRIPTS:
        for p in $(@DIR@_SCRIPTS); do           \
          rm -f $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
        done
-
index c835340..6d6a666 100644 (file)
@@ -20,4 +20,3 @@ maintainer-clean-recursive:
 ## recursive rule.
           || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
        done && test -z "$$fail"
-
index 6f32baf..f97233d 100644 (file)
@@ -6,4 +6,3 @@ distclean-tags:
        rm -f TAGS ID
 
 maintainer-clean-tags:
-
index c8d2120..69db3b7 100644 (file)
@@ -1,10 +1,9 @@
 id: ID
 
 ID:
-       here=`pwd`; cd $(srcdir) && mkid -f $$here/ID $(SOURCES) $(HEADERS)
+       here=`pwd` && cd $(srcdir) && mkid -f $$here/ID $(SOURCES) $(HEADERS)
 
 tags: TAGS
 
 TAGS:
-       here=`pwd`; cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
-
+       here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
diff --git a/tags.am b/tags.am
index 0b718ed..1ef7e44 100644 (file)
--- a/tags.am
+++ b/tags.am
@@ -13,4 +13,3 @@ TAGS:
 ## Make sure we have something to run etags on.
        test -z "$(ETAGS_ARGS)$(CONFIG_HEADER)$(SOURCES)$(HEADERS)$$tags" \
          || etags $(ETAGS_ARGS) $$tags $(CONFIG_HEADER) $(SOURCES) $(HEADERS)
-
index 4da7494..a691e37 100644 (file)
@@ -12,4 +12,3 @@ distclean-info:
 
 maintainer-clean-info:
        rm -f $(INFOS)
-
index 62b5d44..b9cc8dc 100644 (file)
@@ -23,4 +23,3 @@ distclean-vti:
 
 maintainer-clean-vti:
        rm -f stamp-vti version.texi
-
index de1b817..8f6dade 100644 (file)
@@ -1,3 +1,2 @@
 MAKEINFO = makeinfo
 TEXI2DVI = texi2dvi
-
index aa4d9e1..7fb2d5a 100644 (file)
@@ -32,4 +32,3 @@ uninstall-info:
        cd $(srcdir) && for file in *.info*; do \
          rm -f $(infodir)/$$file; \
        done
-