]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
general: include verbatim makefile fragments in output Makefiles
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 1 Aug 2012 09:18:35 +0000 (11:18 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 2 Aug 2012 15:34:25 +0000 (17:34 +0200)
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 <stefano.lattarini@gmail.com>
20 files changed:
.gitignore
Makefile.am
automake.in
lib/am/distdir.am
t/all2.sh
t/ax/depcomp.sh
t/ax/tap-setup.sh
t/check2.sh
t/clean.sh [deleted file]
t/conflnk2.sh
t/dejagnu.sh [deleted file]
t/distdir.sh
t/installdir.sh
t/instexec.sh [deleted file]
t/noinst.sh
t/phony.sh
t/serial-tests.sh
t/spell.sh
t/spell2.sh
t/txinfo-rules-once.sh [deleted file]

index 8fee6b76f90ae733a481ee095e2d9e4db77b87e3..6a6d5c2a20fa033f5813f739be1f1e9f34f3c8da 100644 (file)
@@ -1,3 +1,4 @@
+/.mk/
 /ChangeLog
 /aclocal.m4
 /configure
index eab05c36372ec1bb0d108ec9221d81844a5f3d59..1392f68d2b17d6223567aa1927e05b3166ddb27c 100644 (file)
@@ -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
index 596b52983207a3523e2c493ea7ac7d6cdffecbf3..40b2c4d8a3856365faf79db06624437b1273e987 100644 (file)
@@ -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;
     }
 }
index 310b338f391c0274851f5687777677133bf182be..ce5ff1b7ef72cd8f3146aaf5901f2525a050a506 100644 (file)
 
 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.
index 879cdfcee9096e55d6f9758c56acfdab41842f22..e586b6e6878b74d682b4ef4bf60ef34a2c74718a 100755 (executable)
--- 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
 
 :
index 5886691b779fe84f1887da387e19db9a554fc5e7..2a60dd95113db4f2b93d758f1418bd40a6eab8c0 100644 (file)
@@ -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'"
 }
 
index 952a49dfa3047fff98fd9d11fe32793e28fd5b73..3ea2a83500697800f137fdbc9edae5e478d5accb 100644 (file)
@@ -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
index 9a1124ad207837db3564b5337d3100e0848131ed..95f479a552ae806c5c0b4c08f82675f8d09f57bb 100755 (executable)
@@ -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 (executable)
index 80f56df..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-
-# 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
index fa0b0092b752bc1e832ef946860649988bde55a8..8c0bf9bca6a6fd23d77d33331a67ffcec94ad690 100755 (executable)
 
 . ./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 (executable)
index a3bec52..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-
-# 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
-
-:
index 8edf6f074303c708925740105050b08f8ce7860b..d73e445cf3b88c166c3aa93ca1d25dd0c1ed800b 100755 (executable)
@@ -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)"
index 1cef2c152ca143507cf2511ee66bba8d06559c43..5f74b32f9c5be1a99f3d5c635d84cd893925800d 100755 (executable)
@@ -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 (executable)
index f394d84..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-
-# 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
index ca4440fde0fd96edd756cb420f609ec0edc14480..de8d3d2eb48d7f79c87172523eeb91d4a0df872e 100755 (executable)
 
 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
 
 :
index b1f3b7ec864f3e8c5f55c8a49a56f49da299aee3..14d6e24d7a34a19a681b6a2d3d50e45bcb9ff4dd 100755 (executable)
@@ -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
 
 :
index d90de296f79db99c0a38fc1e4b669189449e8358..2c6f9bc9195eeb10efe15cd111b496f48495a70a 100755 (executable)
 
 # 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 <<END
-AC_INIT([$me], [1.0])
-AM_INIT_AUTOMAKE([serial-tests])
-AC_CONFIG_FILES([Makefile])
-END
-
-echo 'TESTS = foo.test bar.test' > one/Makefile.am
-
-cat > two/configure.ac <<END
-AC_INIT([$me], [2.0])
-AC_CONFIG_AUX_DIR([config])
-AM_INIT_AUTOMAKE([parallel-tests])
-AC_CONFIG_FILES([aMakefile bMakefile])
-END
-
-cp one/Makefile.am two/aMakefile.am
-cat - one/Makefile.am > two/bMakefile.am <<END
+cat > 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 ..
 
 :
index 0c339b6d60ffe675d9ed07cebf181986e4673a92..3fd31d926ab10c68692f87298a47a8b6ee2247f1 100755 (executable)
@@ -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'
index 368080bcd944f1dd3e080c2ef15a31d00a2200aa..3a5a8ebd0f6c8df1a42d561ebd19ee6b17d75c8f 100755 (executable)
@@ -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 (executable)
index 12e8a84..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-
-# 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
-
-: