From 19e281405a599a29b32f9cf084e043dab3107de3 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 1 Aug 2012 11:18:35 +0200 Subject: [PATCH] general: include verbatim makefile fragments in output Makefiles Instead of copying their contents in each output Makefile. * automake.in (verbatim): Instead of copying the given Makefile fragment in the output makefile, copy it in the '.mk' subdirectory of the top-level source directory (i.e., the one automake is being run into). And return a proper "include" directive that will allow GNU make to include that fragment in the generated Makefile at make runtime. * lib/am/distdir.am: Distribute the '.mk' subdirectory of the top-level source directory, with the help of ... (am.dist.mk-files): ... this new internal variable. * .gitignore: Add the '.mk' directory. * Makefile.am (amhello_configury): Likewise. * t/all2.sh: Adjust. * t/ax/depcomp.sh: Likewise. * t/ax/tap-setup.sh: Likewise. * t/check.sh: Likewise. * t/distdir.sh: Likewise. * t/installdir.sh: Likewise. * t/noinst.sh: Likewise. * t/phony.sh: Likewise. * t/spell.sh: Likewise. * t/spell2.sh: Likewise. * t/conflnk2.sh: Adjust, and refactor a bit while we are at it. * t/serial-tests.sh: Likewise (greatly simplifying it in the process). * t/txinfo-rules-once.sh: Remove: its grepping tests has been rendered almost all obsolete, and it would be to time-consuming to try to update them. * t/dejagnu.sh: Remove as obsolete. * t/instexec.sh: Likewise. * t/clean.sh: Likewise. Signed-off-by: Stefano Lattarini --- .gitignore | 1 + Makefile.am | 3 +- automake.in | 13 +++++++-- lib/am/distdir.am | 6 +++- t/all2.sh | 3 +- t/ax/depcomp.sh | 2 +- t/ax/tap-setup.sh | 3 +- t/check2.sh | 3 -- t/clean.sh | 26 ------------------ t/conflnk2.sh | 33 +++++++++++++--------- t/dejagnu.sh | 35 ------------------------ t/distdir.sh | 3 +- t/installdir.sh | 2 -- t/instexec.sh | 27 ------------------ t/noinst.sh | 10 +++++-- t/phony.sh | 3 +- t/serial-tests.sh | 62 ++++-------------------------------------- t/spell.sh | 3 +- t/spell2.sh | 3 +- t/txinfo-rules-once.sh | 45 ------------------------------ 20 files changed, 65 insertions(+), 221 deletions(-) delete mode 100755 t/clean.sh delete mode 100755 t/dejagnu.sh delete mode 100755 t/instexec.sh delete mode 100755 t/txinfo-rules-once.sh diff --git a/.gitignore b/.gitignore index 8fee6b76f..6a6d5c2a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.mk/ /ChangeLog /aclocal.m4 /configure diff --git a/Makefile.am b/Makefile.am index eab05c363..1392f68d2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -568,7 +568,8 @@ amhello_configury = \ depcomp \ install-sh \ missing \ - src/Makefile.in + src/Makefile.in \ + .mk dist_noinst_DATA += $(amhello_sources) dist_doc_DATA = $(srcdir)/doc/amhello-1.0.tar.gz diff --git a/automake.in b/automake.in index 596b52983..40b2c4d8a 100644 --- a/automake.in +++ b/automake.in @@ -5776,16 +5776,23 @@ sub preprocess_file ($%) sub verbatim ($) { my $name = shift; - my $text .= slurp_makefile_fragment ("$libdir/am/$name.mk"); + my $dir = '.mk'; + my $file = "$dir/$name.mk"; + my $text = slurp_makefile_fragment ("$libdir/am/$name.mk"); + mkdir ($dir, 0755) if ! -d $dir; + my $fh = new Automake::XFile "> $file"; + verb "creating $file"; + print $fh $text; + my $out = "include \@top_srcdir\@/$file\n"; if (defined wantarray) { # Scalar or list context. - return $text; + return $out; } else { # Void context - $output_verbatim .= $text; + $output_verbatim .= $out; return; } } diff --git a/lib/am/distdir.am b/lib/am/distdir.am index 310b338f3..ce5ff1b7e 100644 --- a/lib/am/distdir.am +++ b/lib/am/distdir.am @@ -16,10 +16,14 @@ am.dist.common-files += %DIST-COMMON% +## Makefile fragments used internally by automake-generated Makefiles. +am.dist.mk-files = $(wildcard $(top_srcdir)/.mk/*) + ## Use 'sort', not 'am.util.uniq', for performance reasons. Luckily, we ## don't care in which order the distributed files are. am.dist.all-files = $(call am.memoize,am.dist.all-files,$(strip $(sort \ - $(am.dist.common-files) $(am.dist.sources) $(TEXINFOS) $(EXTRA_DIST)))) + $(am.dist.common-files) $(am.dist.sources) $(am.dist.mk-files) \ + $(TEXINFOS) $(EXTRA_DIST)))) ## Try to avoid repeated slashes in the entries, to make the filtering ## in the 'am.dist.files-tmp2' definition below more reliable. diff --git a/t/all2.sh b/t/all2.sh index 879cdfcee..e586b6e68 100755 --- a/t/all2.sh +++ b/t/all2.sh @@ -26,7 +26,8 @@ for target in $targets; do echo "${target}-local:" > Makefile.am $AUTOMAKE grep "${target}-local ${target}-local" Makefile.in && exit 1 - grep "${target}-am:.*${target}-local" Makefile.in + grep "${target}-am:.*${target}-local" Makefile.in \ + || grep "${target}-am:.*${target}-local" .mk/*.mk done : diff --git a/t/ax/depcomp.sh b/t/ax/depcomp.sh index 5886691b7..2a60dd951 100644 --- a/t/ax/depcomp.sh +++ b/t/ax/depcomp.sh @@ -106,7 +106,7 @@ setup_srcdir () srcdir=$1 # This is intended to be global. mkdir -p "$srcdir" \ || fatal_ "couldn't create source directory '$srcdir'" - cp -pR "$ocwd/$srctree"/* "$srcdir"/ \ + cp -pR "$ocwd/$srctree"/* "$ocwd/$srctree"/.??* "$srcdir"/ \ || fatal_ "couldn't populate source directory '$srcdir'" } diff --git a/t/ax/tap-setup.sh b/t/ax/tap-setup.sh index 952a49dfa..3ea2a8350 100644 --- a/t/ax/tap-setup.sh +++ b/t/ax/tap-setup.sh @@ -28,7 +28,8 @@ test -f ../../automake && test -f ../../defs && test -d ../../t \ test ! -f Makefile.am || mv Makefile.am Makefile.am~ \ || fatal_ "failed to save Makefile.am" -test -d ../tap-common-setup.dir && cp -fpR ../tap-common-setup.dir/* . \ +test -d ../tap-common-setup.dir \ + && cp -fpR ../tap-common-setup.dir/* ../tap-common-setup.dir/.??* . \ || fatal_ "couldn't get precomputed data files" fetch_tap_driver diff --git a/t/check2.sh b/t/check2.sh index 9a1124ad2..95f479a55 100755 --- a/t/check2.sh +++ b/t/check2.sh @@ -56,9 +56,6 @@ cat stdout grep '^PASS: subrun\.sh *$' stdout grep 'PASS.*echo\.sh' stdout && exit 1 -$EGREP '^check:.*check-recursive' Makefile.in -$EGREP '^check:.*check-am' dir/Makefile.in - # Make sure subrun.sh is still on its line as above. This means Automake # hasn't rewritten the TESTS line unnecessarily. grep '^ subrun\.sh$' Makefile.in diff --git a/t/clean.sh b/t/clean.sh deleted file mode 100755 index 80f56df03..000000000 --- a/t/clean.sh +++ /dev/null @@ -1,26 +0,0 @@ -#! /bin/sh -# Copyright (C) 1998-2012 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, see . - -# Test to make sure a clean target depends on previous one. - -. ./defs || exit 1 - -: > Makefile.am - -$ACLOCAL -$AUTOMAKE - -grep '^clean-am:.*mostlyclean-am' Makefile.in diff --git a/t/conflnk2.sh b/t/conflnk2.sh index fa0b0092b..8c0bf9bca 100755 --- a/t/conflnk2.sh +++ b/t/conflnk2.sh @@ -19,18 +19,7 @@ . ./defs || exit 1 -cat > Makefile.am << 'END' -SUBDIRS = sdir -.PHONY: test -test: distdir - test -f $(distdir)/src - test -f $(distdir)/src2 - test -f $(distdir)/sdir/src3 - test -f $(distdir)/sdir-no-make/src4 - test 2 -gt `find $(distdir)/sdir -type d | wc -l` - test 2 -gt `find $(distdir)/sdir-no-make -type d | wc -l` - test 4 -gt `find $(distdir) -type d | wc -l` -END +echo SUBDIRS = sdir > Makefile.am : > src : > src2 @@ -52,6 +41,24 @@ $ACLOCAL $AUTOMAKE $AUTOCONF ./configure -$MAKE test +$MAKE distdir + +find $distdir # For debugging. + +rm -rf $distdir/.mk + +test -f $distdir/src +test -f $distdir/src2 +test -f $distdir/sdir/src3 +test -f $distdir/sdir-no-make/src4 + +count_distributed_dirs () +{ + find $distdir${1+"/$1"} -type d | wc -l +} + +test 2 -gt $(count_distributed_dirs 'sdir') +test 2 -gt $(count_distributed_dirs 'sdir-no-make') +test 4 -gt $(count_distributed_dirs) : diff --git a/t/dejagnu.sh b/t/dejagnu.sh deleted file mode 100755 index a3bec5243..000000000 --- a/t/dejagnu.sh +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -# Copyright (C) 1996-2012 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, see . - -# Superficial test to check that dejagnu tests and automake-style -# tests can coexist. See also related deeper test 'check12.test'. - -. ./defs || exit 1 - -cat > Makefile.am << 'END' -AUTOMAKE_OPTIONS = dejagnu -TESTS = frob.test -END - -test x"$am_serial_tests" = x"yes" || : > test-driver - -$ACLOCAL -$AUTOMAKE - -grep '^check-TESTS' Makefile.in -grep '^check-DEJAGNU' Makefile.in - -: diff --git a/t/distdir.sh b/t/distdir.sh index 8edf6f074..d73e445cf 100755 --- a/t/distdir.sh +++ b/t/distdir.sh @@ -71,7 +71,8 @@ cat stdout # Make sure no './' appear in the directory names. srcdir is '..', so # this also checks that no directory is created in the source tree. -grep 'MKDIR_P.*\.' stdout && exit 1 +sed 's|/.mk/|@mk@|' stdout > stdout2 +grep 'MKDIR_P.*\.' stdout2 && exit 1 cd .. ./configure --prefix "$(pwd)" diff --git a/t/installdir.sh b/t/installdir.sh index 1cef2c152..5f74b32f9 100755 --- a/t/installdir.sh +++ b/t/installdir.sh @@ -36,8 +36,6 @@ END $ACLOCAL $AUTOMAKE -test $(grep -c installdirs-local Makefile.in) -eq 4 - cwd=$(pwd) || fatal_ "getting current working directory" $AUTOCONF diff --git a/t/instexec.sh b/t/instexec.sh deleted file mode 100755 index f394d84a8..000000000 --- a/t/instexec.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Copyright (C) 1996-2012 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, see . - -# Test for this bug: when a Makefile.am builds nothing, no -# install-exec target is generated. - -. ./defs || exit 1 - -: > Makefile.am - -$ACLOCAL -$AUTOMAKE - -grep '^install-exec:' Makefile.in diff --git a/t/noinst.sh b/t/noinst.sh index ca4440fde..de8d3d2eb 100755 --- a/t/noinst.sh +++ b/t/noinst.sh @@ -21,12 +21,18 @@ cat > Makefile.am << 'END' all-local: - exit 1 + echo ok > all-has-run END +echo AC_OUTPUT >> configure.ac + $ACLOCAL $AUTOMAKE +$AUTOCONF -grep '^install[-a-z]*:.* all' Makefile.in +./configure --prefix=$(pwd)/oops +$MAKE install +test -f all-has-run +test ! -e oops : diff --git a/t/phony.sh b/t/phony.sh index b1f3b7ec8..14d6e24d7 100755 --- a/t/phony.sh +++ b/t/phony.sh @@ -26,6 +26,7 @@ EOF $ACLOCAL $AUTOMAKE -test $($FGREP -c '.PHONY:' Makefile.in) -gt 3 +grep '^\.PHONY: foo$' Makefile.in +grep '^\.PHONY: bar$' Makefile.in : diff --git a/t/serial-tests.sh b/t/serial-tests.sh index d90de296f..2c6f9bc91 100755 --- a/t/serial-tests.sh +++ b/t/serial-tests.sh @@ -16,69 +16,19 @@ # Option 'serial-tests'. -am_create_testdir=empty . ./defs || exit 1 -hasnt_parallel_tests () -{ - $EGREP -i 'test_suite_log|test_(logs|bases)|\.log.*:' $1 && exit 1 - grep 'recheck.*:' $1 && exit 1 - grep '^check-TESTS: \$(am__cooked_tests)$' $1 -} - -has_parallel_tests () -{ - $EGREP '(^| )check-TESTS.*:' $1 - $EGREP '(^| )recheck.*:' $1 - $EGREP '^\$\(TEST_SUITE_LOG\):.* \$\(am\.test-suite\.test-logs\)( |$)' $1 - grep '%\.log %\.trs *:' $1 -} - -mkdir one two - -cat > one/configure.ac < one/Makefile.am - -cat > two/configure.ac < two/bMakefile.am < Makefile.am << 'END' AUTOMAKE_OPTIONS = serial-tests +TESTS = foo.test bar.test END -cd one -touch missing install-sh $ACLOCAL $AUTOMAKE -grep TEST Makefile.in # For debugging. -hasnt_parallel_tests Makefile.in -test ! -e test-driver -cd .. - -cd two -mkdir config -$ACLOCAL -$AUTOMAKE --add-missing -grep TEST [ab]Makefile.in # For debugging. -has_parallel_tests aMakefile.in -hasnt_parallel_tests bMakefile.in -mv aMakefile.in aMakefile.sav -mv bMakefile.in bMakefile.sav +grep '^include .*.top_srcdir./\.mk/serial-tests\.mk$' Makefile.in +$FGREP 'parallel-tests.mk' Makefile.in && exit 1 +test -f .mk/serial-tests.mk +test ! -e .mk/parallel-tests.mk test ! -e test-driver -test -f config/test-driver -$AUTOMAKE -diff aMakefile.sav aMakefile.in -diff bMakefile.sav bMakefile.in -cd .. : diff --git a/t/spell.sh b/t/spell.sh index 0c339b6d6..3fd31d926 100755 --- a/t/spell.sh +++ b/t/spell.sh @@ -41,7 +41,8 @@ $AUTOMAKE $MAKE 2>stderr && { cat stderr >&2; exit 1; } cat stderr >&2 -LC_ALL=C sed -e 's/^Makefile:[0-9][0-9]*: //' \ +LC_ALL=C sed -e 's|^Makefile:[0-9][0-9]*: ||' \ + -e 's|^\.mk/.*\.mk:[0-9][0-9]*: ||' \ -e '/^\*\*\*.*Automake-NG/d' stderr > got cat > exp << 'END' diff --git a/t/spell2.sh b/t/spell2.sh index 368080bcd..3a5a8ebd0 100755 --- a/t/spell2.sh +++ b/t/spell2.sh @@ -41,7 +41,8 @@ $AUTOMAKE $MAKE 2>stderr && { cat stderr >&2; exit 1; } cat stderr >&2 -LC_ALL=C sed -e 's/^Makefile:[0-9][0-9]*: //' \ +LC_ALL=C sed -e 's|^Makefile:[0-9][0-9]*: ||' \ + -e 's|^\.mk/.*\.mk:[0-9][0-9]*: ||' \ -e '/^\*\*\*.*Automake-NG/d' stderr > got cat > exp << 'END' diff --git a/t/txinfo-rules-once.sh b/t/txinfo-rules-once.sh deleted file mode 100755 index 12e8a84fc..000000000 --- a/t/txinfo-rules-once.sh +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh -# Copyright (C) 2003-2012 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, see . - -# Some grepping checks on Texinfo support. - -. ./defs || exit 1 - -echo AC_OUTPUT >> configure.ac - -$ACLOCAL - -: > texinfo.tex - -echo info_TEXINFOS = main.texi other.texi sub/x.texi > Makefile.am -mkdir sub -echo @setfilename main.info > main.texi -echo @setfilename other.info > other.texi -echo @setfilename sub/x.info > sub/x.texi -$AUTOMAKE -$EGREP '\.(info|pdf|ps|dvi|html|texi)' Makefile.in # For debugging. -test $(grep -c '^%\.info: %\.texi$' Makefile.in) -eq 1 -test $(grep -c '^%\.html: %\.texi$' Makefile.in) -eq 1 -test $(grep -c '^%\.dvi: %\.texi$' Makefile.in) -eq 1 -test $(grep -c '^%\.pdf: %\.texi$' Makefile.in) -eq 1 -test $(grep -c '^%\.ps: %\.dvi$' Makefile.in) -eq 1 - -for t in info dist-info dvi-am install-html uninstall-pdf-am; do - $FGREP $t Makefile.in # For debugging. - test $(grep -c "^$t *:" Makefile.in) -eq 1 -done - -: -- 2.47.2