From 9c12e9b5a6ed5b004232f540443ca40f7731c70e Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sat, 11 Aug 2012 01:41:26 +0200 Subject: [PATCH] [ng] dist: refactor handling of dist formats a little * automake.in (handle_dist): Define list of default dist formats in the new internal make variable 'am.dist.formats'. Related adjustments. (preprocess_file): Drop the following now-unused transforms: XZ, LZMA, LZIP, BZIP2, COMPRESS, GZIP, SHAR, ZIP. * lib/am/distdir.am: Drop any use of the removed transforms, throughout. (DIST_TARGETS): Redefine in function of '$(am.dist.formats)'. (.PHONY): Update in function of '$(am.dist.formats)'. (am.dist.ext.gzip, am.dist.ext.bzip2, am.dist.ext.xz, am.dist.ext.lzip, am.dist.ext.tarZ, am.dist.ext.shar, am.dist.ext.zip): New internal variables. (DIST_ARCHIVES): Redefine in function of them and of '$(am.dist.formats)'. Signed-off-by: Stefano Lattarini --- automake.in | 34 ++++++++++++++++------------------ lib/am/distdir.am | 36 ++++++++++++++---------------------- 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/automake.in b/automake.in index c1806ab8f..71aa25efa 100644 --- a/automake.in +++ b/automake.in @@ -3210,16 +3210,22 @@ sub handle_dist () # The remaining definitions are only required when a dist target is used. return if option 'no-dist'; - # At least one of the archive formats must be enabled. + # The list of tarball formats we must support. + my @archive_formats; if ($relative_dir eq '.') { - my $archive_defined = option 'no-dist-gzip' ? 0 : 1; - $archive_defined ||= - grep { option "dist-$_" } qw(shar zip tarZ bzip2 lzip lzma xz); - error (option 'no-dist-gzip', - "no-dist-gzip specified but no dist-* specified,\n" - . "at least one archive format must be enabled") - unless $archive_defined; + push @archive_formats, 'gzip' unless option 'no-dist-gzip'; + foreach my $fmt (qw/shar zip tarZ bzip2 lzip xz/) + { + push @archive_formats, $fmt if option "dist-$fmt"; + } + # At least one of the archive formats must be enabled. + if (@archive_formats == 0) + { + error (option 'no-dist-gzip', + "no-dist-gzip specified but no dist-* specified,\n" + . "at least one archive format must be enabled"); + } } # Look for common files that should be included in distribution. @@ -3281,6 +3287,7 @@ sub handle_dist () rule ('distcheck-hook') ? 'yes' : ''); define_variable ('am.dist.handle-gettext', INTERNAL, $seen_gettext && !$seen_gettext_external ? 'yes' : ''); + define_variable ('am.dist.formats', INTERNAL, @archive_formats); # If the target 'dist-hook' exists, make sure it is run. This # allows users to do random weird things to the distribution @@ -5666,16 +5673,7 @@ sub preprocess_file ($%) # Complete %transform with global options. # Note that %transform goes last, so it overrides global options. - %transform = ( 'XZ' => !! option 'dist-xz', - 'LZMA' => !! option 'dist-lzma', - 'LZIP' => !! option 'dist-lzip', - 'BZIP2' => !! option 'dist-bzip2', - 'COMPRESS' => !! option 'dist-tarZ', - 'GZIP' => ! option 'no-dist-gzip', - 'SHAR' => !! option 'dist-shar', - 'ZIP' => !! option 'dist-zip', - - 'INSTALL-INFO' => ! option 'no-installinfo', + %transform = ( 'INSTALL-INFO' => ! option 'no-installinfo', 'INSTALL-MAN' => ! option 'no-installman', 'HAVE-MANS' => !! var ('MANS'), 'CK-NEWS' => !! option 'check-news', diff --git a/lib/am/distdir.am b/lib/am/distdir.am index 75954129f..35d9a71b5 100644 --- a/lib/am/distdir.am +++ b/lib/am/distdir.am @@ -313,58 +313,50 @@ endif %?TOPDIR_P% if %?TOPDIR_P% -?GZIP?DIST_ARCHIVES += $(distdir).tar.gz +am.dist.ext.gzip = tar.gz +am.dist.ext.bzip2 = tar.bz2 +am.dist.ext.xz = tar.xz +am.dist.ext.lzip = tar.lz +am.dist.ext.tarZ = tar.Z +am.dist.ext.shar = shar.gz +am.dist.ext.zip = zip + +DIST_TARGETS = $(foreach x,$(am.dist.formats),dist-$x) +DIST_ARCHIVES = $(foreach x,$(am.dist.formats),$(distdir).$(am.dist.ext.$x)) +# FIXME: hack to prevent the dumb Automake parser from mangling the list of +# .PHONY targets. +$(am.chars.empty).PHONY: $(foreach x,$(am.dist.formats),dist-$x) + GZIP_ENV = --best -.PHONY: dist-gzip dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) -?BZIP2?DIST_ARCHIVES += $(distdir).tar.bz2 -.PHONY: dist-bzip2 dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) -?LZIP?DIST_ARCHIVES += $(distdir).tar.lz -.PHONY: dist-lzip dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) -?XZ?DIST_ARCHIVES += $(distdir).tar.xz -.PHONY: dist-xz dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) -?COMPRESS?DIST_ARCHIVES += $(distdir).tar.Z -.PHONY: dist-tarZ dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) -?SHAR?DIST_ARCHIVES += $(distdir).shar.gz -.PHONY: dist-shar dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) -?ZIP?DIST_ARCHIVES += $(distdir).zip -.PHONY: dist-zip dist-zip: distdir rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) -?LZIP?DIST_TARGETS += dist-lzip -?XZ?DIST_TARGETS += dist-xz -?SHAR?DIST_TARGETS += dist-shar -?BZIP2?DIST_TARGETS += dist-bzip2 -?GZIP?DIST_TARGETS += dist-gzip -?ZIP?DIST_TARGETS += dist-zip -?COMPRESS?DIST_TARGETS += dist-tarZ - endif %?TOPDIR_P% -- 2.47.2