ac-archive-maintainers
[Top][All Lists]
Advanced

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

C++ compiler vendor test macro


From: Ludovic Courtès
Subject: C++ compiler vendor test macro
Date: Tue, 7 Sep 2004 18:10:02 +0200
User-agent: Mutt/1.5.4i [Guile enabled]

Hi,

Here is a little macro (actually two macros) that tries to guess what
the vendor of C++ compiler is (it currently knows of five compilers).
Note that `AC_C_IFELSE' is just a tiny helper macro.

dnl @synopsis AC_CXX_COMPILER_VENDOR(VENDOR-NAME, [NICKNAME])
dnl
dnl Set VENDOR-NAME to the lower-case name of the compiler vendor or `unknown'
dnl if the compiler's vendor is unknown.  `compaq' means the CXX compiler as
dnl available on Tru64/OSF1/Digital Unix on Alpha machines.  If NICKNAME is
dnl provided, set it to the compiler's usual name (eg. `g++', `cxx', `aCC',
dnl etc.).
dnl
dnl @version 20040907
dnl @author  Ludovic Courtès <address@hidden>
AC_DEFUN([AC_CXX_COMPILER_VENDOR],
  [AC_REQUIRE([AC_PROG_CXX])
   AC_REQUIRE([AC_PROG_CXXCPP])
   AC_CACHE_CHECK([the C++ compiler vendor],
    [ac_cv_cxx_compiler_vendor],

    [AC_LANG_PUSH([C++])

     dnl GNU C++
     _AC_C_IFDEF([__GNUG__],
       [ac_cv_cxx_compiler_vendor=gnu],
       [_AC_C_IFDEF([__DECCXX],
         [ac_cv_cxx_compiler_vendor=compaq],
         [dnl HP's aCC
          _AC_C_IFDEF([__HP_aCC],
           [ac_cv_cxx_compiler_vendor=hp],
           [dnl SGI CC
            _AC_C_IFDEF([__sgi],
             [ac_cv_cxx_compiler_vendor=sgi],
             [dnl Note:  We are using the C compiler because VC++ doesn't
              dnl recognize `.cc'(which is used by `configure') as a C++ file
              dnl extension and requires `/TP' to be passed.
              AC_LANG_PUSH([C])
              _AC_C_IFDEF([_MSC_VER],
                [ac_cv_cxx_compiler_vendor=microsoft],
                [ac_cv_cxx_compiler_vendor=unknown])
              AC_LANG_POP()])])])])

     AC_LANG_POP()])
   $1="$ac_cv_cxx_compiler_vendor"

   dnl The compiler nickname
   ifelse([$2], , [],
     [case "$ac_cv_cxx_compiler_vendor" in
        gnu)       $2=g++;;
        compaq)    $2=cxx;;
        hp)        $2=aCC;;
        sgi)       $2=CC;;
        microsoft) $2=cl;;
        *)         $2=unknown;;
      esac])])dnl


And now the helper macro needed by the above one:

dnl @synopsis _AC_C_IFDEF(MACRO-NAME, ACTION-IF-DEF, ACTION-IF-NOT-DEF)
dnl
dnl Check for the definition of macro MACRO-NAME using the current
dnl language's compiler.
dnl
dnl @version 20040907
dnl @author  Ludovic Courtès <address@hidden>
AC_DEFUN([_AC_C_IFDEF],
  [AC_COMPILE_IFELSE([#ifndef $1
                      # error "Macro $1 is undefined!"
                      /* For some compilers (eg. SGI's CC), #error is not
                         enough...  */
                      please, do fail
                      #endif],
                     [$2], [$3])])


I have a few other macros which depend on `AC_CXX_COMPILER_VENDOR' and
I will send them soon in separate messages.

Thanks,
Ludovic.




reply via email to

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