Subject: bug#13378: [PATCH] compile: use 'compile' script when "-c -o" is used with losing compilers

From: Stefano Lattarini <[email-masked]>
Date: Thu, 10 Jan 2013 14:33:19 +0100

Reference:
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#50>

On 01/08/2013 08:27 PM, Stefano Lattarini wrote:
> On 01/08/2013 04:29 PM, Eric Blake wrote:
>> On 01/08/2013 08:15 AM, Stefano Lattarini wrote:
>>> That would be overkill, since AM_PROG_CC_C_O is only required by
>>> projects doing C compilation.  Also, IIRC, that macro needs to be
>>> called after AC_PROG_CC, while AM_INIT_AUTOMAKE is typically invoked
>>> before AC_PROG_CC.
>>
>> But with m4, you can arrange for AM_INIT_AUTOMAKE to redefine AC_PROG_CC
>> so that it hooks in a call to AM_PROG_CC_C_O immediately after its
>> current definition, and thus still preserve desired ordering while
>> making the burden simpler for the configure.ac author.
>>
> This is true, but I'd have preferred to avoid this shenanigans with
> macro redefinitions if at all possible.  It seems it won't be really
> possible though (see also my reply to the last message from Nick):
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#47>
> :-(
>
> [SNIP]
>
> So I think your proposal is the way to go, *right for Automake 1.13.2*,
> since it offers a bug fix for the situation described in
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#47>
>
Done with the patch below.  The AC_PROG_CC redefinition is more of a
band-aid rather than a "proper" fix (the copy & paste done by the patch
is admittedly quite horrific), but that is no big deal IMHO, since we
will backport the features needed by Automake back into Autoconf, and
Automake 1.14 will just require the later Autoconf anyway, allowing us
to get rid of that copy & paste.

In addition, with this change, the 'compile' script will be required
in *all* projects using C compilation (even if they don't use the
'subdir-objects' option); but this should be noticeable only by
packages not using 'automake --add-missing' (and they should be the
great majority), and easily fixable by the other packages anyway.

OK to push to maint?  I'll wait up to a week to push, since I'd really
like a review on this ...

Thanks,
  Stefano

---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----

>From 5e65e237be62efabcdc2dbd7410ab44bc514b48e Mon Sep 17 00:00:00 2001
Message-Id: <5e65e237b[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Wed, 9 Jan 2013 23:16:53 +0100
Subject: [PATCH] compile: use 'compile' script when "-c -o" is used with losing compilers

Do so seen when only source files in the "current" directory are present.

This commit is part of a series of related changes addressing automake
bug#13378 (see also the plan 'PLANS/subdir-objects.txt').

Before this change, Automake-generated C compilation rules mistakenly
passed the "-c -o" options combination unconditionally (even to losing
compiler) when the 'subdir-objects' was used but sources were only
present in the top-level directory.  Issue spotted by Nick Bowler:

  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#35>
  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#44>

We fix this by having Automake redefine AC_PROG_CC to take over the role
of AM_PROG_CC_C_O and to require the 'compile' script unconditionally
(albeit that will continue to be invoked only when inferior compilers
are detected).

Among other things, this means AM_PROG_CC_C_O explicitly is no longer
required; that macro is still supported for backward-compatibility, but
calling it is basically a no-op now.

This change has some pros and some cons (obviously, we believe the former
outweighs the latter).  Here are the most relevant ones:

+ Pros 1:
  Some logic in the Automake script has been simplified
+ Pros 2:
  That simplification has automatically fixed an actual bug (admittedly,
  it was present only in corner situations, but still) XXX
  The test 't/ccnoco4.sh', which demonstrated that bug and has been
  failing so far, now passes.
+ Pros 3:
  Things works more "automagically" now (no need to manually add the
  AM_PROG_CC_C_O macro to configure.ac anymore)

* Cons 1:
  The 'compile' script will be required in all projects using C
  compilation; this will only be a problem for packages not using
  '--add-missing'.  However, such packages are definitely more rare
  than the ones using '--add-missing', and adjusting them will be
  trivial -- just copy the compile script over from the new Automake
  installation.
* Cons 2:
  The copy & paste of autoconf internals hack this change has introduced
  in our "rewrite" of AC_PROG_CC is really an egregious abomination.  It
  can only be justified with the fact that we expect future versions of
  autoconf to implement the semantics we need directly in AC_PROG_CC, so
  that we'll be able to leverage that (since Automake 1.14 will require
  the latest Autoconf version released).

Now, the detailed list of file-by-file changes ...

* automake.in ($seen_cc_c_o): Remove this global variable.
(scan_autoconf_traces): Don't set it, and do not trace the
'AM_PROG_CC_C_O' m4 macro.
(lang_c_rewrite): Remove, no longer needed.
* doc/automake.texi: Adjust expected "autoreconf --install" output
in the amhello example.  Remove statements about the need for the
AM_PROG_CC_C_O macro.  Report it is obsolete now.
* m4/init.m4: Re-write AC_PROG_CC to append checks about whether the
C compiler supports "-c -o" together.  These checks have basically
been ripped out (with adaptations) from the 'AC_PROG_CC_C_O' macro
of Autoconf and ...
* m4/minuso.m4 (AM_PROG_CC_C_O): ... this macro of ours, which has
thus basically become a no-op.
* t/ax/am-test-lib.sh (am_setup_testdir): Also copy the 'compile'
script in the test directory; if we don't do so, every test using
AC_PROG_CC should call automake with the "--add-missing" option, or
copy the 'compile' script itself.
* t/cond11.sh: No need to create a dummy 'compile' script: that is
already brought in by 'am_setup_testdir()', that is automatically
invoked when 'test-lib.sh' is sourced.
* t/add-missing.tap: Adjust: we expect the 'compile' script to be
required by a mere AC_PROG_CC call now.
* t/dist-auxdir-many-subdirs.sh: Likewise.
* t/specflg6.sh: Likewise.
* t/subobj4.sh: Likewise.
* t/cxx-lt-demo.sh: Likewise, and update comments to match.
* t/distcom2.sh: Enhance a little.
* t/dollarvar2.sh: Adjust.
* t/extra-portability.sh: Likewise.
* t/per-target-flags.sh: Likewise.
* t/subobj.sh: Likewise, and enhance a little.
* t/ccnoco2.sh: Remove as obsolete.
* t/list-of-tests.mk (handwritten_TESTS): Adjust.
(XFAIL_TESTS): Remove 't/ccnoco4.sh'.
* NEWS: Update.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 .gitignore                    |  1 +
 NEWS                          | 23 ++++++++++++++++++
 automake.in                   | 47 ------------------------------------
 doc/automake.texi             | 22 +++++++++--------
 m4/init.m4                    | 47 ++++++++++++++++++++++++++++++++++++
 m4/minuso.m4                  | 20 +++-------------
 t/add-missing.tap             |  9 ++++---
 t/ax/am-test-lib.sh           |  2 +-
 t/ccnoco2.sh                  | 55 -------------------------------------------
 t/cond11.sh                   |  1 -
 t/cxx-lt-demo.sh              |  6 +++--
 t/dist-auxdir-many-subdirs.sh |  1 +
 t/distcom2.sh                 |  2 ++
 t/dollarvar2.sh               | 11 +++------
 t/extra-portability.sh        | 13 +++++-----
 t/list-of-tests.mk            |  2 --
 t/per-target-flags.sh         |  7 ------
 t/specflg6.sh                 |  2 --
 t/subobj.sh                   |  5 +++-
 t/subobj4.sh                  |  1 -
 20 files changed, 113 insertions(+), 164 deletions(-)
 delete mode 100755 t/ccnoco2.sh

diff --git a/.gitignore b/.gitignore
index a32310e..0d031eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@
 /doc/amhello/config.h.in~
 /doc/amhello/configure
 /doc/amhello/depcomp
+/doc/amhello/compile
 /doc/amhello/install-sh
 /doc/amhello/missing
 /doc/web-manual
diff --git a/NEWS b/NEWS
index 02a34df..e87d267 100644
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,29 @@ New in 1.13.2:
     should take precedence over the same-named automake-provided macro
     (defined in '/usr/local/share/aclocal-1.14/vala.m4').

+* C compilation, and the AC_PROG_CC and AM_PROG_CC_C_O macros:
+
+  - The 'compile' script is now unconditionally required for all
+    packages that perform C compilation (note that if you are using
+    the '--add-missing' option, automake will fetch that script for
+    you, so you shouldn't need any explicit adjustment).
+    This new behaviour is needed to avoid obscure errors when the
+    'subdir-objects' option is used, and the compiler is an inferior
+    one that doesn't grasp the combined use of both the "-c -o"
+    options; see discussion about automake bug#13378 for more details:
+    <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#35>
+    <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#44>
+
+  - Automake will automatically enhance the AC_PROG_CC autoconf macro
+    to make it check, at configure time, that the C compiler supports
+    the combined use of both the "-c -o" options.  This "rewrite" of
+    AC_PROG_CC is only meant to be temporary, since future Autoconf
+    versions should provide all the features Automake needs.
+
+  - The AM_PROG_CC_C_O is no longer useful, and its use is a no-op
+    now.  Future Automake versions might start warning that this
+    macro is obsolete.
+
 * Obsolescent features:

   - Use of suffix-less info files (that can be specified through the
diff --git a/automake.in b/automake.in
index e8ba73f..990b60d 100644
--- a/automake.in
+++ b/automake.in
@@ -387,9 +387,6 @@ my $package_version_location;
 # TRUE if we've seen AM_PROG_AR
 my $seen_ar = 0;

-# TRUE if we've seen AM_PROG_CC_C_O
-my $seen_cc_c_o = 0;
-
 # Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument.
 my %required_aux_file = ();

@@ -5179,7 +5176,6 @@ sub scan_autoconf_traces ($)
 		AM_INIT_AUTOMAKE => 0,
 		AM_MAINTAINER_MODE => 0,
 		AM_PROG_AR => 0,
-		AM_PROG_CC_C_O => 0,
 		_AM_SUBST_NOTMAKE => 1,
 		_AM_COND_IF => 1,
 		_AM_COND_ELSE => 1,
@@ -5383,10 +5379,6 @@ EOF
 	{
 	  $seen_ar = $where;
 	}
-      elsif ($macro eq 'AM_PROG_CC_C_O')
-	{
-	  $seen_cc_c_o = $where;
-	}
       elsif ($macro eq '_AM_COND_IF')
         {
 	  cond_stack_if ('', $args[1], $where);
@@ -5607,45 +5599,6 @@ sub lang_sub_obj
     return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
 }

-# Rewrite a single C source file.
-sub lang_c_rewrite
-{
-  my ($directory, $base, $ext, $obj, $have_per_exec_flags, $var) = @_;
-
-  my $r = LANG_PROCESS;
-  if (option 'subdir-objects')
-    {
-      $r = LANG_SUBDIR;
-      if ($directory && $directory ne '.')
-	{
-	  $base = $directory . '/' . $base;
-
-	  # libtool is always able to put the object at the proper place,
-	  # so we do not have to require AM_PROG_CC_C_O when building .lo files.
-	  msg_var ('portability', $var,
-		   "compiling '$base.c' in subdir requires "
-		   . "'AM_PROG_CC_C_O' in '$configure_ac'",
-		   uniq_scope => US_GLOBAL,
-		   uniq_part => 'AM_PROG_CC_C_O subdir')
-	    unless $seen_cc_c_o || $obj eq '.lo';
-	}
-    }
-
-  if (! $seen_cc_c_o
-      && $have_per_exec_flags
-      && ! option 'subdir-objects'
-      && $obj ne '.lo')
-    {
-      msg_var ('portability',
-	       $var, "compiling '$base.c' with per-target flags requires "
-	       . "'AM_PROG_CC_C_O' in '$configure_ac'",
-	       uniq_scope => US_GLOBAL,
-	       uniq_part => 'AM_PROG_CC_C_O per-target')
-    }
-
-    return $r;
-}
-
 # Rewrite a single header file.
 sub lang_header_rewrite
 {
diff --git a/doc/automake.texi b/doc/automake.texi
index 8ace5e5..5048f54 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -1496,6 +1496,7 @@ command as follows:
 ~/amhello % @kbd{autoreconf --install}
 configure.ac: installing './install-sh'
 configure.ac: installing './missing'
+configure.ac: installing './compile'
 src/Makefile.am: installing './depcomp'
 @end example

@@ -3994,10 +3995,9 @@ choose the assembler for you (by default the C compiler) and set
 @item AM_PROG_CC_C_O
 @acindex AM_PROG_CC_C_O
 @acindex AC_PROG_CC_C_O
-This is like @code{AC_PROG_CC_C_O}, but it generates its results in
-the manner required by Automake.  You must use this instead of
-@code{AC_PROG_CC_C_O} when you need this functionality, that is, when
-using per-target flags or subdir-objects with C sources.
+This is an @emph{obsolete wrapper} around @code{AC_PROG_CC_C_O}.  New
+code needs not to use this macro.  It might be deprecated and
+@emph{retired in future Automake versions}.

 @item AM_PROG_LEX
 @acindex AM_PROG_LEX
@@ -4068,6 +4068,13 @@ Invocation, , Using @command{autoupdate} to Modernize

 @table @code

+@item AM_PROG_CC_C_O
+@acindex AM_PROG_CC_C_O
+@acindex AC_PROG_CC_C_O
+This is an @emph{obsolete wrapper} around @code{AC_PROG_CC_C_O}.  New
+code needs not to use this macro.  It will be deprecated, and then
+removed, in future Automake versions.
+
 @item AM_PROG_MKDIR_P
 @acindex AM_PROG_MKDIR_P
 @cindex @code{mkdir -p}, macro check
@@ -5810,9 +5817,7 @@ different name for the intermediate object files.  Ordinarily a file
 like @file{sample.c} will be compiled to produce @file{sample.o}.
 However, if the program's @code{_CFLAGS} variable is set, then the
 object file will be named, for instance, @file{maude-sample.o}.  (See
-also @ref{Renamed Objects}.)  The use of per-target compilation flags
-with C sources requires that the macro @code{AM_PROG_CC_C_O} be called
-from @file{configure.ac}.
+also @ref{Renamed Objects}).

 In compilations with per-target flags, the ordinary @samp{AM_} form of
 the flags variable is @emph{not} automatically included in the
@@ -10245,9 +10250,6 @@ the source file.  For instance, if the source file is
 @file{subdir/file.cxx}, then the output file would be
 @file{subdir/file.o}.

-In order to use this option with C sources, you should add
-@code{AM_PROG_CC_C_O} to @file{configure.ac}.
-
 @anchor{tar-formats}
 @item @option{tar-v7}
 @itemx @option{tar-ustar}
diff --git a/m4/init.m4 b/m4/init.m4
index 44b2481..db77a96 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -125,6 +125,53 @@ dnl mangled by Autoconf and run in a shell conditional statement.
 m4_define([_AC_COMPILER_EXEEXT],
 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])

+dnl We have to redefine AC_PROG_CC to allow our compile rules to use
+dnl "-c -o" together also with losing compilers.
+dnl FIXME: Add references to the original discussion and bug report.
+dnl FIXME: Shameless copy & paste from Autoconf internals, since trying to
+dnl        play smart among tangles of AC_REQUIRE, m4_defn, m4_provide and
+dnl        other tricks was proving too difficult, and in the end, likely
+dnl        more brittle too.  And this should anyway be just a temporary
+dnl        band-aid, until Autoconf provides the semantics and/or hooks we
+dnl        need (hint hint, nudge nudge) ...
+AC_DEFUN([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+dnl FIXME The following abomination is expected to disappear in
+dnl       Automake 1.14.
+AC_MSG_CHECKING([whether $CC understands -c and -o together])
+set dummy $CC; ac_cc=`AS_ECHO(["$[2]"]) | \
+                      sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
+AC_CACHE_VAL([ac_cv_prog_cc_${am_cc}_c_o],
+[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
+rm -f conftest2.*
+if _AC_DO_VAR(ac_try) && test -f conftest2.$ac_objext
+then
+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+else
+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+])dnl
+if eval test \"\$ac_cv_prog_cc_${ac_cc}_c_o\" = yes; then
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
+  # Losing compiler, so wrap it with the 'compile' script.
+  # FIXME: It is wrong to rewrite CC.
+  # But if we don't then we get into trouble of one sort or another.
+  # A longer-term fix would be to have automake use am__CC in this case,
+  # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+  CC="$am_aux_dir/compile $CC"
+  AC_DEFINE([NO_MINUS_C_MINUS_O], [1],
+            [Define to 1 if your C compiler doesn't accept -c and -o together.])
+fi
+])

 # When config.status generates a header, we must update the stamp-h file.
 # This file resides in the same directory as the config header
diff --git a/m4/minuso.m4 b/m4/minuso.m4
index 984427c..6cb574e 100644
--- a/m4/minuso.m4
+++ b/m4/minuso.m4
@@ -7,24 +7,10 @@

 # AM_PROG_CC_C_O
 # --------------
-# Like AC_PROG_CC_C_O, but changed for automake.
+# Basically a no-op now, completely superseded by the AC_PROG_CC
+# adjusted by Automake.  Kept for backward-compatibility.
 AC_DEFUN([AM_PROG_CC_C_O],
-[AC_REQUIRE([AC_PROG_CC_C_O])dnl
-AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([compile])dnl
-# FIXME: we rely on the cache variable name because
-# there is no other way.
-set dummy $CC
-am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
-eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
-if test "$am_t" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
+[AC_REQUIRE([AC_PROG_CC])dnl
 dnl Make sure AC_PROG_CC is never called again, or it will override our
 dnl setting of CC.
 m4_define([AC_PROG_CC],
diff --git a/t/add-missing.tap b/t/add-missing.tap
index f74c2fd..9c4b774 100755
--- a/t/add-missing.tap
+++ b/t/add-missing.tap
@@ -247,6 +247,7 @@ check_ <<'END'
 depcomp/C
 == Files ==
 depcomp
+compile
 == configure.ac ==
 AC_PROG_CC
 == Makefile.am ==
@@ -271,9 +272,9 @@ compile
 == Files ==
 compile
 == configure.ac ==
-# Using AM_PROG_CC_C_O in configure.ac should be enough.  No need to
-# use AC_PROG_CC too, nor to define xxx_PROGRAMS in Makefile.am.
-AM_PROG_CC_C_O
+# Using AC_PROG_CC in configure.ac should be enough.  No
+# need to also define, say, xxx_PROGRAMS in Makefile.am.
+AC_PROG_CC
 END

 # For config.guess and config.sub.
@@ -294,6 +295,7 @@ check_ <<'END'
 == Name ==
 ylwrap/Lex
 == Files ==
+compile
 ylwrap
 == configure.ac ==
 AC_PROG_CC
@@ -308,6 +310,7 @@ check_ <<'END'
 == Name ==
 ylwrap/Yacc
 == Files ==
+compile
 ylwrap
 == configure.ac ==
 AC_PROG_CC
diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh
index f3fcacc..0ceb4d0 100644
--- a/t/ax/am-test-lib.sh
+++ b/t/ax/am-test-lib.sh
@@ -820,7 +820,7 @@ am_setup_testdir ()
     || framework_failure_ "cannot chdir into test subdirectory"
   if test x"$am_create_testdir" != x"empty"; then
     cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
-       "$am_scriptdir"/depcomp . \
+       "$am_scriptdir"/compile "$am_scriptdir"/depcomp . \
       || framework_failure_ "fetching common files from $am_scriptdir"
     # Build appropriate environment in test directory.  E.g., create
     # configure.ac, touch all necessary files, etc.  Don't use AC_OUTPUT,
diff --git a/t/ccnoco2.sh b/t/ccnoco2.sh
deleted file mode 100755
index a835fa6..0000000
--- a/t/ccnoco2.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2006-2013 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/>.
-
-# Make sure Automake requires AM_PROG_CC_C_O when either per-targets
-# flags or subdir-objects are used.
-
-. test-init.sh
-
-cat >>configure.ac <<EOF
-AC_PROG_CC
-AC_OUTPUT
-EOF
-
-cat >Makefile.am <<EOF
-bin_PROGRAMS = wish
-wish_SOURCES = a.c
-wish_CPPFLAGS = -DWHATEVER
-EOF
-
-touch a.c
-
-$ACLOCAL
-$AUTOCONF
-AUTOMAKE_fails --copy --add-missing
-grep '^Makefile\.am:2:.*per-target.*AM_PROG_CC_C_O' stderr
-
-
-cat >Makefile.am <<EOF
-bin_PROGRAMS = wish
-wish_SOURCES = sub/a.c
-EOF
-
-mkdir sub
-mv a.c sub
-
-$AUTOMAKE --copy --add-missing
-
-echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
-AUTOMAKE_fails --copy --add-missing
-grep '^Makefile\.am:2:.*subdir.*AM_PROG_CC_C_O' stderr
-
-:
diff --git a/t/cond11.sh b/t/cond11.sh
index 03c4077..7d729d8 100755
--- a/t/cond11.sh
+++ b/t/cond11.sh
@@ -47,7 +47,6 @@ END

 : > config.guess
 : > config.sub
-: > compile

 $ACLOCAL
 $AUTOCONF
diff --git a/t/cxx-lt-demo.sh b/t/cxx-lt-demo.sh
index 8afc974..3a87cfd 100755
--- a/t/cxx-lt-demo.sh
+++ b/t/cxx-lt-demo.sh
@@ -94,10 +94,12 @@ $AUTOCONF
 $AUTOMAKE --add-missing --copy

 ls -l . ax # For debugging.
-for f in ltmain.sh depcomp config.guess config.sub; do
+# Ideally, the 'compile' script should not be required by C++ compilers.
+# But alas, LT_INIT seems to invoke AC_PROG_CC anyway, and that brings in
+# that script.
+for f in ltmain.sh depcomp compile config.guess config.sub; do
   test -f ax/$f && test ! -h ax/$f || exit 1
 done
-test ! -e ax/compile # Not required by C++ compilers.

 cat > src/main.cc << 'END'
 #include "libfoo.h++"
diff --git a/t/dist-auxdir-many-subdirs.sh b/t/dist-auxdir-many-subdirs.sh
index d49372a..ec1a964 100755
--- a/t/dist-auxdir-many-subdirs.sh
+++ b/t/dist-auxdir-many-subdirs.sh
@@ -63,6 +63,7 @@ END
   required_files='
     install-sh
     missing
+    compile
     depcomp
     py-compile
     test-driver
diff --git a/t/distcom2.sh b/t/distcom2.sh
index 57154d9..dc0cb4d 100755
--- a/t/distcom2.sh
+++ b/t/distcom2.sh
@@ -44,6 +44,8 @@ $ACLOCAL

 for opt in '' --no-force; do

+  rm -f compile depcomp
+
   $AUTOMAKE $opt --add-missing

   test -f compile
diff --git a/t/dollarvar2.sh b/t/dollarvar2.sh
index 7183743..ef2dd06 100755
--- a/t/dollarvar2.sh
+++ b/t/dollarvar2.sh
@@ -65,27 +65,22 @@ grep 'recursive variable expansion' stderr
 cat >Makefile.am <<'EOF'
 x = 1
 bla = $(foo$(x))
-noinst_PROGRAMS = foo
-foo_CPPFLAGS = -Dwhatever
+oops = $(var-with-dash)
 EOF

-echo AC_PROG_CC >> configure.ac
-
-$ACLOCAL --force
-
 # Can disable both 'portability' and 'portability-recursive' warnings.
 $AUTOMAKE -Wno-portability

 # Disabling 'portability-recursive' warnings should not disable
 # 'portability' warnings.
 AUTOMAKE_fails -Wportability -Wno-portability-recursive
-grep AM_PROG_CC_C_O stderr
+grep 'var-with-dash' stderr
 grep 'recursive variable expansion' stderr && exit 1

 # Enabling 'portability-recursive' warnings should not enable
 # all the 'portability' warning.
 AUTOMAKE_fails -Wno-portability -Wportability-recursive
-grep AM_PROG_CC_C_O stderr && exit 1
+grep 'var-with-dash' stderr && exit 1
 grep 'recursive variable expansion' stderr

 :
diff --git a/t/extra-portability.sh b/t/extra-portability.sh
index 94dd799..1ea23ad 100755
--- a/t/extra-portability.sh
+++ b/t/extra-portability.sh
@@ -62,30 +62,29 @@ $AUTOMAKE -Wall -Wno-portability
 # Now, a setup where also a "simple" portability warning is present.
 #

-# Per-target flags require the use of AM_PROG_CC_C_O in configure.ac.
-echo libfoo_a_CPPFLAGS = -Dwhatever >> Makefile.am
+echo 'var = $(foo--bar)' >> Makefile.am

 # Enabling extra-portability enables portability as well ...
 AUTOMAKE_fails -Wextra-portability
-grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'foo--bar' stderr
 grep 'requires.*AM_PROG_AR' stderr
 # ... even if it had been previously disabled.
 AUTOMAKE_fails -Wno-portability -Wextra-portability
-grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'foo--bar' stderr
 grep 'requires.*AM_PROG_AR' stderr

 # Disabling extra-portability leaves portability intact (1).
 AUTOMAKE_fails -Wportability -Wno-extra-portability
-grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'foo--bar' stderr
 grep 'requires.*AM_PROG_AR' stderr && exit 1
 # Disabling extra-portability leaves portability intact (2).
 AUTOMAKE_fails -Wall -Wno-extra-portability
-grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'foo--bar' stderr
 grep 'requires.*AM_PROG_AR' stderr && exit 1

 # Enabling portability does not enable extra-portability.
 AUTOMAKE_fails -Wportability
-grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'foo--bar' stderr
 grep 'requires.*AM_PROG_AR' stderr && exit 1

 # Disabling portability disables extra-portability.
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 63e098d..aac2506 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -30,7 +30,6 @@ t/pm/Version3.pl

 XFAIL_TESTS = \
 t/all.sh \
-t/ccnoco4.sh \
 t/cond17.sh \
 t/gcj6.sh \
 t/override-conditional-2.sh \
@@ -208,7 +207,6 @@ t/canon7.sh \
 t/canon8.sh \
 t/canon-name.sh \
 t/ccnoco.sh \
-t/ccnoco2.sh \
 t/ccnoco3.sh \
 t/ccnoco4.sh \
 t/check.sh \
diff --git a/t/per-target-flags.sh b/t/per-target-flags.sh
index ef19e69..333242f 100755
--- a/t/per-target-flags.sh
+++ b/t/per-target-flags.sh
@@ -55,15 +55,8 @@ cat - libMakefile.am > libMakefile2.am << 'END'
 AUTOMAKE_OPTIONS = no-dependencies
 END

-# Make sure 'compile' is required.
-for m in $makefiles; do
-  AUTOMAKE_fails $m
-  $EGREP " required file.* '(compile|\./compile)'" stderr
-done
-
 makefiles=$(for mkf in $makefiles; do echo $mkf.in; done)

-: > compile
 $AUTOMAKE

 # Sanity check.
diff --git a/t/specflg6.sh b/t/specflg6.sh
index 77d837a..bbc8334 100755
--- a/t/specflg6.sh
+++ b/t/specflg6.sh
@@ -36,8 +36,6 @@ foo_CFLAGS = -DFOO
 foo_SOURCES = foo.c
 END

-: > compile
-
 $ACLOCAL
 $AUTOMAKE

diff --git a/t/subobj.sh b/t/subobj.sh
index 2431184..6e5fd98 100755
--- a/t/subobj.sh
+++ b/t/subobj.sh
@@ -20,6 +20,8 @@

 cat >> configure.ac << 'END'
 AC_PROG_CC
+dnl This should be a no-op now, but still be supported
+dnl without causing warnings.
 AM_PROG_CC_C_O
 END

@@ -30,10 +32,11 @@ wish_SOURCES = generic/a.c generic/b.c
 END

 $ACLOCAL
+rm -f compile
 $AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; exit 1; }
 cat stderr >&2
 # Make sure compile is installed, and that Automake says so.
-grep 'install.*compile' stderr
+grep '^configure\.ac:4:.*install.*compile' stderr
 test -f compile

 grep '^generic/a\.\$(OBJEXT):' Makefile.in
diff --git a/t/subobj4.sh b/t/subobj4.sh
index b1b577d..45d9666 100755
--- a/t/subobj4.sh
+++ b/t/subobj4.sh
@@ -41,7 +41,6 @@ END
 cat > d2/Makefile.am << 'END'
 END

-: > compile
 : > d2/z.c

 $ACLOCAL
-- 
1.8.1.rc3.192.g2d0029e