1dnl Adapted from the predefined _AC_LANG_COMPILER_GNU.
2m4_define([_AC_LANG_COMPILER_INTEL],
3[AC_CACHE_CHECK([whether we are using the INTEL _AC_LANG compiler],
4		[ac_cv_[]_AC_LANG_ABBREV[]_compiler_intel],
5[
6_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __INTEL_COMPILER
7       choke me
8#endif
9]])],
10		   [ac_compiler_intel=yes],
11		   [ac_compiler_intel=no])
12ac_cv_[]_AC_LANG_ABBREV[]_compiler_intel=$ac_compiler_intel
13])])# _AC_LANG_COMPILER_INTEL
14dnl The list of warnings that must be disabled.
15m4_define([_INTEL_IGNORE_WARNINGS],
16[ 522   dnl Remark ``redeclared "inline" after being called''
17  981   dnl Remark ``operands are evaluated in unspecified order''
18  383   dnl Remark ``value copied to temporary, reference to temporary used''
19  279   dnl Remark ``controlling expression is constant''
20]) # _INTEL_IGNORE_WARNINGS
21
22dnl Add extra flags when icc is used.
23AC_DEFUN([buddy_INTEL],
24[_AC_LANG_COMPILER_INTEL
25AC_CACHE_CHECK([to add extra CFLAGS for the INTEL C compiler],
26		[ac_cv_intel_cflags],
27[ dnl
28  if test x"$ac_cv_[]_AC_LANG_ABBREV[]_compiler_intel" = x"yes"; then
29    # -W does not exist for icc in CFLAGS.
30    CFLAGS=`echo "$CFLAGS" | sed 's/-W[[[:space:]]]//g;s/-W$//'`
31
32    disabled_warnings=''
33    for warning in _INTEL_IGNORE_WARNINGS; do
34      disabled_warnings="$disabled_warnings,$warning"
35    done
36
37    # Remove the extra "," and extra whitespaces.
38    disabled_warnings=`echo "$disabled_warnings" | sed "s/^,//;s/[[[:space:]]]//g"`
39
40    INTEL_CFLAGS="-w1 -Werror -wd${disabled_warnings}"
41
42    [ac_cv_intel_cflags="$INTEL_CFLAGS"]
43  else
44    [ac_cv_intel_cflags=""]
45  fi])
46  AC_SUBST([INTEL_CFLAGS])
47
48  if test x"$ac_cv_[]_AC_LANG_ABBREV[]_compiler_intel" = x"yes"; then
49    # -W does not exist for icc in CFLAGS.
50    CFLAGS=`echo "$CFLAGS" | sed 's/-W[[[:space:]]]//g;s/-W$//'`
51    CFLAGS="$CFLAGS $ac_cv_intel_cflags"
52    CXXFLAGS="$CFLAGS $ac_cv_intel_cflags"
53  fi
54]) # buddy_INTEL
55