diff options
Diffstat (limited to 'scripts/mkc_check_compiler')
-rwxr-xr-x | scripts/mkc_check_compiler | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/scripts/mkc_check_compiler b/scripts/mkc_check_compiler new file mode 100755 index 0000000..6930a2f --- /dev/null +++ b/scripts/mkc_check_compiler @@ -0,0 +1,72 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +: ${TMPDIR:=/tmp} + +tmpfile="$TMPDIR/mk-c.$$.c" +trap 'rm -f "$tmpfile"' 0 + +################################################## + +pathpart=compiler_type +if test "$1" = -x; then + pathpart=cxx_type + langname='C++' + CC="$CXX" + export CC +else + langname='C' +fi + +################################################## +checks=' + __clang__ clang + __ICC icc +__INTEL_COMPILER icc + __PCC__ pcc + __GNUC__ gcc + _MSC_VER msc + __HP_aCC hpc + __HP_cc hpc + __SUNPRO_C sunpro + __SUNPRO_CC sunpro + __IBMCPP__ ibmc + __IBMC__ ibmc + __BORLANDC__ bcc + __WATCOMC__ watcom + __COMO__ como + __DECC decc + __DECCXX decc +_COMPILER_VERSION mipspro +' + +check_itself (){ + awk ' +BEGIN { + printf "#" + for (i=1; i < ARGC; ++i){ + printf "if defined(%s)\ncompiler %s\n#el", ARGV [i], ARGV [i+1] + } + printf "se\ncompiler unknown\n#endif\n" +}' $checks >"$tmpfile" + $CC -E "$tmpfile" | + awk 'BEGIN { ret="unknown"} $1 == "compiler" {ret=$2; exit} END {print ret}' +} + +. mkc_check_common.sh + +check_and_cache "checking for $langname compiler type" "$cache" + +printme '%s\n' "$ret" 1>&2 + +echo "$ret" |