+ ])
+ ])
+
+# COMO
+AC_DEFUN([_AX_COMPILER_VERSION_COMEAU],
+ [ dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [__COMO_VERSION__%100],,
+ AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(__COMO_VERSION__/100)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
+ ])
+
+# KAI
+AC_DEFUN([_AX_COMPILER_VERSION_KAI],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__KCC_VERSION%100],,
+ AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [(__KCC_VERSION/100)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(__KCC_VERSION/1000)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown kay compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+dnl LCC
+dnl LCC does not output version...
+
+# SGI
+AC_DEFUN([_AX_COMPILER_VERSION_SGI],[
+ m4_define([_AX_COMPILER_VERSION_SGI_NUMBER],
+ [
+ #if defined(_COMPILER_VERSION)
+ _COMPILER_VERSION
+ #else
+ _SGI_COMPILER_VERSION
+ #endif
+ ])
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [_AX_COMPILER_VERSION_SGI_NUMBER%10],,
+ AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],,
+ AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# microsoft
+AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ _MSC_VER%100,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (_MSC_VER/100)%100,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version]))
+ dnl could be overridden
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0
+ # special case for version 6
+ AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _MSC_FULL_VER%1000,,
+ _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)])
+ # for version 7
+ AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _MSC_FULL_VER%1000,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version]))
+ ])
+ # for version > 8
+ AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ _MSC_FULL_VER%10000,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version]))
+ ])
+ AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15],
+ [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build,
+ _MSC_BUILD,,
+ AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version]))
+ ])
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build"
+ ])
+
+# for metrowerks
+AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ __MWERKS__%0x100,,
+ AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ (__MWERKS__/0x100)%0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (__MWERKS__/0x1000)%0x10,,
+ AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# for watcom
+AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __WATCOMC__%100,,
+ AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ (__WATCOMC__/100)%100,,
+ AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
+ ])
+
+# for PGI
+AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ __PGIC__,,
+ AC_MSG_FAILURE([[[$0]] unknown pgi major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ __PGIC_MINOR__,,
+ AC_MSG_FAILURE([[[$0]] unknown pgi minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [__PGIC_PATCHLEVEL__],,
+ AC_MSG_FAILURE([[[$0]] unknown pgi patch level]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# tcc
+AC_DEFUN([_AX_COMPILER_VERSION_TCC],[
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`]
+ ])
+
+# for GNU
+AC_DEFUN([_AX_COMPILER_VERSION_SDCC],[
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
+ /* avoid parse error with comments */
+ #if(defined(__SDCC_VERSION_MAJOR))
+ __SDCC_VERSION_MAJOR
+ #else
+ SDCC/100
+ #endif
+ ,,
+ AC_MSG_FAILURE([[[$0]] unknown sdcc major]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
+ /* avoid parse error with comments */
+ #if(defined(__SDCC_VERSION_MINOR))
+ __SDCC_VERSION_MINOR
+ #else
+ (SDCC%100)/10
+ #endif
+ ,,
+ AC_MSG_FAILURE([[[$0]] unknown sdcc minor]))
+ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
+ [
+ /* avoid parse error with comments */
+ #if(defined(__SDCC_VERSION_PATCH))
+ __SDCC_VERSION_PATCH
+ #elsif(defined(_SDCC_VERSION_PATCHLEVEL))
+ __SDCC_VERSION_PATCHLEVEL
+ #else
+ SDCC%10
+ #endif
+ ],,
+ AC_MSG_FAILURE([[[$0]] unknown sdcc patch level]))
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
+ ])
+
+# main entry point
+AC_DEFUN([AX_COMPILER_VERSION],[dnl
+ AC_REQUIRE([AX_COMPILER_VENDOR])
+ AC_REQUIRE([AC_PROG_SED])
+ AC_CACHE_CHECK([for _AC_LANG compiler version],
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version,
+ [ dnl
+ AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor],
+ [intel],[_AX_COMPILER_VERSION_INTEL],
+ [ibm],[_AX_COMPILER_VERSION_IBM],
+ [pathscale],[_AX_COMPILER_VERSION_PATHSCALE],
+ [clang],[_AX_COMPILER_VERSION_CLANG],
+ [cray],[_AX_COMPILER_VERSION_CRAY],
+ [fujitsu],[_AX_COMPILER_VERSION_FUJITSU],
+ [gnu],[_AX_COMPILER_VERSION_GNU],
+ [sun],[_AX_COMPILER_VERSION_SUN],
+ [hp],[_AX_COMPILER_VERSION_HP],
+ [dec],[_AX_COMPILER_VERSION_DEC],
+ [borland],[_AX_COMPILER_VERSION_BORLAND],
+ [comeau],[_AX_COMPILER_VERSION_COMEAU],
+ [kai],[_AX_COMPILER_VERSION_KAI],
+ [sgi],[_AX_COMPILER_VERSION_SGI],
+ [microsoft],[_AX_COMPILER_VERSION_MICROSOFT],
+ [metrowerks],[_AX_COMPILER_VERSION_METROWERKS],
+ [watcom],[_AX_COMPILER_VERSION_WATCOM],
+ [portland],[_AX_COMPILER_VERSION_PORTLAND],
+ [tcc],[_AX_COMPILER_VERSION_TCC],
+ [sdcc],[_AX_COMPILER_VERSION_SDCC],
+ [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""])
+ ])
+])