This patch seems wrong: it merges where splitting would be more
welcome. But the difference between handle_dist and
handle_dist_worker was fairly artificial and became annoying in the
process of cleaning the dist targets.
I also merged dist.am into distdir.am because (i) I was extremely
annoyed by the fact the file name was a lie (it's actually
distcheck.am), and (ii), although I agree the long list of ?TOPDIR? is
gross, I do plan to implement some multilline if/else/fi support for
Automake files, which will make this much simpler, and more pleasant.
Index: ChangeLog
from Akim Demaille <[EMAIL PROTECTED]>
* dist.am: Remove, merge into...
* distdir.am: here. Use the neat sed snippet for banners.
BTW, distcheck is phony.
* automake.in (&handle_dist_worker): Remove, merge into...
(&handle_dist): this.
(&file_contents): Strip leading new lines.
Be sure to end comments with new lines.
Index: automake.in
--- automake.in Sat, 17 Feb 2001 19:25:21 +0100 akim (am/f/39_automake.i 1.44 755)
+++ automake.in Sat, 17 Feb 2001 19:58:18 +0100 akim (am/f/39_automake.i 1.44 755)
@@ -2589,97 +2589,6 @@ sub handle_dist_worker
{
my ($makefile) = @_;
- # Initialization; only at top level.
- my $xform = &transform_cond ('TOPDIR' => ($relative_dir eq '.'));
-
- # Scan EXTRA_DIST to see if we need to distribute anything from a
- # subdir. If so, add it to the list. I didn't want to do this
- # originally, but there were so many requests that I finally
- # relented.
- if (&variable_defined ('EXTRA_DIST'))
- {
- # FIXME: This should be fixed to work with conditionals. That
- # will require only making the entries in @dist_dirs under the
- # appropriate condition. This is meaningful if the nature of
- # the distribution should depend upon the configure options
- # used.
- foreach (&variable_value_as_list ('EXTRA_DIST', ''))
- {
- next if /^\@.*\@$/;
- next unless s,/+[^/]+$,,;
- $dist_dirs{$_} = 1
- unless $_ eq '.';
- }
- }
-
- # We have to check DIST_COMMON for extra directories in case the
- # user put a source used in AC_OUTPUT into a subdir.
- foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
- {
- next if /^\@.*\@$/;
- next unless s,/+[^/]+$,,;
- $dist_dirs{$_} = 1
- unless $_ eq '.';
- }
-
- if (scalar keys %dist_dirs)
- {
- # Prepend $(distdir) to each directory given. Doing it via a
- # hash lets us ensure that each directory is used only once.
- grep ($dist_dirs{'$(distdir)/' . $_} = 1, keys %dist_dirs);
- $xform .= &transform ('DISTDIRS', join (' ', sort keys %dist_dirs));
- }
- else
- {
- $xform .= 's/.*\@DISTDIRS\@.*//g;';
- }
-
- # If we have SUBDIRS, create all dist subdirectories and do
- # recursive build.
- if (&variable_defined ('SUBDIRS'))
- {
- # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
- # to all possible directories, and use it. If DIST_SUBDIRS is
- # defined, just use it.
- local ($dist_subdir_name);
- if (&variable_conditions ('SUBDIRS')
- || &variable_defined ('DIST_SUBDIRS'))
- {
- $dist_subdir_name = 'DIST_SUBDIRS';
- if (! &variable_defined ('DIST_SUBDIRS'))
- {
- &define_pretty_variable
- ('DIST_SUBDIRS', '',
- uniq (&variable_value_as_list ('SUBDIRS', 'all')));
- }
- }
- else
- {
- $dist_subdir_name = 'SUBDIRS';
- # We always define this because that is what `distclean'
- # wants.
- &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
- }
-
- my $top_distdir = ($relative_dir eq '.') ? 'distdir' : 'top_distdir';
- $xform .= &transform ('DIST_SUBDIR_NAME' => $dist_subdir_name,
- 'TOP_DISTDIR' => $top_distdir);
- }
-
- # If the target `dist-hook' exists, make sure it is run. This
- # allows users to do random weird things to the distribution
- # before it is packaged up.
- push (@dist_targets, 'dist-hook')
- if &target_defined ('dist-hook');
-
- $output_rules .=
- &file_contents ('distdir',
- $xform
- . &transform ('DIST-TARGETS' => join " ", @dist_targets)
- . &transform_cond ('DIST-TARGETS' =>
- scalar @dist_targets,
- 'SUBDIRS' =>
- &variable_defined ('SUBDIRS')));
}
# Handle 'dist' target.
@@ -2786,20 +2695,100 @@ sub handle_dist
}
$output_rules .= "\n";
- # Generate 'dist' target, and maybe other dist targets.
- if ($relative_dir eq '.')
+ # Scan EXTRA_DIST to see if we need to distribute anything from a
+ # subdir. If so, add it to the list. I didn't want to do this
+ # originally, but there were so many requests that I finally
+ # relented.
+ if (&variable_defined ('EXTRA_DIST'))
+ {
+ # FIXME: This should be fixed to work with conditionals. That
+ # will require only making the entries in @dist_dirs under the
+ # appropriate condition. This is meaningful if the nature of
+ # the distribution should depend upon the configure options
+ # used.
+ foreach (&variable_value_as_list ('EXTRA_DIST', ''))
+ {
+ next if /^\@.*\@$/;
+ next unless s,/+[^/]+$,,;
+ $dist_dirs{$_} = 1
+ unless $_ eq '.';
+ }
+ }
+
+ # We have to check DIST_COMMON for extra directories in case the
+ # user put a source used in AC_OUTPUT into a subdir.
+ foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
+ {
+ next if /^\@.*\@$/;
+ next unless s,/+[^/]+$,,;
+ $dist_dirs{$_} = 1
+ unless $_ eq '.';
+ }
+
+ # Rule to check whether a distribution is viable.
+ my $xform =
+ &transform_cond ('TOPDIR' => ($relative_dir eq '.'),
+ 'DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
+ 'GETTEXT' => $seen_gettext);
+
+ if (scalar keys %dist_dirs)
+ {
+ # Prepend $(distdir) to each directory given. Doing it via a
+ # hash lets us ensure that each directory is used only once.
+ grep ($dist_dirs{'$(distdir)/' . $_} = 1, keys %dist_dirs);
+ $xform .= &transform ('DISTDIRS', join (' ', sort keys %dist_dirs));
+ }
+ else
+ {
+ $xform .= 's/.*\@DISTDIRS\@.*//g;';
+ }
+
+ # If we have SUBDIRS, create all dist subdirectories and do
+ # recursive build.
+ if (&variable_defined ('SUBDIRS'))
{
- # Rule to check whether a distribution is viable.
- my ($xform) =
- &transform_cond ('DISTHOOK' => &target_defined ('distcheck-hook'),
- 'GETTEXT' => $seen_gettext);
+ # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
+ # to all possible directories, and use it. If DIST_SUBDIRS is
+ # defined, just use it.
+ local ($dist_subdir_name);
+ if (&variable_conditions ('SUBDIRS')
+ || &variable_defined ('DIST_SUBDIRS'))
+ {
+ $dist_subdir_name = 'DIST_SUBDIRS';
+ if (! &variable_defined ('DIST_SUBDIRS'))
+ {
+ &define_pretty_variable
+ ('DIST_SUBDIRS', '',
+ uniq (&variable_value_as_list ('SUBDIRS', 'all')));
+ }
+ }
+ else
+ {
+ $dist_subdir_name = 'SUBDIRS';
+ # We always define this because that is what `distclean'
+ # wants.
+ &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
+ }
- # Arg, this file should have been named `distcheck'.
- $output_rules .= &file_contents ('dist', $xform);
+ my $top_distdir = ($relative_dir eq '.') ? 'distdir' : 'top_distdir';
+ $xform .= &transform ('DIST_SUBDIR_NAME' => $dist_subdir_name,
+ 'TOP_DISTDIR' => $top_distdir);
}
- # Generate distdir target.
- &handle_dist_worker ($makefile);
+ # If the target `dist-hook' exists, make sure it is run. This
+ # allows users to do random weird things to the distribution
+ # before it is packaged up.
+ push (@dist_targets, 'dist-hook')
+ if &target_defined ('dist-hook');
+
+ $output_rules .=
+ &file_contents ('distdir',
+ $xform
+ . &transform ('DIST-TARGETS' => join " ", @dist_targets)
+ . &transform_cond ('DIST-TARGETS' =>
+ scalar @dist_targets,
+ 'SUBDIRS' =>
+ &variable_defined ('SUBDIRS')));
}
@@ -6894,11 +6883,17 @@ sub file_contents
# perl goes loopy if you try to
#
# $result_rules =~ /^($TARGET_PATTERN *)+: ($TARGET_PATTERN *)+\n\n/sm
- local ($result_vars) = '';
- local ($result_rules) = '';
- local ($comment) = '';
+ my $result_vars = '';
+ my $result_rules = '';
+ my $comment = '';
foreach (split (/(?<!\\)\n(?![\t#])/, $contents))
{
+ # Strip leading new lines. This can happen for comments:
+ # the pattern above allows `\n\n# comment' to yield
+ # `\n# comment'.
+ s/^\n+//;
+
+ # Sanity checks.
&am_file_error ("$basename.am",
"blank line following trailing backslash:\n$_")
if /\\$/;
@@ -6914,7 +6909,7 @@ sub file_contents
elsif (/$COMMENT_PATTERN/mso)
{
# Stick comments before the incoming macro or rule.
- $comment = $_;
+ $comment = "$_\n";
}
elsif (/$RULE_PATTERN/mso)
{
@@ -6949,7 +6944,7 @@ sub file_contents
{
# Some hair to avoid spurious trailing blank
# when there are no dependencies.
- $result_rules .= "$comment$separator";
+ $result_rules .= "$separator$comment";
$result_rules .= "$targets:";
$result_rules .= " $dependencies"
if $dependencies;
@@ -6967,7 +6962,7 @@ sub file_contents
}
elsif (/$MACRO_PATTERN/mso)
{
- $result_vars .= "$comment$separator$_\n"
+ $result_vars .= "$separator$comment$_\n"
unless defined $contents{$1};
$comment = $separator = '';
&prog_error (".am macro \`$1' with trailing backslash at $file:$.")
@@ -6978,7 +6973,7 @@ sub file_contents
{
# This isn't an error; it is probably some tokens which
# configure is supposed to replace, such as `@SET-MAKE@'.
- $result_rules .= "$comment$separator$_\n";
+ $result_rules .= "$separator$comment$_\n";
$comment = $separator = '';
}
}
Index: Makefile.am
--- Makefile.am Sat, 17 Feb 2001 17:56:59 +0100 akim (am/f/46_Makefile.a 1.6 644)
+++ Makefile.am Sat, 17 Feb 2001 19:30:36 +0100 akim (am/f/46_Makefile.a 1.6 644)
@@ -12,7 +12,7 @@
amfiles = check.am clean-hdr.am clean-kr.am clean.am comp-vars.am \
compile.am data-clean.am data.am dejagnu.am depend.am depend2.am \
-dist.am distdir.am dist-vars.am footer.am header-vars.am header.am \
+distdir.am dist-vars.am footer.am header-vars.am header.am \
java-clean.am java.am kr-extra.am library.am libs-clean.am libs.am \
libtool.am lisp-clean.am lisp.am ltlib-clean.am ltlib.am ltlibrary.am \
mans-vars.am mans.am multilib.am program.am progs-clean.am progs.am \
Index: distdir.am
--- distdir.am Sat, 17 Feb 2001 19:25:21 +0100 akim (am/h/17_distdir.am 1.7 644)
+++ distdir.am Sat, 17 Feb 2001 19:58:38 +0100 akim (am/h/17_distdir.am 1.7 644)
@@ -154,3 +154,49 @@
?TOPDIR??ZIP? -rm -f $(distdir).zip
?TOPDIR??ZIP? zip -rq $(distdir).zip $(distdir)
?TOPDIR??ZIP? -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+
+
+
+## ------------------------- ##
+## Checking a distribution. ##
+## ------------------------- ##
+
+
+?TOPDIR?# This target untars the dist file and tries a VPATH configuration. Then
+?TOPDIR?# it guarantees that the distribution is self-contained by making another
+?TOPDIR?# tarfile.
+?TOPDIR?.PHONY: distcheck
+?TOPDIR?distcheck: dist
+## Make sure we can remove distdir before trying to remove it.
+?TOPDIR? -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
+?TOPDIR? GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
+## Make the new source tree read-only. Distributions ought to work in
+## this case. However, make the top-level directory writable so we
+## can make our new subdirs.
+?TOPDIR? chmod -R a-w $(distdir); chmod a+w $(distdir)
+?TOPDIR? mkdir $(distdir)/=build
+?TOPDIR? mkdir $(distdir)/=inst
+## Undo the write access.
+?TOPDIR? chmod a-w $(distdir)
+?TOPDIR? dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
+?TOPDIR??DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
+?TOPDIR? && cd $(distdir)/=build \
+?TOPDIR? && ../configure --srcdir=.. --prefix=$$dc_install_base \
+?TOPDIR??GETTEXT? --with-included-gettext \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) dvi \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) check \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) install \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+## We use -le 1 because the `dir' file might still exist after uninstall.
+?TOPDIR? && test `find $$dc_install_base -type f -print | wc -l` -le 1 \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) dist \
+?TOPDIR? && $(MAKE) $(AM_MAKEFLAGS) distclean \
+## Make sure to remove the dist file we created in the test build
+## directory.
+?TOPDIR? && rm -f $(distdir).tar.gz \
+?TOPDIR? && test `find . -type f -print | wc -l` -eq 0
+?TOPDIR? -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
+?TOPDIR? @echo "$(distdir).tar.gz is ready for distribution" | \
+?TOPDIR? sed 'h;s/./=/g;p;x;p;x'
Index: Makefile.in
--- Makefile.in Sat, 17 Feb 2001 19:25:21 +0100 akim (am/h/16_Makefile.i 1.15 644)
+++ Makefile.in Sat, 17 Feb 2001 20:00:26 +0100 akim (am/h/16_Makefile.i 1.15 644)
@@ -81,7 +81,7 @@
amfiles = check.am clean-hdr.am clean-kr.am clean.am comp-vars.am \
compile.am data-clean.am data.am dejagnu.am depend.am depend2.am \
-dist.am distdir.am dist-vars.am footer.am header-vars.am header.am \
+distdir.am dist-vars.am footer.am header-vars.am header.am \
java-clean.am java.am kr-extra.am library.am libs-clean.am libs.am \
libtool.am lisp-clean.am lisp.am ltlib-clean.am ltlib.am ltlibrary.am \
mans-vars.am mans.am multilib.am program.am progs-clean.am progs.am \
@@ -450,37 +450,6 @@
top_distdir = $(distdir)
-# This target untars the dist file and tries a VPATH configuration. Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
- -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
- chmod -R a-w $(distdir); chmod a+w $(distdir)
- mkdir $(distdir)/=build
- mkdir $(distdir)/=inst
- chmod a-w $(distdir)
- dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
- && cd $(distdir)/=build \
- && ../configure --srcdir=.. --prefix=$$dc_install_base \
- && $(MAKE) $(AM_MAKEFLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) dvi \
- && $(MAKE) $(AM_MAKEFLAGS) check \
- && $(MAKE) $(AM_MAKEFLAGS) install \
- && $(MAKE) $(AM_MAKEFLAGS) installcheck \
- && $(MAKE) $(AM_MAKEFLAGS) uninstall \
- && test `find $$dc_install_base -type f -print | wc -l` -le 1 \
- && $(MAKE) $(AM_MAKEFLAGS) dist \
- && $(MAKE) $(AM_MAKEFLAGS) distclean \
- && rm -f $(distdir).tar.gz \
- && test `find . -type f -print | wc -l` -eq 0
- -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
- @banner="$(distdir).tar.gz is ready for distribution"; \
- dashes=`echo "$$banner" | sed s/./=/g`; \
- echo "$$dashes"; \
- echo "$$banner"; \
- echo "$$dashes"
-
GZIP_ENV = --best
distdir: $(DISTFILES)
@@ -523,6 +492,33 @@
dist: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
+ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
+ chmod -R a-w $(distdir); chmod a+w $(distdir)
+ mkdir $(distdir)/=build
+ mkdir $(distdir)/=inst
+ chmod a-w $(distdir)
+ dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
+ && cd $(distdir)/=build \
+ && ../configure --srcdir=.. --prefix=$$dc_install_base \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && test `find $$dc_install_base -type f -print | wc -l` -le 1 \
+ && $(MAKE) $(AM_MAKEFLAGS) dist \
+ && $(MAKE) $(AM_MAKEFLAGS) distclean \
+ && rm -f $(distdir).tar.gz \
+ && test `find . -type f -print | wc -l` -eq 0
+ -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
+ @echo "$(distdir).tar.gz is ready for distribution" | \
+ sed 'h;s/./=/g;p;x;p;x'
info-am: $(INFO_DEPS)
info: info-recursive
dvi-am: $(DVIS)
@@ -590,7 +586,7 @@
mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti
.PHONY: all all-am all-recursive check check-am check-recursive clean \
- clean-generic clean-recursive dist dist-all distclean \
+ clean-generic clean-recursive dist dist-all distcheck distclean \
distclean-generic distclean-recursive distclean-tags distdir \
dvi dvi-am dvi-recursive info info-am info-recursive install \
install-am install-binSCRIPTS install-data install-data-am \
Index: dist.am
--- dist.am Fri, 09 Feb 2001 04:37:00 +0100 akim (am/g/42_dist.am 1.4 644)
+++ dist.am Sat, 17 Feb 2001 20:01:12 +0100 akim ()
@@ -1,58 +0,0 @@
-## automake - create Makefile.in from Makefile.am
-## Copyright 1994, 1995, 1996, 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.
-
-# This target untars the dist file and tries a VPATH configuration. Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
-## Make sure we can remove distdir before trying to remove it.
- -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
-## Make the new source tree read-only. Distributions ought to work in
-## this case. However, make the top-level directory writable so we
-## can make our new subdirs.
- chmod -R a-w $(distdir); chmod a+w $(distdir)
- mkdir $(distdir)/=build
- mkdir $(distdir)/=inst
-## Undo the write access.
- chmod a-w $(distdir)
- dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
-?DISTHOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
- && cd $(distdir)/=build \
- && ../configure --srcdir=.. --prefix=$$dc_install_base \
-?GETTEXT? --with-included-gettext \
- && $(MAKE) $(AM_MAKEFLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) dvi \
- && $(MAKE) $(AM_MAKEFLAGS) check \
- && $(MAKE) $(AM_MAKEFLAGS) install \
- && $(MAKE) $(AM_MAKEFLAGS) installcheck \
- && $(MAKE) $(AM_MAKEFLAGS) uninstall \
-## We use -le 1 because the `dir' file might still exist after uninstall.
- && test `find $$dc_install_base -type f -print | wc -l` -le 1 \
- && $(MAKE) $(AM_MAKEFLAGS) dist \
- && $(MAKE) $(AM_MAKEFLAGS) distclean \
-## Make sure to remove the dist file we created in the test build
-## directory.
- && rm -f $(distdir).tar.gz \
- && test `find . -type f -print | wc -l` -eq 0
- -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
- @banner="$(distdir).tar.gz is ready for distribution"; \
- dashes=`echo "$$banner" | sed s/./=/g`; \
- echo "$$dashes"; \
- echo "$$banner"; \
- echo "$$dashes"