autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] c.m4 - Add Objective C as a language


From: Ralf Wildenhues
Subject: Re: [Patch] c.m4 - Add Objective C as a language
Date: Thu, 16 Mar 2006 18:46:05 +0100
User-agent: Mutt/1.5.9i

[ moving to autoconf-patches ]

* Paul Eggert wrote on Mon, Mar 13, 2006 at 06:56:29PM CET:
> Ralf Wildenhues <address@hidden> writes:
> 
> >> >   http://thread.gmane.org/gmane.comp.sysutils.autoconf.general/1661
> >> 
> >> We don't have any paperwork from David M. Lloyd, no.  I don't recall
> >> why not.  We can start the paperwork now, if he likes.
> >
> > Any reaction yet?
> 
> Not as far as I know, no.  We don't have any paperwork yet.

OK.  Here's a redo against CVS Autoconf.

To document what I did in lib/autoconf/c.m4, quite mechanically:
- duplicate each part dealing with C++
- Rename
    s/C++/Objective C/g
    s/CXXCPP/OBJCPP/g
    s/GXX/GOBJC/g
    s/CXX/OBJC/g
    s/cxx/objc/g
- set ac_ext=m
- readjust comments: underlining, reindent
- remove obvious cruft and obviously C++ specific stuff

The only remaining part for which I actually had to look at David's
patch was for the list of possible compilers.  It's four comment lines
and two lines of actual code which I copied.  AFAIK this is not enough
to be copyrightable.  And it's easily retrievable online, for example
at http://www.faqs.org/faqs/computer-lang/Objective-C/faq/ .

So, then I compared my resulting patch with his, and detected a couple
of errors in his patch, and several places where mine uses "more modern"
notation.

Do you think this is ok as procedure?

Further question: document Objective C right after C++ (logical) or
after Erlang node (alphabetical)?  Try 'gcc' before the other compilers?

It would be great if somebody could test this with a non-GCC compiler.

This patch comes with a sibling patch to fix support for OBJC in
Automake.

Missing bit would be at test for necessary library additions (-lobjc
-lpthread?).

Cheers,
Ralf

        * 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 <address@hidden>.

Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.212
diff -u -r1.212 c.m4
--- lib/autoconf/c.m4   11 Mar 2006 13:21:32 -0000      1.212
+++ lib/autoconf/c.m4   14 Mar 2006 22:53:25 -0000
@@ -116,6 +116,38 @@
 
 
 
+# ------------------------------ #
+# 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 @@
 
 
 
+# ------------------------- #
+# 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,10 +379,10 @@
 # _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}.
 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>])])
 
 
@@ -805,6 +872,138 @@
 ])# _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], [objcc objc gcc 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
+
+
 
 
 
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.964
diff -u -r1.964 autoconf.texi
--- doc/autoconf.texi   14 Mar 2006 07:19:27 -0000      1.964
+++ doc/autoconf.texi   14 Mar 2006 22:23:06 -0000
@@ -381,6 +383,7 @@
 * 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
 
@@ -2258,6 +2261,15 @@
 programs to test for C, C++, and Fortran features.
 @end defvar
 
address@hidden OBJCFLAGS
address@hidden 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).
address@hidden uses this variable when compiling programs to test for
+Objective C features.
address@hidden defvar
+
 @defvar builddir
 @ovindex builddir
 Rigorously equal to @samp{.}.  Added for symmetry only.
@@ -5638,6 +5650,7 @@
 * 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
@@ -6114,6 +6127,44 @@
 @end defmac
 
 
address@hidden Objective C Compiler
address@hidden Objective C Compiler Characteristics
+
+
address@hidden AC_PROG_OBJC (@ovar{compiler-search-list})
address@hidden
address@hidden OBJC
address@hidden 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:
+
address@hidden
+AC_PROG_OBJC([gcc objcc objc])
address@hidden example
+
+If using the @acronym{GNU} Objective C compiler, set shell variable
address@hidden 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
address@hidden), or @option{-g} for other compilers.
address@hidden defmac
+
address@hidden AC_PROG_OBJCCPP
address@hidden
address@hidden 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.
address@hidden defmac
+
+
 @node Erlang Compiler and Interpreter
 @subsection Erlang Compiler and Interpreter Characteristics
 @cindex Erlang
@@ -6282,7 +6333,7 @@
 @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
@@ -6839,6 +6890,12 @@
 @item Erlang
 Compile and execute tests using @code{ERLC} and @code{ERL} and use extension
 @file{.erl} for test Erlang modules.  Use compilation flags: @code{ERLCFLAGS}.
+
address@hidden Objective C
+Do compilation tests using @code{OBJC} and @code{OBJCCPP} and use
+extension @file{.m} for test programs.  Use compilation flags:
address@hidden with @code{OBJCPP}, and both @code{CPPFLAGS} and
address@hidden with @code{OBJC}.
 @end table
 @end defmac
 
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.353
diff -u -r1.353 NEWS
--- NEWS        20 Feb 2006 19:45:32 -0000      1.353
+++ NEWS        14 Mar 2006 22:25:17 -0000
@@ -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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]