* lib/autoconf/c.m4 (AC_LANG(Objective C), AC_LANG_OBJC)

(_AC_LANG_ABBREV(Objective C), _AC_LANG_PREFIX(Objective C))
(AC_LANG_SOURCE(Objective C), AC_LANG_PROGRAM(Objective C))
(AC_LANG_CALL(Objective C), AC_LANG_FUNC_LINK_TRY(Objective C))
(AC_LANG_BOOL_COMPILE_TRY(Objective C))
(AC_LANG_INT_SAVE(Objective C), AC_LANG_PREPROC(Objective C))
(AC_PROG_OBJCPP, AC_LANG_COMPILER(Objective C), AC_PROG_OBJC)
(_AC_PROG_OBJC_G): New macros.
(_AC_ARG_VAR_CPPFLAGS): Adjusted.
* doc/autoconf.texi (Objective C Compiler): New node.
(Preset Output Variables): Document OBJCFLAGS.
(Language Choice): Document `Objective C' language.
(Fortran Compiler): Fix typo.
* NEWS: Updated.
Inspired by a patch from David M. Lloyd <dmlloyd@tds.net>.
This commit is contained in:
Ralf Wildenhues 2006-03-20 20:28:55 +00:00
parent 2ea44d31c2
commit 96aa2c31b2
4 changed files with 279 additions and 4 deletions

View File

@ -1,3 +1,21 @@
2006-03-20 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* lib/autoconf/c.m4 (AC_LANG(Objective C), AC_LANG_OBJC)
(_AC_LANG_ABBREV(Objective C), _AC_LANG_PREFIX(Objective C))
(AC_LANG_SOURCE(Objective C), AC_LANG_PROGRAM(Objective C))
(AC_LANG_CALL(Objective C), AC_LANG_FUNC_LINK_TRY(Objective C))
(AC_LANG_BOOL_COMPILE_TRY(Objective C))
(AC_LANG_INT_SAVE(Objective C), AC_LANG_PREPROC(Objective C))
(AC_PROG_OBJCPP, AC_LANG_COMPILER(Objective C), AC_PROG_OBJC)
(_AC_PROG_OBJC_G): New macros.
(_AC_ARG_VAR_CPPFLAGS): Adjusted.
* doc/autoconf.texi (Objective C Compiler): New node.
(Preset Output Variables): Document OBJCFLAGS.
(Language Choice): Document `Objective C' language.
(Fortran Compiler): Fix typo.
* NEWS: Updated.
Inspired by a patch from David M. Lloyd <dmlloyd@tds.net>.
2006-03-20 Stepan Kasal <kasal@ucw.cz>
* doc/autoconf.texi (Default Includes): Fix typo

3
NEWS
View File

@ -87,6 +87,9 @@
New macros for configuring installation of Erlang libraries:
AC_ERLANG_SUBST_INSTALL_LIB_DIR, AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR.
** New macros to support Objective C.
AC_PROG_OBJC, AC_PROG_OBJCPP.
* Major changes in Autoconf 2.59b
Released 2004-08-20, by Paul Eggert.

View File

@ -383,6 +383,7 @@ Compilers and Preprocessors
* Generic Compiler Characteristics:: Language independent tests and features
* C Compiler:: Checking its characteristics
* C++ Compiler:: Likewise
* Objective C Compiler:: Likewise
* Erlang Compiler and Interpreter:: Likewise
* Fortran Compiler:: Likewise
@ -2260,6 +2261,15 @@ those libraries are found and provide necessary functions, see
programs to test for C, C++, and Fortran features.
@end defvar
@defvar OBJCFLAGS
@ovindex OBJCFLAGS
Debugging and optimization options for the Objective C compiler. If it is
not set in the environment when @command{configure} runs, the default value
is set when you call @code{AC_PROG_OBJC} (or empty if you don't).
@command{configure} uses this variable when compiling programs to test for
Objective C features.
@end defvar
@defvar builddir
@ovindex builddir
Rigorously equal to @samp{.}. Added for symmetry only.
@ -5642,6 +5652,7 @@ compiling.
* Generic Compiler Characteristics:: Language independent tests and features
* C Compiler:: Checking its characteristics
* C++ Compiler:: Likewise
* Objective C Compiler:: Likewise
* Erlang Compiler and Interpreter:: Likewise
* Fortran Compiler:: Likewise
@end menu
@ -6118,6 +6129,44 @@ it is not known whether such broken preprocessors exist for C++.
@end defmac
@node Objective C Compiler
@subsection Objective C Compiler Characteristics
@defmac AC_PROG_OBJC (@ovar{compiler-search-list})
@acindex{PROG_OBJC}
@ovindex OBJC
@ovindex OBJCFLAGS
Determine an Objective C compiler to use. If @code{OBJC} is not already
set in the environment, check for Objective C compilers. Set output
variable @code{OBJC} 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_OBJC}
like this:
@example
AC_PROG_OBJC([gcc objcc objc])
@end example
If using the @acronym{GNU} Objective C compiler, set shell variable
@code{GOBJC} to @samp{yes}. If output variable @code{OBJCFLAGS} 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_OBJCCPP
@acindex{PROG_OBJCCPP}
@ovindex OBJCCPP
Set output variable @code{OBJCCPP} to a command that runs the Objective C
preprocessor. If @samp{$OBJC -E} doesn't work, @file{/lib/cpp} is used.
@end defmac
@node Erlang Compiler and Interpreter
@subsection Erlang Compiler and Interpreter Characteristics
@cindex Erlang
@ -6282,7 +6331,7 @@ Determine the linker flags (e.g., @option{-L} and @option{-l}) for the
@dfn{Fortran intrinsic and run-time libraries} that are required to
successfully link a Fortran program or shared library. The output
variable @code{FLIBS} or @code{FCLIBS} is set to these flags (which
should be include after @code{LIBS} when linking).
should be included after @code{LIBS} when linking).
This macro is intended to be used in those situations when it is
necessary to mix, e.g., C++ and Fortran source code in a single
@ -6843,6 +6892,12 @@ compilation flags: @code{FCFLAGS}.
@ovindex ERLCFLAGS
Compile and execute tests using @code{ERLC} and @code{ERL} and use extension
@file{.erl} for test Erlang modules. Use compilation flags: @code{ERLCFLAGS}.
@item Objective C
Do compilation tests using @code{OBJC} and @code{OBJCCPP} 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}.
@end table
@end defmac

View File

@ -116,6 +116,38 @@ m4_define([_AC_LANG_PREFIX(C++)], [CXX])
# ------------------------------ #
# 1d. The Objective C language. #
# ------------------------------ #
# AC_LANG(Objective C)
# --------------------
m4_define([AC_LANG(Objective C)],
[ac_ext=m
ac_cpp='$OBJCPP $CPPFLAGS'
ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
ac_compiler_gnu=$ac_cv_objc_compiler_gnu
])
# AC_LANG_OBJC
# ------------
AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
# _AC_LANG_ABBREV(Objective C)
# ----------------------------
m4_define([_AC_LANG_ABBREV(Objective C)], [objc])
# _AC_LANG_PREFIX(Objective C)
# ----------------------------
m4_define([_AC_LANG_PREFIX(Objective C)], [OBJC])
## ---------------------- ##
## 2.Producing programs. ##
## ---------------------- ##
@ -300,6 +332,41 @@ m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
# ------------------------- #
# 2d. Objective C sources. #
# ------------------------- #
# AC_LANG_SOURCE(Objective C)(BODY)
# ---------------------------------
m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(Objective C)])
# AC_LANG_PROGRAM(Objective C)([PROLOGUE], [BODY])
# ------------------------------------------------
m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(Objective C)])
# AC_LANG_CALL(Objective C)(PROLOGUE, FUNCTION)
# ---------------------------------------------
m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(Objective C)])
# AC_LANG_FUNC_LINK_TRY(Objective C)(FUNCTION)
# --------------------------------------------
m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(Objective C)])
# AC_LANG_BOOL_COMPILE_TRY(Objective C)(PROLOGUE, EXPRESSION)
# -----------------------------------------------------------
m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(Objective C)])
# AC_LANG_INT_SAVE(Objective C)(PROLOGUE, EXPRESSION)
# ---------------------------------------------------
m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(Objective C)])
## -------------------------------------------- ##
## 3. Looking for Compilers and Preprocessors. ##
## -------------------------------------------- ##
@ -312,11 +379,11 @@ m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
# _AC_ARG_VAR_CPPFLAGS
# --------------------
# Document and register CPPFLAGS, which is used by
# AC_PROG_{CC, CPP, CXX, CXXCPP}.
# AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP}.
AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
[AC_ARG_VAR([CPPFLAGS],
[C/C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>])])
[C/C++/Objective C preprocessor flags, e.g. -I<include dir>
if you have headers in a nonstandard directory <include dir>])])
# _AC_ARG_VAR_LDFLAGS
@ -805,6 +872,138 @@ fi
])# _AC_PROG_CXX_EXIT_DECLARATION
# ------------------------------ #
# 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_OBJCPP])])
# AC_PROG_OBJCPP
# --------------
# Find a working Objective C preprocessor.
AC_DEFUN([AC_PROG_OBJCPP],
[AC_REQUIRE([AC_PROG_OBJC])dnl
AC_ARG_VAR([OBJCPP], [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 "$OBJCPP"; then
AC_CACHE_VAL(ac_cv_prog_OBJCPP,
[dnl
# Double quotes because OBJCPP needs to be expanded
for OBJCPP in "$OBJC -E" "/lib/cpp"
do
_AC_PROG_PREPROC_WORKS_IFELSE([break])
done
ac_cv_prog_OBJCPP=$OBJCPP
])dnl
OBJCPP=$ac_cv_prog_OBJCPP
else
ac_cv_prog_OBJCPP=$OBJCPP
fi
AC_MSG_RESULT([$OBJCPP])
_AC_PROG_PREPROC_WORKS_IFELSE([],
[AC_MSG_FAILURE([Objective C preprocessor "$OBJCPP" fails sanity check])])
AC_SUBST(OBJCPP)dnl
AC_LANG_POP(Objective C)dnl
])# AC_PROG_OBJCPP
# 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_OBJC])])
# AC_PROG_OBJC([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.
# objcc StepStone Objective-C compiler (also "standard" name for OBJC)
# objc David Stes' POC. If you installed this, you likely want it.
# cc Native C compiler (for instance, Apple).
# CC You never know.
AN_MAKEVAR([OBJC], [AC_PROG_OBJC])
AN_PROGRAM([objcc], [AC_PROG_OBJC])
AN_PROGRAM([objc], [AC_PROG_OBJC])
AC_DEFUN([AC_PROG_OBJC],
[AC_LANG_PUSH(Objective C)dnl
AC_ARG_VAR([OBJC], [Objective C compiler command])dnl
AC_ARG_VAR([OBJCFLAGS], [Objective C compiler flags])dnl
_AC_ARG_VAR_LDFLAGS()dnl
_AC_ARG_VAR_CPPFLAGS()dnl
_AC_ARG_VAR_PRECIOUS([OBJC])dnl
AC_CHECK_TOOLS(OBJC,
[m4_default([$1], [gcc objcc objc cc CC])],
gcc)
# Provide some information about the compiler.
_AS_ECHO_LOG([checking for _AC_LANG compiler version])
ac_compiler=`set X $ac_compile; echo $[2]`
_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
_AC_LANG_COMPILER_GNU
GOBJC=`test $ac_compiler_gnu = yes && echo yes`
_AC_PROG_OBJC_G
AC_LANG_POP(Objective C)dnl
])# AC_PROG_OBJC
# _AC_PROG_OBJC_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_OBJC_G],
[ac_test_OBJCFLAGS=${OBJCFLAGS+set}
ac_save_OBJCFLAGS=$OBJCFLAGS
AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
[ac_save_objc_werror_flag=$ac_objc_werror_flag
ac_objc_werror_flag=yes
ac_cv_prog_objc_g=no
OBJCFLAGS="-g"
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[ac_cv_prog_objc_g=yes],
[OBJCFLAGS=""
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[],
[ac_objc_werror_flag=$ac_save_objc_werror_flag
OBJCFLAGS="-g"
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[ac_cv_prog_objc_g=yes])])])
ac_objc_werror_flag=$ac_save_objc_werror_flag])
if test "$ac_test_OBJCFLAGS" = set; then
OBJCFLAGS=$ac_save_OBJCFLAGS
elif test $ac_cv_prog_objc_g = yes; then
if test "$GOBJC" = yes; then
OBJCFLAGS="-g -O2"
else
OBJCFLAGS="-g"
fi
else
if test "$GOBJC" = yes; then
OBJCFLAGS="-O2"
else
OBJCFLAGS=
fi
fi[]dnl
])# _AC_PROG_OBJC_G