From: Stefano Lattarini Date: Thu, 3 May 2012 16:56:57 +0000 (+0200) Subject: [ng] dist: strip duplicates from dist files at make (not automake) runtime X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42b0536dcc6327b3f09f711671847ac7db879d8c;p=thirdparty%2Fautomake.git [ng] dist: strip duplicates from dist files at make (not automake) runtime We can do this thanks to the new make macros '$(am__uniq)' introduced in the recent commit 'v1.12-145-g112d08a'. * automake.in (handle_dist): Don't "uniq"ify the contents of DIST_COMMON here, but instead ... * lib/am/distdir.am: ... "uniq"ify the contents of DISTFILES here. * t/dist-repeated.sh: Remove sanity check checking for a once expected invariant that is not there anymore now. * t/distcom4.sh, t/distcom5.sh: Adjust. Signed-off-by: Stefano Lattarini --- diff --git a/automake.in b/automake.in index 7af3fecf6..fa30d6dd7 100644 --- a/automake.in +++ b/automake.in @@ -3774,15 +3774,8 @@ sub handle_dist () } } - # Files to distributed. Don't use ->value_as_list_recursive - # as it recursively expands '$(dist_pkgdata_DATA)' etc. - my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value); - @dist_common = uniq @dist_common; - variable_delete 'DIST_COMMON'; - define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common); - - # Now that we've processed DIST_COMMON, disallow further attempts - # to set it. + # We don't expected further attempts to modify DIST_COMMON after + # this point, so disallow it, for extra safety. $handle_dist_run = 1; # Scan EXTRA_DIST to see if we need to distribute anything from a diff --git a/lib/am/distdir.am b/lib/am/distdir.am index 90ba095dc..7fe451a83 100644 --- a/lib/am/distdir.am +++ b/lib/am/distdir.am @@ -14,7 +14,8 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +DISTFILES = $(call am__uniq, \ + $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)) ## Try to avoid repeated slashed in the $(DISTFILES) entries, to make the ## filtering in the 'am__dist_files_1' definition below more reliable. diff --git a/t/dist-repeated.sh b/t/dist-repeated.sh index 6651e72c9..14ea6acb7 100755 --- a/t/dist-repeated.sh +++ b/t/dist-repeated.sh @@ -29,13 +29,6 @@ bar_SOURCES = foo.c python_PYTHON = bar.py EXTRA_DIST = foo.c bar.py -.PHONY: sanity-check -sanity-check: - for f in $(DISTFILES); do echo " $$f "; done > dist.txt - cat dist.txt - test `grep ' foo\.c ' dist.txt | wc -l` -eq 3 - test `grep ' bar\.py ' dist.txt | wc -l` -eq 2 - # So that we don't have to require a C compiler. AUTOMAKE_OPTIONS = no-dependencies CC = false @@ -94,7 +87,6 @@ $AUTOCONF $AUTOMAKE ./configure -$MAKE sanity-check || fatal_ "expected invariants not verified" $MAKE distdir test -f cp-wrapper-has-seen-foo-c && test -f cp-wrapper-has-seen-bar-py \ || fatal_ "our cp wrapper hasn't run correctly" diff --git a/t/distcom4.sh b/t/distcom4.sh index 6f9d8716c..18f8b3385 100755 --- a/t/distcom4.sh +++ b/t/distcom4.sh @@ -43,8 +43,12 @@ mkdir tests : > README : > tests/wrapper.in cat > Makefile.am << 'END' -.PHONY: test -test: distdir +.PHONY: test1 test 2 +test1: + for x in $(DISTFILES); do echo $$x; done | grep 'tests/' > lst + cat lst # For debugging. + test `wc -l dc.txt - -cat dc.txt # For debugging. - -test 1 = `grep tests dc.txt | wc -l` -grep configure dc.txt +$MAKE test1 test2 : diff --git a/t/distcom5.sh b/t/distcom5.sh index adfbe52d1..b8290dde9 100755 --- a/t/distcom5.sh +++ b/t/distcom5.sh @@ -21,21 +21,6 @@ . ./defs || Exit 1 -extract_distcommon () -{ - sed -n -e '/^DIST_COMMON =.*\\$/ { - :loop - p - n - t clear - :clear - s/\\$/\\/ - t loop - p - n - }' -e '/^DIST_COMMON =/ p' ${1+"$@"} -} - cat >> configure.ac << 'END' AC_CONFIG_FILES([tests/autoconf:tests/wrapper.in], [chmod +x tests/autoconf]) @@ -57,28 +42,30 @@ END mkdir tests : > tests/wrapper.in -: > tests/Makefile.am + cat > Makefile.am << 'END' SUBDIRS = tests .PHONY: test test: distdir test -f $(distdir)/tests/wrapper.in +check-local: test + for x in $(DISTFILES); do echo $$x; done \ + | grep tests && exit 1; : +END + +cat > tests/Makefile.am <<'END' +check-local: + for x in $(DISTFILES); do echo $$x; done | grep wrapper.in > lst + cat lst # For debugging. + test `wc -l top.txt -extract_distcommon tests/Makefile.in > inner.txt - -# Might be useful for debugging. -cat top.txt -cat inner.txt - -test 0 = `grep tests top.txt | wc -l` -test 1 = `grep wrapper inner.txt | wc -l` +$MAKE check +# Sanity check. +test -f tests/lst :