This patch adds AC_PROG_OBJC and friends. It's pretty similar to the C++
macroage.
Next I need to check whether -lobjc is required to compile working
Objective C. Is it correct to put this in OBJC_FLAGS or should I set up a
separate flags variable just for this purpose?
If it affects anything, there will eventually be other flags to enable
Objective C-specific features like GC that I was also planning on putting
into OBJC_FLAGS.
- D
<[EMAIL PROTECTED]>
? c.m4.patch
Index: c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.170
diff -u -r1.170 c.m4
--- c.m4 31 Oct 2002 08:27:15 -0000 1.170
+++ c.m4 31 Oct 2002 22:48:58 -0000
@@ -103,7 +103,27 @@
m4_define([_AC_LANG_ABBREV(C++)], [cxx])
+# ------------------------------ #
+# 1d. The Objective C language. #
+# ------------------------------ #
+# AC_LANG(Objective C)
+# --------------------
+m4_define([AC_LANG(Objective C)],
+[ac_ext=m
+ac_cpp='$CPP $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_c_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])
## ---------------------- ##
@@ -266,6 +286,40 @@
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. ##
@@ -282,7 +336,7 @@
# AC_PROG_{CC, CPP, CXX, CXXCPP}.
AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
[AC_ARG_VAR([CPPFLAGS],
- [C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ [C/C++/Objective C preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>])])
@@ -719,8 +773,130 @@
])# _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_ERROR([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_cv_prog_gobjc
+# ----------------
+# We used to name the cache variable this way.
+# I lied, I just want to fit in.
+AU_DEFUN([ac_cv_prog_gobjc],
+[ac_cv_objc_compiler_gnu])
+
+
+# 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 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.
+# POSSIBLE PROBLEM: If cc is a C compiler w/ no gcc, gcc might not be found
+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_CHECK_TOOLS(OBJC,
+ [m4_default([$1], [objcc objc gcc cc CC])],
+ gcc)
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
+ac_compiler=`set X $ac_compile; echo $[2]`
+_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
+_AC_EVAL([$ac_compiler -V </dev/null >&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_PROG_OBJC_LIBOBJC
+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.
+m4_define([_AC_PROG_OBJC_G],
+[ac_test_OBJCFLAGS=${OBJCFLAGS+set}
+ac_save_OBJCFLAGS=$OBJCFLAGS
+OBJCFLAGS="-g"
+AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
+ [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [ac_cv_prog_objc_g=yes],
+ [ac_cv_prog_objc_g=no])])
+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
## ------------------------------- ##