]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Implement and document Objective C++ support.
authorPeter Breitenlohner <peb@mppmu.mpg.de>
Tue, 21 Jul 2009 20:55:34 +0000 (22:55 +0200)
committerEric Blake <ebb9@byu.net>
Tue, 15 Sep 2009 12:11:05 +0000 (06:11 -0600)
* lib/autoconf/c.m4 (AC_LANG(Objective C++), AC_LANG_OBJCXX)
(AC_LANG_PREPROC(Objective C++), AC_PROG_OBJCXXCPP)
(AC_LANG_COMPILER(Objective C++), AC_PROG_OBJCXX)
(_AC_PROG_OBJCXX_G): New macros.
(_AC_ARG_VAR_CPPFLAGS, _AC_ARG_VAR_LDFLAGS)
(_AC_ARG_VAR_LIBS): Adjusted.
* doc/autoconf.texi (Objective C++ Compiler): New node.
(Preset Output Variables): Document OBJCXXFLAGS.
(Language Choice): Document `Objective C++' language.
* NEWS: Updated.

* tests/local.at (AT_CHECK_ENV): Ignore AC_SUBSTed Objective C++
related variables.

Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/c.m4
tests/local.at

index f7975434c56d3ac5f7b51315b981b6cb15a1902b..50f6fb72903b0e747c2431249f574f021f8f60db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-09-15  Peter Breitenlohner  <peb@mppmu.mpg.de>
+
+       Implement and document Objective C++ support.
+       * lib/autoconf/c.m4 (AC_LANG(Objective C++), AC_LANG_OBJCXX)
+       (AC_LANG_PREPROC(Objective C++), AC_PROG_OBJCXXCPP)
+       (AC_LANG_COMPILER(Objective C++), AC_PROG_OBJCXX)
+       (_AC_PROG_OBJCXX_G): New macros.
+       (_AC_ARG_VAR_CPPFLAGS, _AC_ARG_VAR_LDFLAGS)
+       (_AC_ARG_VAR_LIBS): Adjusted.
+       * doc/autoconf.texi (Objective C++ Compiler): New node.
+       (Preset Output Variables): Document OBJCXXFLAGS.
+       (Language Choice): Document `Objective C++' language.
+       * NEWS: Updated.
+       * tests/local.at (AT_CHECK_ENV): Ignore AC_SUBSTed Objective C++
+       related variables.
+
 2009-09-15  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Work around DJGPP shell function return bug with command substitutions.
diff --git a/NEWS b/NEWS
index 01bc094174c575e95148c10dbbf836c15c4169cd..7720ddc088a12145ab5ac7c2ddda8fbc0649b4af 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ GNU Autoconf NEWS - User visible changes.
    an exception clause so that you may release a configure script
    generated by autoconf under the license of your own program.
 
+** New macros to support Objective C++.
+   AC_PROG_OBJCXX  AC_PROG_OBJCXXCPP
+
 ** The following undocumented autoconf macros, removed in Autoconf 2.64,
    have been reinstated:
    AH_CHECK_HEADERS
index a38db005bbbec643e678213105ea49d5225a7dd9..f09002465fb85b72e927fd383eb093b46ead2086 100644 (file)
@@ -391,6 +391,7 @@ Compilers and Preprocessors
 * C Compiler::                  Checking its characteristics
 * C++ Compiler::                Likewise
 * Objective C Compiler::        Likewise
+* Objective C++ Compiler::      Likewise
 * Erlang Compiler and Interpreter::  Likewise
 * Fortran Compiler::            Likewise
 
@@ -2432,11 +2433,12 @@ needs to be processed by @command{configure} in order to be used.
 @defvar CPPFLAGS
 @evindex CPPFLAGS
 @ovindex CPPFLAGS
-Preprocessor options for the C, C++, and Objective C preprocessors and
-compilers.  If
+Preprocessor options for the C, C++, Objective C, and Objective C++
+preprocessors and compilers.  If
 it is not set in the environment when @command{configure} runs, the default
 value is empty.  @command{configure} uses this variable when preprocessing
-or compiling programs to test for C, C++, and Objective C features.
+or compiling programs to test for C, C++, Objective C, and Objective C++
+features.
 
 This variable's contents should contain options like @option{-I},
 @option{-D}, and @option{-U} that affect only the behavior of the
@@ -2527,7 +2529,7 @@ programs to test for Fortran 77 features.
 Options for the linker.  If it is not set
 in the environment when @command{configure} runs, the default value is empty.
 @command{configure} uses this variable when linking programs to test for
-C, C++, Objective C, and Fortran features.
+C, C++, Objective C, Objective C++, and Fortran features.
 
 This variable's contents should contain options like @option{-s} and
 @option{-L} that affect only the behavior of the linker.  Please see the
@@ -2545,7 +2547,8 @@ Don't use this variable to pass library names
 but some Autoconf macros may prepend extra libraries to this variable if
 those libraries are found and provide necessary functions, see
 @ref{Libraries}.  @command{configure} uses this variable when linking
-programs to test for C, C++, and Fortran features.
+programs to test for C, C++, Objective C, Objective C++, and Fortran
+features.
 @end defvar
 
 @defvar OBJCFLAGS
@@ -2555,6 +2558,13 @@ Debugging and optimization options for the Objective C compiler.  It
 acts like @code{CFLAGS}, but for Objective C instead of C.
 @end defvar
 
+@defvar OBJCXXFLAGS
+@evindex OBJCXXFLAGS
+@ovindex OBJCXXFLAGS
+Debugging and optimization options for the Objective C++ compiler.  It
+acts like @code{CXXFLAGS}, but for Objective C++ instead of C++.
+@end defvar
+
 @defvar builddir
 @ovindex builddir
 Rigorously equal to @samp{.}.  Added for symmetry only.
@@ -6549,6 +6559,7 @@ compiling.
 * C Compiler::                  Checking its characteristics
 * C++ Compiler::                Likewise
 * Objective C Compiler::        Likewise
+* Objective C++ Compiler::      Likewise
 * Erlang Compiler and Interpreter::  Likewise
 * Fortran Compiler::            Likewise
 @end menu
@@ -7252,6 +7263,47 @@ preprocessor.  If @samp{$OBJC -E} doesn't work, @file{/lib/cpp} is used.
 @end defmac
 
 
+@node Objective C++ Compiler
+@subsection Objective C++ Compiler Characteristics
+
+
+@defmac AC_PROG_OBJCXX (@ovar{compiler-search-list})
+@acindex{PROG_OBJCXX}
+@evindex OBJCXX
+@evindex OBJCXXFLAGS
+@ovindex OBJCXX
+@ovindex 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
+variable @code{OBJCXX} to the name of the compiler found.
+
+This macro may, however, be invoked with an optional first argument
+which, if specified, must be a blank-separated list of Objective C++ compilers
+to search for.  This just gives the user an opportunity to specify an
+alternative search list for the Objective C++ compiler.  For example, if you
+didn't like the default order, then you could invoke @code{AC_PROG_OBJCXX}
+like this:
+
+@example
+AC_PROG_OBJCXX([gcc g++ objcc++ objcxx])
+@end example
+
+If using the @acronym{GNU} Objective C++ compiler, set shell variable
+@code{GOBJCXX} to @samp{yes}.  If output variable @code{OBJCXXFLAGS} was not
+already set, set it to @option{-g -O2} for the @acronym{GNU} Objective C++
+compiler (@option{-O2} on systems where @command{gcc} does not accept
+@option{-g}), or @option{-g} for other compilers.
+@end defmac
+
+@defmac AC_PROG_OBJCXXCPP
+@acindex{PROG_OBJCXXCPP}
+@evindex OBJCXXCPP
+@ovindex OBJCXXCPP
+Set output variable @code{OBJCXXCPP} to a command that runs the Objective C++
+preprocessor.  If @samp{$OBJCXX -E} doesn't work, @file{/lib/cpp} is used.
+@end defmac
+
+
 @node Erlang Compiler and Interpreter
 @subsection Erlang Compiler and Interpreter Characteristics
 @cindex Erlang
@@ -8059,6 +8111,12 @@ Do compilation tests using @code{OBJC} and @code{OBJCPP} and use
 extension @file{.m} for test programs.  Use compilation flags:
 @code{CPPFLAGS} with @code{OBJCPP}, and both @code{CPPFLAGS} and
 @code{OBJCFLAGS} with @code{OBJC}.
+
+@item Objective C++
+Do compilation tests using @code{OBJCXX} and @code{OBJCXXCPP} and use
+extension @file{.mm} for test programs.  Use compilation flags:
+@code{CPPFLAGS} with @code{OBJCXXCPP}, and both @code{CPPFLAGS} and
+@code{OBJCXXFLAGS} with @code{OBJCXX}.
 @end table
 @end defmac
 
index 4aae7c75990ff0a06d494ed771c28f5ac5dbe11f..3b7cf365f4c72a4bb5cfc766f138df3d0f55ed7f 100644 (file)
 #      1a. C   2a. C
 #      1b. C++
 #      1c. Objective C
+#      1d. Objective C++
 #
 # 3. Looking for a compiler
 #    And possibly the associated preprocessor.
-#      3a. C   3b. C++   3c. Objective C
+#      3a. C   3b. C++   3c. Objective C   3d. Objective C++
 #
 # 4. Compilers' characteristics.
 #      4a. C
@@ -274,6 +275,23 @@ AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
 
 
 
+## -------------------------------- ##
+## 1d. The Objective C++ language.  ##
+## -------------------------------- ##
+
+
+# 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
+])
+
+
+
 ## -------------------------------------------- ##
 ## 3. Looking for Compilers and Preprocessors.  ##
 ## -------------------------------------------- ##
@@ -286,17 +304,17 @@ AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
 # _AC_ARG_VAR_CPPFLAGS
 # --------------------
 # Document and register CPPFLAGS, which is used by
-# AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP}.
+# AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP, OBJCXX, OBJCXXCPP}.
 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
 [AC_ARG_VAR([CPPFLAGS],
-           [C/C++/Objective C preprocessor flags, e.g. -I<include dir>
+           [(Objective) C/C++ preprocessor flags, e.g. -I<include dir>
             if you have headers in a nonstandard directory <include dir>])])
 
 
 # _AC_ARG_VAR_LDFLAGS
 # -------------------
 # Document and register LDFLAGS, which is used by
-# AC_PROG_{CC, CXX, F77, FC, OBJC}.
+# AC_PROG_{CC, CXX, F77, FC, OBJC, OBJCXX}.
 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
 [AC_ARG_VAR([LDFLAGS],
            [linker flags, e.g. -L<lib dir> if you have libraries in a
@@ -306,7 +324,7 @@ AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
 # _AC_ARG_VAR_LIBS
 # ----------------
 # Document and register LIBS, which is used by
-# AC_PROG_{CC, CXX, F77, FC, OBJS}.
+# AC_PROG_{CC, CXX, F77, FC, OBJC, OBJCXX}.
 AC_DEFUN([_AC_ARG_VAR_LIBS],
 [AC_ARG_VAR([LIBS],
            [libraries to pass to the linker, e.g. -l<library>])])
@@ -925,6 +943,145 @@ fi[]dnl
 
 
 
+# -------------------------------- #
+# 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++ StepStone Objective-C++ compiler (also "standard" name for OBJCXX)
+# objcxx David Stes' POC.  If you installed this, you likely want it.
+# c++    Native C++ compiler (for instance, Apple).
+# CXX    You never know.
+AN_MAKEVAR([OBJCXX],  [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++ CXX])],
+              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
+])# 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
+
+
+
 ## ------------------------------- ##
 ## 4. Compilers' characteristics.  ##
 ## ------------------------------- ##
index dc9e0efaf27e73bce365e388eb40ba8d561720f3..53c1d6fbb1a90b5b181cbbefe4d421e747bd0198 100644 (file)
@@ -296,6 +296,7 @@ if test -f state-env.before && test -f state-env.after; then
       [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
       [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
       [ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
+      [OBJCXX|OBJCXXCPP|OBJCXXFLAGS],
       [OPENMP_CFLAGS],
       [LIBS|LIB@&t@OBJS|LTLIBOBJS|LDFLAGS],
       [INSTALL(_(DATA|PROGRAM|SCRIPT))?],