Subject: bug#7647: [PATCH] {maint} Warnings about primary/prefix mismatch fixed and extended. (was: Re: bug#7647: Diagnose invalid primary/directory combinations)

From: Stefano Lattarini <[email-masked]>
Date: Thu, 27 Jan 2011 21:36:29 +0100

Ping on this?

References:
 <http://lists.gnu.org/archive/html/automake-patches/2011-01/msg00032.html>
 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7647>

I've rebased the patch on latest maint, and improved the comments in the
testcase `primary-prefix-documented-valid.test'.  Below is what I've
squashed in; the updated patch is attached.

So... OK for maint?

Regards,
  Stefano

-*-*-*-

diff --git a/ChangeLog b/ChangeLog
index 625d580..5e1dcd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-2011-01-03  Stefano Lattarini  <[email-masked]>
+2011-01-27  Stefano Lattarini  <[email-masked]>
 
        Warnings about primary/prefix mismatch fixed and extended.
        * automake.in (%standard_prefix): Add `doc' and `locale'.
diff --git a/tests/primary-prefix-invalid-couples.test b/tests/primary-prefix-invalid-couples.test
index bd7a346..a8f61a9 100755
--- a/tests/primary-prefix-invalid-couples.test
+++ b/tests/primary-prefix-invalid-couples.test
@@ -103,11 +103,12 @@ for primary in $primaries; do
     TEXINFOS)
       # FIXME: Here we'd like to have:
       #   prefixes_ok='info'
-      # but Automake currently fails on that, as it allows the TEXINFOS
-      # primary to be coupled to any prefix.
+      # but Automake currently fails on that, as it allows the use of
+      # `foo_TEXINFOS' to declare extra Texinfo sources for the `foo'
+      # Texinfo manual, as in e.g.:
+      #   info_TEXINFOS = foo.texi
+      #   foo_TEXINFOS = gpl.texi
       # See also Automake bug#7657.
-      # We should dig out how automake had come to behave this way, and
-      # if such a behaviour can be safely changed.
       prefixes_ok=$prefixes
       ;;
     *)
From e73827393f4ca2bc0b126bf9c31ec55064b0b6af Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <[email-masked]>
Date: Thu, 16 Dec 2010 19:23:06 +0100
Subject: [PATCH] Warnings about primary/prefix mismatch fixed and extended.

* automake.in (%standard_prefix): Add `doc' and `locale'.
Rename `pkgdatadir' to `pkgdata'.  Similarly for`pkglibdir',
`pkgincludedir' and `pkglibexecdir'.
(handle_programs): List `pkglibexec', not `pkglib', among the
prefixes valid for the `PROGRAMS' primary.
(handle_data): List also `doc' among the prefixes valid for
the `DATA' primary.  This is required by automake's own build
system.
* tests/dirforbid.test: Test removed, superseded by ...
* tests/primary-prefix-invalid-couples.test: ... this new test.
* tests/primary-prefix-valid-couples.test: New test.
* tests/primary-prefix-documented-valid.test: Likewise.
* tests/primary-prefix-force-valid.test: Likewise.
* tests/java3.test: Adjusted, and extended a bit.
* tests/Makefile.am (TESTS): Updated.
* NEWS: Updated.

From a report by Eric Blake.
---
 ChangeLog                                          |   21 +++
 NEWS                                               |    3 +
 automake.in                                        |   16 +-
 tests/Makefile.am                                  |    5 +-
 tests/Makefile.in                                  |    5 +-
 tests/dirforbid.test                               |   38 -----
 tests/java3.test                                   |   14 ++-
 tests/primary-prefix-couples-documented-valid.test |   89 ++++++++++++
 tests/primary-prefix-couples-force-valid.test      |   87 ++++++++++++
 tests/primary-prefix-invalid-couples.test          |  143 ++++++++++++++++++++
 tests/primary-prefix-valid-couples.test            |   90 ++++++++++++
 11 files changed, 460 insertions(+), 51 deletions(-)
 delete mode 100755 tests/dirforbid.test
 create mode 100755 tests/primary-prefix-couples-documented-valid.test
 create mode 100755 tests/primary-prefix-couples-force-valid.test
 create mode 100755 tests/primary-prefix-invalid-couples.test
 create mode 100755 tests/primary-prefix-valid-couples.test

diff --git a/ChangeLog b/ChangeLog
index bed0418..615a72d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-01-27  Stefano Lattarini  <[email-masked]>
+
+	Warnings about primary/prefix mismatch fixed and extended.
+	* automake.in (%standard_prefix): Add `doc' and `locale'.
+	Rename `pkgdatadir' to `pkgdata'.  Similarly for`pkglibdir',
+	`pkgincludedir' and `pkglibexecdir'.
+	(handle_programs): List `pkglibexec', not `pkglib', among the
+	prefixes valid for the `PROGRAMS' primary.
+	(handle_data): List also `doc' among the prefixes valid for
+	the `DATA' primary.  This is required by automake's own build
+	system.
+	* tests/dirforbid.test: Test removed, superseded by ...
+	* tests/primary-prefix-invalid-couples.test: ... this new test.
+	* tests/primary-prefix-valid-couples.test: New test.
+	* tests/primary-prefix-couples-documented-valid.test: Likewise.
+	* tests/primary-prefix-couples-force-valid.test: Likewise.
+	* tests/java3.test: Adjusted, and extended a bit.
+	* tests/Makefile.am (TESTS): Updated.
+	* NEWS: Updated.
+	From a report by Eric Blake.
+
 2011-01-24  Stefano Lattarini  <[email-masked]>
 
 	docs: color-tests issues with parallel make
diff --git a/NEWS b/NEWS
index b5cb6e9..703aeb2 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,9 @@ Bugs fixed in 1.11.0a:
 
 * Long standing bugs:
 
+  - Automake now warns about more primary/directory invalid combinations,
+    such as "doc_LIBRARIES" or "pkglib_PROGRAMS".
+
   - On Darwin 9, `pythondir' and `pyexecdir' pointed below `/Library/Python'
     even if the `--prefix' argument pointed outside of a system directory.
     AM_PATH_PYTHON has been fixed to ignore the value returned from python's
diff --git a/automake.in b/automake.in
index d56fbf7..c9ba0f1 100755
--- a/automake.in
+++ b/automake.in
@@ -249,11 +249,11 @@ my @common_sometimes =
 # Standard directories from the GNU Coding Standards, and additional
 # pkg* directories from Automake.  Stored in a hash for fast member check.
 my %standard_prefix =
-    map { $_ => 1 } (qw(bin data dataroot dvi exec html include info
-			lib libexec lisp localstate man man1 man2 man3
-			man4 man5 man6 man7 man8 man9 oldinclude pdf
-			pkgdatadir pkgincludedir pkglibdir pkglibexecdir
-			ps sbin sharedstate sysconf));
+    map { $_ => 1 } (qw(bin data dataroot doc dvi exec html include info
+			lib libexec lisp locale localstate man man1 man2
+			man3 man4 man5 man6 man7 man8 man9 oldinclude pdf
+			pkgdata pkginclude pkglib pkglibexec ps sbin
+			sharedstate sysconf));
 
 # Copyright on generated Makefile.ins.
 my $gen_copyright = "\
@@ -2627,7 +2627,7 @@ sub handle_libtool
 sub handle_programs
 {
   my @proglist = &am_install_var ('progs', 'PROGRAMS',
-				  'bin', 'sbin', 'libexec', 'pkglib',
+				  'bin', 'sbin', 'libexec', 'pkglibexec',
 				  'noinst', 'check');
   return if ! @proglist;
 
@@ -3737,8 +3737,8 @@ sub handle_man_pages
 sub handle_data
 {
     &am_install_var ('-noextra', '-candist', 'data', 'DATA',
-		     'data', 'dataroot', 'dvi', 'html', 'pdf', 'ps',
-		     'sysconf', 'sharedstate', 'localstate',
+		     'data', 'dataroot', 'doc', 'dvi', 'html', 'pdf',
+		     'ps', 'sysconf', 'sharedstate', 'localstate',
 		     'pkgdata', 'lisp', 'noinst', 'check');
 }
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 78bacf2..d43ad48 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -281,7 +281,6 @@ depend4.test \
 depend5.test \
 depend6.test \
 destdir.test \
-dirforbid.test \
 dirlist.test \
 dirlist2.test \
 discover.test \
@@ -610,6 +609,10 @@ prefix.test \
 primary.test \
 primary2.test \
 primary3.test \
+primary-prefix-invalid-couples.test \
+primary-prefix-valid-couples.test \
+primary-prefix-couples-force-valid.test \
+primary-prefix-couples-documented-valid.test \
 proginst.test \
 python.test \
 python2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 18cb337..d925805 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -548,7 +548,6 @@ depend4.test \
 depend5.test \
 depend6.test \
 destdir.test \
-dirforbid.test \
 dirlist.test \
 dirlist2.test \
 discover.test \
@@ -877,6 +876,10 @@ prefix.test \
 primary.test \
 primary2.test \
 primary3.test \
+primary-prefix-invalid-couples.test \
+primary-prefix-valid-couples.test \
+primary-prefix-couples-force-valid.test \
+primary-prefix-couples-documented-valid.test \
 proginst.test \
 python.test \
 python2.test \
diff --git a/tests/dirforbid.test b/tests/dirforbid.test
deleted file mode 100755
index 3ab319d..0000000
--- a/tests/dirforbid.test
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2003  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/>.
-
-# All primaries cannot be used with all directories.
-# Automake should flag them as errors.
-# For PR/294
-
-. ./defs || Exit 1
-
-set -e
-
-cat >> configure.in <<'END'
-AC_PROG_CC
-END
-
-# Try some (not all) disallowed variables
-for i in data_PROGRAMS lib_HEADERS ; do
-  cat > Makefile.am << END
-$i = foo
-END
-  $ACLOCAL
-  AUTOMAKE_fails -a
-  grep 'Makefile.am:1:.*directory' stderr
-done
-:
diff --git a/tests/java3.test b/tests/java3.test
index 7895769..41dbb71 100755
--- a/tests/java3.test
+++ b/tests/java3.test
@@ -23,7 +23,7 @@
 set -e
 
 cat >> configure.in << 'END'
-AM_CONDITIONAL([WHO_CARES], false)
+AM_CONDITIONAL([WHO_CARES], [false])
 AC_OUTPUT
 END
 
@@ -32,7 +32,7 @@ if WHO_CARES
 JAVA_FILES = MyClass1.java
 endif
 
-dist_pkgdata_JAVA = $(JAVA_FILES)
+dist_java_JAVA = $(JAVA_FILES)
 END
 
 : >MyClass1.java
@@ -40,5 +40,13 @@ END
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
-./configure
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE install
+test ! -d _inst
+test ! -r _inst
+$MAKE uninstall
 $MAKE distcheck
+
+:
diff --git a/tests/primary-prefix-couples-documented-valid.test b/tests/primary-prefix-couples-documented-valid.test
new file mode 100755
index 0000000..c52e40f
--- /dev/null
+++ b/tests/primary-prefix-couples-documented-valid.test
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check that the "uncommon" prefix/primary combinations used in
+# examples in the Automake manual do not cause obvious errors.
+# Please keep this test in sync with the automake manual.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PROG_GCJ
+AM_PATH_PYTHON
+END
+
+# Fake libtool availability.
+: > ltmain.sh
+cat > acinclude.m4 <<'END'
+AC_DEFUN([AC_PROG_LIBTOOL],
+         [AC_SUBST([LIBTOOL], [:])])
+END
+
+cat > Makefile.am <<'END'
+xmldir = $(datadir)/xml
+xml_DATA = file.xml
+
+data_DATA = file1 file2 file3
+data2dir = $(datadir)
+data2_DATA = file4 file5 file6
+
+aclocaldir = $(datadir)/aclocal
+aclocal_DATA = mymacro.m4 myothermacro.m4
+
+imagesdir = $(pkgdatadir)/images
+soundsdir = $(pkgdatadir)/sounds
+dist_images_DATA = images/vortex.pgm
+dist_sounds_DATA = sounds/whirl.ogg
+
+lisp_DATA = file1.el file2.el
+
+javadir = $(datadir)/java
+dist_java_JAVA = a.java b.java c.java
+
+pkgpython_PYTHON = foo.py
+
+pyexec_LTLIBRARIES = quaternion.la
+quaternion_la_SOURCES = quaternion.c support.c support.h
+quaternion_la_LDFLAGS = -avoid-version -module
+
+myexecbindir = /exec
+myexecbin_PROGRAMS = zardoz
+
+foodir = $(prefix)/foo
+barexecdir = $(prefix)/bar/binaries
+foo_SCRIPTS = foo.sh
+barexec_SCRIPTS = quux.pl
+
+my_execbindir = $(pkglibdir)
+my_doclibdir = $(docdir)
+my_execbin_PROGRAMS = foo
+my_doclib_LIBRARIES = libquux.a
+END
+
+$ACLOCAL
+
+# Both these two invocations are meant.
+# They exercise both code paths concerning auxiliary files.
+$AUTOMAKE -a
+$AUTOMAKE
+
+:
diff --git a/tests/primary-prefix-couples-force-valid.test b/tests/primary-prefix-couples-force-valid.test
new file mode 100755
index 0000000..159f297
--- /dev/null
+++ b/tests/primary-prefix-couples-force-valid.test
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check that a user who wants to use an invalid prefix/primary
+# combination can do so with a proper workaround.
+# For example, this:
+#   lib_PROGRAMS = foo
+# is expected to cause an automake error, but this:
+#   bardir = $(libdir)
+#   bar_PROGRAMS = foo
+# should work.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+my_libdir = $(libdir)
+my_lib_PROGRAMS = foo
+
+foodir = $(bindir)
+foo_LIBRARIES = libquux.a
+
+xdir = $(libexecdir)
+x_HEADERS = bar.h
+
+installcheck-local: test
+.PHONY: test
+test:
+	(cd '$(prefix)' && find .);: for debugging
+	ls -l '$(libdir)/foo'
+	test -f '$(libdir)/foo'
+	test -x '$(libdir)/foo'
+	ls -l '$(bindir)/libquux.a'
+	test -f '$(bindir)/libquux.a'
+	ls -l '$(libexecdir)/bar.h'
+	test -f '$(libexecdir)/bar.h'
+	test ! -x '$(libexecdir)/bar.h'
+END
+
+cat > foo.c <<'END'
+int main (void)
+{
+  return 0;
+}
+END
+
+cat > libquux.c <<'END'
+int quux(void)
+{
+  return 1;
+}
+END
+
+: > bar.h
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+
+$MAKE install
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/tests/primary-prefix-invalid-couples.test b/tests/primary-prefix-invalid-couples.test
new file mode 100755
index 0000000..a2f98e1
--- /dev/null
+++ b/tests/primary-prefix-invalid-couples.test
@@ -0,0 +1,143 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Not all primaries/directories combinations are valid.
+# Automake should flag them as errors.
+# Originated from PR/294, extended later (following bug #7647) to
+# cover more cases.
+# See also test `primary-prefix-valid-couples.test'.
+
+. ./defs || Exit 1
+
+set -e
+
+oIFS=$IFS # saved for later
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PROG_GCJ
+AM_PATH_PYTHON
+AM_PATH_LISPDIR
+END
+
+$ACLOCAL
+
+# Please keep this list in sync with the list of "Directory Variables"
+# in the GNU Coding Standards and with the list additional directory
+# variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
+# ...).   See also the hash `%standard_prefix' in the automake script.
+prefixes='bin data dataroot doc dvi exec html include info lib libexec
+          lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
+          man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
+          ps sbin sharedstate sysconf'
+# Please keep this list in sync with the list of primaries documented in
+# the Automake manual (see the "The Uniform Naming Scheme" section).
+primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
+           HEADERS MANS TEXINFOS'
+
+# Use files, not variables, to hold the list of all the possible
+# prefix_PRIMARY couples and the list of those couples valid for
+# automake, to avoid having unreadable very verbose traces.
+
+set +x # don't be overly verbose
+
+for prefix in $prefixes; do
+  for primary in $primaries; do
+    echo ${prefix}_${primary}
+  done
+done >all.list
+
+for primary in $primaries; do
+  prefixes_ok=''
+  case $primary in
+    LIBRARIES|LTLIBRARIES)
+      prefixes_ok='lib pkglib'
+      ;;
+    PROGRAMS)
+      prefixes_ok='bin sbin libexec pkglibexec'
+      ;;
+    SCRIPTS)
+      prefixes_ok='bin sbin libexec pkgdata'
+      ;;
+    DATA)
+      prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
+                   sysconf sharedstate localstate lisp'
+      ;;
+    HEADERS)
+      prefixes_ok='include oldinclude pkginclude'
+      ;;
+    LISP)
+      prefixes_ok='lisp'
+      ;;
+    PYTHON)
+      prefixes_ok='python'
+      ;;
+    JAVA)
+      prefixes_ok='java'
+      ;;
+    MANS)
+      # FIXME: Here we'd like to have:
+      #   prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
+      # but Automake currently fails on that, as it allows the MANS
+      # primary to be coupled to any prefix.
+      # See also Automake bug#7656.
+      # We should dig out how automake had come to behave this way, and
+      # if such a behaviour can be safely changed.
+      prefixes_ok=$prefixes
+      ;;
+    TEXINFOS)
+      # FIXME: Here we'd like to have:
+      #   prefixes_ok='info'
+      # but Automake currently fails on that, as it allows the use of
+      # `foo_TEXINFOS' to declare extra Texinfo sources for the `foo'
+      # Texinfo manual, as in e.g.:
+      #   info_TEXINFOS = foo.texi
+      #   foo_TEXINFOS = gpl.texi
+      # See also Automake bug#7657.
+      prefixes_ok=$prefixes
+      ;;
+    *)
+      echo "$me: internal error: unrecognized primary '$primary'" >&2
+      Exit 99
+      ;;
+  esac
+  for prefix in $prefixes_ok; do
+    echo ${prefix}_${primary}
+  done
+done >allow.list
+
+set -x
+
+cat all.list
+cat allow.list
+
+while read x; do
+  grep "^$x$" allow.list >/dev/null && continue
+  # To get the expected error message more in detail.
+  IFS=_; set $x; IFS=$oIFS
+  test $# -eq 2 || Exit 99 # sanity check
+  prefix=$1
+  primary=$2
+  errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
+  # Now do the test for this prefix/primary combination.
+  echo "$x = foo" > Makefile.am
+  AUTOMAKE_fails -a
+  grep "^Makefile\\.am:1:$errmsg_rx" stderr
+done <all.list
+
+:
diff --git a/tests/primary-prefix-valid-couples.test b/tests/primary-prefix-valid-couples.test
new file mode 100755
index 0000000..b6b53dc
--- /dev/null
+++ b/tests/primary-prefix-valid-couples.test
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011 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 valid prefix/primary combinations.
+# See also test `primary-prefix-invalid-couples.test'.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PROG_GCJ
+AM_PATH_PYTHON
+AM_PATH_LISPDIR
+END
+
+# Fake libtool availability.
+: > ltmain.sh
+: > config.sub
+: > config.guess
+cat > acinclude.m4 <<'END'
+AC_DEFUN([AC_PROG_LIBTOOL],
+         [AC_SUBST([LIBTOOL], [:])])
+END
+
+# Other required files.
+echo '@setfilename foo' > foo.texi
+: > texinfo.tex
+: > py-compile
+: > elisp-comp
+
+# Setup Makefile.am.
+
+: > Makefile.am
+
+for p in bin sbin libexec pkglibexec; do
+  echo "${p}_PROGRAMS = prog-$p" >> Makefile.am
+done
+
+for p in lib pkglib; do
+  echo "${p}_LIBRARIES = libs-$p.a" >> Makefile.am
+  echo "${p}_LTLIBRARIES = libd-$p.la" >> Makefile.am
+done
+
+for p in bin sbin libexec pkgdata; do
+  echo "${p}_SCRIPTS = $p.sh" >> Makefile.am
+done
+
+for p in data dataroot pkgdata doc html dvi pdf ps sysconf \
+         sharedstate localstate lisp; do
+  echo "${p}_DATA = $p.dat" >> Makefile.am
+done
+
+for p in include oldinclude pkginclude; do
+  echo "${p}_HEADERS = $p.h" >> Makefile.am
+done
+
+for p in man man1 man2 man3 man4 man5 man6 man7 man8 man9; do
+  echo "${p}_MANS = bar.$p"
+done
+
+echo "info_TEXINFOS = foo.texi" >> Makefile.am
+echo "lisp_LISP = foo.el" >> Makefile.am
+echo "python_PYTHON = foo.py" >> Makefile.am
+echo "java_JAVA = foo.java" >> Makefile.am
+
+awk '{print NR ":" $0}' Makefile.am # for debugging
+
+# Go with the tests.
+
+$ACLOCAL
+$AUTOMAKE
+
+:
-- 
1.7.2.3