On Tue, 15 Sep 2009, Ralf Wildenhues wrote:

Would you be so nice as to respin and simplify the patch under the
assumption that AC_PROG_OBJCXX exists?  I think it should be sufficient
to just require new enough Autoconf for this to work, that way we can
avoid all the duplication and so on.  This patch is targets 1.12 rather
than 1.11.1 anyway.  Maybe it can even omit the objcxx.m4 file
completely?

Hi Ralf,

attached is a new version of the patch. As I said earlier, I think we need
the m4/objcxx.m4 file in order to define AC_PROG_OBJCXX & Co.  The
definitions are exactly as in Autoconf-git, thus once Autoconf-2.65 is
released and can be required as prerequisite that file can be dropped.
At the same time the documentation for AC_PROG_OBJCXX in the manual should
go away and the reference to AC_PROG_OBJCXX changed accordingly -- unless
you prefer to do that right now.

I hope that Autoconf-2.65 will come before Automake-1.12 is ready.

I have just tested the patch with both Autoconf-2.64 (objcxx.m4 is required)
and Autoconf-2.64.56-dfc96 (git as of today, objcxx.m4 is not required).
The obcjxx tests pass but there are some mysterious failures (plus some
others that are caused locally and are understood):
for 2.64: aclocal9, acloca10, acloca14, nodef, python11
for 2.64.56-dfc96: aclocal9, acloca10, acloca18, missing4, nodef, python11
The tests were done on a pretty fast machine, my suspicion is that a sleep
might be required in some of these tests.

The other thing I'd like to see either in this patch or in a followup
one is your play-1.1 test rewritten as an Automake testsuite addition,
so that we have one full build test (including distcheck).  (I can do
that if you don't want to.)

Here I am somewhat unsure what exactly needs to be done for a testsuite
case.  If that is easy to explain I'll do it, otherwise I should better
leave it to you (and please feel free to add/modify copyright notices as
apropriate).

In any case, that maybe should be based on a newer version play-1.2 that
also includes a libtool library.

Regards
Peter Breitenlohner <p...@mppmu.mpg.de>
From ec77c2ee94537892f6123754455ecf38aec80523 Mon Sep 17 00:00:00 2001
From: Peter Breitenlohner <p...@mppmu.mpg.de>
Date: Fri, 2 Oct 2009 23:41:40 +0200
Subject: [PATCH] Support for Objective C++

* m4/objcxx.m4: New Autoconf macros for Objective C++ language.
* m4/Makefile.am: Adjust.
* configure.ac: Require Autoconf 2.64 or better.

* automake.in: Register new language.
(lang_objcxx_rewrite): New subroutine.
(resolve_linker): Add OBJCXXLINK.
(%_am_macro_for_cond): Add am__fastdepOBJCXX and AC_PROG_OBJCXX.
* (%-ac_macro_for_var): Add OBJCXX and OBJCXXFLAGS.
* m4/depend.m4 (_AM_DEPENDENCIES): Add OBJCXX.
* m4/init.m4 (AM_INIT_AUTOMAKE): Add AC_PROG_OBJCXX hook.

* tests/ext.test, tests/nodep2.test: Adjust.
* tests/objcxx.test, tests.objcxx2.test: New tests.
* tests/Makefile.am: Adjust.

* doc/automake.texi (Objective C++ Support): New node.
(Public Macros): Document AC_PROG_OBJCXX, OBJCXX, and OBJCXXFLAGS.
(How the Linker is Chosen, Support for Other Languages): Adjust.
* NEWS: Announce and require Autoconf 2.64 or better.

Signed-off-by: Peter Breitenlohner <p...@mppmu.mpg.de>
---
 NEWS                     |   10 +++
 automake.in              |   29 +++++++-
 configure.ac             |    2 +
 doc/automake.texi        |   63 +++++++++++++++-
 lib/Automake/Variable.pm |    2 +
 m4/Makefile.am           |    1 +
 m4/depend.m4             |    5 +-
 m4/init.m4               |    6 +-
 m4/objcxx.m4             |  183 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am        |    2 +
 tests/ext.test           |    7 +-
 tests/nodep2.test        |    6 +-
 tests/objcxx.test        |   34 +++++++++
 tests/objcxx2.test       |   33 ++++++++
 14 files changed, 370 insertions(+), 13 deletions(-)
 create mode 100644 m4/objcxx.m4
 create mode 100755 tests/objcxx.test
 create mode 100755 tests/objcxx2.test

diff --git a/NEWS b/NEWS
index 26a8b31..fb98c4f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,19 @@
 New in 1.11a:
 
+* Version requirements:
+
+  - Autoconf 2.64 or greater is required.
+
 * Changes to automake:
 
   - automake now generates silenced rules for texinfo outputs.
 
+* Languages changes:
+
+  - New support for Objective C++:
+    - AC_PROG_OBJCXX looks for a ObjC++ compiler.
+    - A new section of the manual documents the support.
+
 Bugs fixed in 1.11a:
 
 * Bugs introduced by 1.11:
diff --git a/automake.in b/automake.in
index 25ba40d..b7d9e75 100755
--- a/automake.in
+++ b/automake.in
@@ -783,6 +783,24 @@ register_language ('name' => 'objc',
                   'pure' => 1,
                   'extensions' => ['.m']);
 
+# Objective C++.
+register_language ('name' => 'objcxx',
+                  'Name' => 'Objective C++',
+                  'config_vars' => ['OBJCXX'],
+                  'linker' => 'OBJCXXLINK',
+                  'link' => '$(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) 
$(AM_LDFLAGS) $(LDFLAGS) -o $@',
+                  'autodep' => 'OBJCXX',
+                  'flags' => ['OBJCXXFLAGS', 'CPPFLAGS'],
+                  'compile' => '$(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS)',
+                  'ccer' => 'OBJCXX',
+                  'compiler' => 'OBJCXXCOMPILE',
+                  'compile_flag' => '-c',
+                  'output_flag' => '-o',
+                  'lder' => 'OBJCXXLD',
+                  'ld' => '$(OBJCXX)',
+                  'pure' => 1,
+                  'extensions' => ['.mm']);
+
 # Unified Parallel C.
 register_language ('name' => 'upc',
                   'Name' => 'Unified Parallel C',
@@ -5883,6 +5901,12 @@ sub lang_objc_rewrite
     return &lang_sub_obj;
 }
 
+# Rewrite a single Objective C++ file.
+sub lang_objcxx_rewrite
+{
+    return &lang_sub_obj;
+}
+
 # Rewrite a single Unified Parallel C file.
 sub lang_upc_rewrite
 {
@@ -6160,7 +6184,7 @@ sub resolve_linker
 {
     my (%linkers) = @_;
 
-    foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
+    foreach my $l (qw(GCJLINK OBJCXXLINK CXXLINK F77LINK FCLINK OBJCLINK 
UPCLINK))
     {
        return $l if defined $linkers{$l};
     }
@@ -6350,13 +6374,14 @@ sub make_conditional_string ($$)
 my %_am_macro_for_cond =
   (
   AMDEP => "one of the compiler tests\n"
-          . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC,\n"
+          . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,\n"
           . "    AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
   am__fastdepCC => 'AC_PROG_CC',
   am__fastdepCCAS => 'AM_PROG_AS',
   am__fastdepCXX => 'AC_PROG_CXX',
   am__fastdepGCJ => 'AM_PROG_GCJ',
   am__fastdepOBJC => 'AC_PROG_OBJC',
+  am__fastdepOBJCXX => 'AC_PROG_OBJCXX',
   am__fastdepUPC => 'AM_PROG_UPC'
   );
 
diff --git a/configure.ac b/configure.ac
index 9f8eabe..0be046d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+dnl Require Autoconf 2.64 for quoting names of traced macros.
+AC_PREREQ(2.64)
 AC_INIT([GNU Automake], [1.11a], [bug-autom...@gnu.org])
 
 AC_CONFIG_SRCDIR(automake.in)
diff --git a/doc/automake.texi b/doc/automake.texi
index f6633d8..2faaae2 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -219,6 +219,7 @@ Building Programs and Libraries
 * Yacc and Lex::                Yacc and Lex support
 * C++ Support::                 Compiling C++ sources
 * Objective C Support::         Compiling Objective C sources
+* Objective C++ Support::       Compiling Objective C++ sources
 * Unified Parallel C Support::  Compiling Unified Parallel C sources
 * Assembly Support::            Compiling assembly sources
 * Fortran 77 Support::          Compiling Fortran 77 sources
@@ -2906,6 +2907,10 @@ Programs, , Particular Program Checks, autoconf, The 
Autoconf Manual}.
 This is required if any Objective C source is included.  @xref{Particular
 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
 
+...@item AC_PROG_OBJCXX
+This is required if any Objective C++ source is included.  @xref{Public
+Macros}.
+
 @item AC_PROG_F77
 This is required if any Fortran 77 source is included.  This macro is
 distributed with Autoconf version 2.13 and later.  @xref{Particular
@@ -3876,6 +3881,15 @@ Program Checks, autoconf, The Autoconf Manual}), but 
uses the
 @command{missing} script on systems that do not have @command{lex}.
 HP-UX 10 is one such system.
 
+...@item AC_PROG_OBJCXX([...@var{compiler-search-list}]
+...@acindex AC_PROG_OBJCXX
+...@vindex OBJCXX
+...@vindex OBJCXXFLAGS
+Determine an Objective C++ compiler to use.  If @code{OBJCXX} is not already
+set in the environment, check for Objective C++ compilers.  Set output
+variables @code{OBJCXX} and @code{OBJCXXFLAGS}. The default
+...@var{compiler-search-list} is @samp{g++ objc++ objcxx c++}.
+
 @item AM_PROG_GCJ
 @acindex AM_PROG_GCJ
 @vindex GCJ
@@ -4535,6 +4549,7 @@ to build programs and libraries.
 * Yacc and Lex::                Yacc and Lex support
 * C++ Support::                 Compiling C++ sources
 * Objective C Support::         Compiling Objective C sources
+* Objective C++ Support::       Compiling Objective C++ sources
 * Unified Parallel C Support::  Compiling Unified Parallel C sources
 * Assembly Support::            Compiling assembly sources
 * Fortran 77 Support::          Compiling Fortran 77 sources
@@ -5628,6 +5643,7 @@ maude_LINK = $(CCLD) -magic -o $@@
 @itemx maude_GCJFLAGS
 @itemx maude_LFLAGS
 @itemx maude_OBJCFLAGS
+...@itemx maude_OBJCXXFLAGS
 @itemx maude_RFLAGS
 @itemx maude_UPCFLAGS
 @itemx maude_YFLAGS
@@ -5645,6 +5661,7 @@ Automake.  These @dfn{per-target compilation flags} are
 @samp{_GCJFLAGS},
 @samp{_LFLAGS},
 @samp{_OBJCFLAGS},
+...@samp{_objcxxflags},
 @samp{_RFLAGS},
 @samp{_UPCFLAGS}, and
 @samp{_YFLAGS}.
@@ -6197,6 +6214,40 @@ The command used to actually link an Objective C program.
 @end vtable
 
 
+...@node Objective C++ Support
+...@section Objective C++ Support
+
+...@cindex Objective C++ support
+...@cindex Support for Objective C++
+
+Automake includes some support for Objective C++.
+
+Any package including Objective C++ code must define the output variable
+...@code{objcxx} in @file{configure.ac}; the simplest way to do this is to
+use the @code{AC_PROG_OBJCXX} macro (@pxref{Public Macros}).
+
+A few additional variables are defined when an Objective C++ source file
+is seen:
+
+...@vtable @code
+...@item OBJCXX
+The name of the Objective C++ compiler.
+
+...@item OBJCXXFLAGS
+Any flags to pass to the Objective C++ compiler.
+
+...@item AM_OBJCXXFLAGS
+The maintainer's variant of @code{OBJCXXFLAGS}.
+
+...@item OBJCXXCOMPILE
+The command used to actually compile an Objective C++ source file.  The
+file name is appended to form the complete command line.
+
+...@item OBJCXXLINK
+The command used to actually link an Objective C++ program.
+...@end vtable
+
+
 @node Unified Parallel C Support
 @section Unified Parallel C Support
 
@@ -6463,6 +6514,9 @@ parentheses are the variables containing the link 
command.)
 @vindex GCJLINK
 Native Java (@code{GCJLINK})
 @item
+...@vindex OBJCXXLINK
+Objective C++ (@code{OBJCXXLINK})
+...@item
 @vindex CXXLINK
 C++ (@code{CXXLINK})
 @item
@@ -6664,7 +6718,8 @@ source file.
 @section Support for Other Languages
 
 Automake currently only includes full support for C, C++ (@pxref{C++
-Support}), Objective C (@pxref{Objective C Support}), Fortran 77
+Support}), Objective C (@pxref{Objective C Support}), Objective C++
+(@pxref{Objective C++ Support}), Fortran 77
 (@pxref{Fortran 77 Support}), Fortran 9x (@pxref{Fortran 9x Support}),
 and Java (@pxref{Java Support}).  There is only rudimentary support for other
 languages, support for which will be improved based on user demand.
@@ -10896,6 +10951,7 @@ flags, not appended.
 @cindex @code{AM_LFLAGS} and @code{LFLAGS}
 @cindex @code{AM_LIBTOOLFLAGS} and @code{LIBTOOLFLAGS}
 @cindex @code{AM_OBJCFLAGS} and @code{OBJCFLAGS}
+...@cindex @code{AM_OBJCXXFLAGS} and @code{OBJCXXFLAGS}
 @cindex @code{AM_RFLAGS} and @code{RFLAGS}
 @cindex @code{AM_UPCFLAGS} and @code{UPCFLAGS}
 @cindex @code{AM_YFLAGS} and @code{YFLAGS}
@@ -10910,6 +10966,7 @@ flags, not appended.
 @cindex @code{LFLAGS} and @code{AM_LFLAGS}
 @cindex @code{LIBTOOLFLAGS} and @code{AM_LIBTOOLFLAGS}
 @cindex @code{OBJCFLAGS} and @code{AM_OBJCFLAGS}
+...@cindex @code{OBJCXXFLAGS} and @code{AM_OBJCXXFLAGS}
 @cindex @code{RFLAGS} and @code{AM_RFLAGS}
 @cindex @code{UPCFLAGS} and @code{AM_UPCFLAGS}
 @cindex @code{YFLAGS} and @code{AM_YFLAGS}
@@ -10919,8 +10976,8 @@ mostly discuss @code{CPPFLAGS} in our examples, but 
actually the
 answer holds for all the compile flags used in Automake:
 @code{CCASFLAGS}, @code{CFLAGS}, @code{CPPFLAGS}, @code{CXXFLAGS},
 @code{FCFLAGS}, @code{FFLAGS}, @code{GCJFLAGS}, @code{LDFLAGS},
-...@code{lflags}, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS}, @code{RFLAGS},
-...@code{upcflags}, and @code{YFLAGS}.
+...@code{lflags}, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS},
+...@code{objcxxflags}, @code{RFLAGS}, @code{UPCFLAGS}, and @code{YFLAGS}.
 
 @code{CPPFLAGS}, @code{AM_CPPFLAGS}, and @code{mumble_CPPFLAGS} are
 three variables that can be used to pass flags to the C preprocessor
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 1e24bb2..654fa5d 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -185,6 +185,8 @@ my %_ac_macro_for_var =
    FCFLAGS => 'AC_PROG_FC',
    OBJC => 'AC_PROG_OBJC',
    OBJCFLAGS => 'AC_PROG_OBJC',
+   OBJCXX => 'AC_PROG_OBJCXX',
+   OBJCXXFLAGS => 'AC_PROG_OBJCXX',
    RANLIB => 'AC_PROG_RANLIB',
    UPC => 'AM_PROG_UPC',
    UPCFLAGS => 'AM_PROG_UPC',
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 3ea8840..0e8aa2a 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -43,6 +43,7 @@ minuso.m4 \
 missing.m4 \
 mkdirp.m4 \
 multi.m4 \
+objcxx.m4 \
 obsol-gt.m4 \
 obsol-lt.m4 \
 obsolete.m4 \
diff --git a/m4/depend.m4 b/m4/depend.m4
index efe8643..431c638 100644
--- a/m4/depend.m4
+++ b/m4/depend.m4
@@ -6,7 +6,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 10
+# serial 11
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -18,7 +18,7 @@
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
 # We try a few techniques and use that to set a single cache variable.
 #
 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
@@ -34,6 +34,7 @@ AC_REQUIRE([AM_DEP_TRACK])dnl
 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], OBJCXX, [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
        [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
                    [depcc="$$1"   am_compiler_list=])
diff --git a/m4/init.m4 b/m4/init.m4
index 365c9ac..537b5e1 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -7,7 +7,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 16
+# serial 17
 
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
@@ -99,6 +99,10 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
                  [_AM_DEPENDENCIES(OBJC)],
                  [define([AC_PROG_OBJC],
                          defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+                 [_AM_DEPENDENCIES(OBJCXX)],
+                 [m4_ifdef([AC_PROG_OBJCXX], [define([AC_PROG_OBJCXX],
+                         
defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES(OBJCXX)])])])dnl
 ])
 _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
 dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
diff --git a/m4/objcxx.m4 b/m4/objcxx.m4
new file mode 100644
index 0000000..42f2ae4
--- /dev/null
+++ b/m4/objcxx.m4
@@ -0,0 +1,183 @@
+# Autoconf support for the Objective C++ language.
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+## -------------------------------- ##
+## 1d. The Objective C++ language.  ##
+## -------------------------------- ##
+
+
+# In case Autoconf has already defined the Objective C++ language
+# we must undefine these before defining them again (via m4_copy).
+m4_ifdef([AC_PROG_OBJCXX],
+[
+m4_undefine([AC_LANG_CONFTEST(Objective C++)])
+m4_undefine([AC_LANG_SOURCE(Objective C++)])
+m4_undefine([AC_LANG_PROGRAM(Objective C++)])
+m4_undefine([AC_LANG_CALL(Objective C++)])
+m4_undefine([AC_LANG_FUNC_LINK_TRY(Objective C++)])
+m4_undefine([AC_LANG_BOOL_COMPILE_TRY(Objective C++)])
+m4_undefine([AC_LANG_INT_SAVE(Objective C++)])
+m4_undefine([_AC_LANG_IO_PROGRAM(Objective C++)])
+m4_undefine([_AC_LANG_NULL_PROGRAM(Objective C++)])
+])
+
+# AC_LANG(Objective C++)
+# ----------------------
+AC_LANG_DEFINE([Objective C++], [objcxx], [OBJCXX], [C++],
+[ac_ext=mm
+ac_cpp='$OBJCXXCPP $CPPFLAGS'
+ac_compile='$OBJCXX -c $OBJCXXFLAGS $CPPFLAGS conftest.$ac_ext 
>&AS_MESSAGE_LOG_FD'
+ac_link='$OBJCXX -o conftest$ac_exeext $OBJCXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compiler_gnu=$ac_cv_objcxx_compiler_gnu
+])
+
+
+
+# -------------------------------- #
+# 3d. The Objective C++ compiler.  #
+# -------------------------------- #
+
+
+# AC_LANG_PREPROC(Objective C++)
+# ------------------------------
+# Find the Objective C++ preprocessor.  Must be AC_DEFUN'd to be 
AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_PREPROC(Objective C++)],
+[AC_REQUIRE([AC_PROG_OBJCXXCPP])])
+
+
+# AC_PROG_OBJCXXCPP
+# -----------------
+# Find a working Objective C++ preprocessor.
+AC_DEFUN([AC_PROG_OBJCXXCPP],
+[AC_REQUIRE([AC_PROG_OBJCXX])dnl
+AC_ARG_VAR([OBJCXXCPP],   [Objective C++ preprocessor])dnl
+_AC_ARG_VAR_CPPFLAGS()dnl
+AC_LANG_PUSH(Objective C++)dnl
+AC_MSG_CHECKING([how to run the Objective C++ preprocessor])
+if test -z "$OBJCXXCPP"; then
+  AC_CACHE_VAL(ac_cv_prog_OBJCXXCPP,
+  [dnl
+    # Double quotes because OBJCXXCPP needs to be expanded
+    for OBJCXXCPP in "$OBJCXX -E" "/lib/cpp"
+    do
+      _AC_PROG_PREPROC_WORKS_IFELSE([break])
+    done
+    ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
+  ])dnl
+  OBJCXXCPP=$ac_cv_prog_OBJCXXCPP
+else
+  ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
+fi
+AC_MSG_RESULT([$OBJCXXCPP])
+_AC_PROG_PREPROC_WORKS_IFELSE([],
+         [AC_MSG_FAILURE([Objective C++ preprocessor "$OBJCXXCPP" fails sanity 
check])])
+AC_SUBST(OBJCXXCPP)dnl
+AC_LANG_POP(Objective C++)dnl
+])# AC_PROG_OBJCXXCPP
+
+
+# AC_LANG_COMPILER(Objective C++)
+# -------------------------------
+# Find the Objective C++ compiler.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(Objective C++)],
+[AC_REQUIRE([AC_PROG_OBJCXX])])
+
+
+
+# AC_PROG_OBJCXX([LIST-OF-COMPILERS])
+# ---------------------------------
+# LIST-OF-COMPILERS is a space separated list of Objective C++ compilers to
+# search for (if not specified, a default list is used).  This just gives
+# the user an opportunity to specify an alternative search list for the
+# Objective C++ compiler.
+# FIXME: this list is pure guesswork
+# objc++ maybe "standard" name for OBJCXX.
+# objcxx maybe "alternate" name.
+# c++    Native C++ compiler (for instance, Apple).
+AN_MAKEVAR([OBJCXX],  [AC_PROG_OBJCXX])
+AN_PROGRAM([objc++],  [AC_PROG_OBJCXX])
+AN_PROGRAM([objcxx],  [AC_PROG_OBJCXX])
+AC_DEFUN([AC_PROG_OBJCXX],
+[AC_LANG_PUSH(Objective C++)dnl
+AC_ARG_VAR([OBJCXX],      [Objective C++ compiler command])dnl
+AC_ARG_VAR([OBJCXXFLAGS], [Objective C++ compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+_AC_ARG_VAR_LIBS()dnl
+_AC_ARG_VAR_CPPFLAGS()dnl
+_AC_ARG_VAR_PRECIOUS([OBJCXX])dnl
+AC_CHECK_TOOLS(OBJCXX,
+              [m4_default([$1], [g++ objc++ objcxx c++])],
+              g++)
+# Provide some information about the compiler.
+_AS_ECHO_LOG([checking for _AC_LANG compiler version])
+set X $ac_compile
+ac_compiler=$[2]
+for ac_option in --version -v -V -qversion; do
+  _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
+done
+
+m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
+_AC_LANG_COMPILER_GNU
+if test $ac_compiler_gnu = yes; then
+  GOBJCXX=yes
+else
+  GOBJCXX=
+fi
+_AC_PROG_OBJCXX_G
+AC_LANG_POP(Objective C++)dnl
+_AM_IF_OPTION([no-dependencies],,
+              [_AM_DEPENDENCIES(OBJCXX)])dnl
+])# AC_PROG_OBJCXX
+
+
+# _AC_PROG_OBJCXX_G
+# -----------------
+# Check whether -g works, even if OBJCFLAGS is set, in case the package
+# plays around with OBJCFLAGS (such as to build both debugging and
+# normal versions of a library), tasteless as that idea is.
+# Don't consider -g to work if it generates warnings when plain compiles don't.
+m4_define([_AC_PROG_OBJCXX_G],
+[ac_test_OBJCXXFLAGS=${OBJCXXFLAGS+set}
+ac_save_OBJCXXFLAGS=$OBJCXXFLAGS
+AC_CACHE_CHECK(whether $OBJCXX accepts -g, ac_cv_prog_objcxx_g,
+  [ac_save_objcxx_werror_flag=$ac_objcxx_werror_flag
+   ac_objcxx_werror_flag=yes
+   ac_cv_prog_objcxx_g=no
+   OBJCXXFLAGS="-g"
+   _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+     [ac_cv_prog_objcxx_g=yes],
+     [OBJCXXFLAGS=""
+      _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+       [],
+       [ac_objcxx_werror_flag=$ac_save_objcxx_werror_flag
+        OBJCXXFLAGS="-g"
+        _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+          [ac_cv_prog_objcxx_g=yes])])])
+   ac_objcxx_werror_flag=$ac_save_objcx_werror_flag])
+if test "$ac_test_OBJCXXFLAGS" = set; then
+  OBJCXXFLAGS=$ac_save_OBJCXXFLAGS
+elif test $ac_cv_prog_objcxx_g = yes; then
+  if test "$GOBJCXX" = yes; then
+    OBJCXXFLAGS="-g -O2"
+  else
+    OBJCXXFLAGS="-g"
+  fi
+else
+  if test "$GOBJCXX" = yes; then
+    OBJCXXFLAGS="-O2"
+  else
+    OBJCXXFLAGS=
+  fi
+fi[]dnl
+])# _AC_PROG_OBJCXX_G
+
+
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7f6910b..75143d9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -474,6 +474,8 @@ notrans.test \
 number.test \
 objc.test \
 objc2.test \
+objcxx.test \
+objcxx2.test \
 obsolete.test \
 order.test \
 outdir.test \
diff --git a/tests/ext.test b/tests/ext.test
index 929afd5..8f70883 100755
--- a/tests/ext.test
+++ b/tests/ext.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2006  Free Software Foundation, Inc.
+# Copyright (C) 1999, 2001, 2002, 2006, 2009  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
@@ -22,18 +22,19 @@ cat >> configure.in << 'END'
 AC_PROG_F77
 AC_PROG_FC
 AC_PROG_OBJC
+AC_PROG_OBJCXX
 AM_PROG_UPC
 END
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo
-foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.upc
+foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.mm 11.upc
 END
 
 $ACLOCAL || Exit 1
 $AUTOMAKE || Exit 1
 
-for ext in f for f90 f95 F F90 F95 r m upc
+for ext in f for f90 f95 F F90 F95 r m mm upc
 do
    grep "^$ext\.o:" Makefile.in && Exit 1
 done
diff --git a/tests/nodep2.test b/tests/nodep2.test
index 53bcaad..e36fb59 100755
--- a/tests/nodep2.test
+++ b/tests/nodep2.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2006  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2009  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
@@ -22,7 +22,7 @@ set -e
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo
-foo_SOURCES = a.c b.cpp c.m d.S e.java f.upc
+foo_SOURCES = a.c b.cpp c.m cxx.mm d.S e.java f.upc
 END
 
 cat > configure.in << 'END'
@@ -32,6 +32,7 @@ AC_CONFIG_FILES([Makefile])
 AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_OBJC
+AC_PROG_OBJCXX
 AM_PROG_AS
 AM_PROG_GCJ
 AM_PROG_UPC
@@ -41,6 +42,7 @@ END
 : > a.c
 : > b.cpp
 : > c.m
+: > cxx.mm
 : > d.S
 : > e.java
 : > f.upc
diff --git a/tests/objcxx.test b/tests/objcxx.test
new file mode 100755
index 0000000..2dafeb5
--- /dev/null
+++ b/tests/objcxx.test
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2009  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 that `.mm' extension works.
+# From Ralf Corsepius (for C++).
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_OBJCXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.mm
+END
+
+$ACLOCAL || Exit 1
+$AUTOMAKE || Exit 1
+
+grep '^\.SUFFIXES:.*\.mm' Makefile.in
diff --git a/tests/objcxx2.test b/tests/objcxx2.test
new file mode 100755
index 0000000..558db21
--- /dev/null
+++ b/tests/objcxx2.test
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2009  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 that Automake suggests using AC_PROG_OBJCXX if Objective C++
+# sources are used.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_PROG_CC >>configure.in
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.mm
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AC_PROG_OBJCXX stderr
-- 
1.6.4

Reply via email to