1# ===========================================================================
2#    https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_COMPILER_VENDOR
8#
9# DESCRIPTION
10#
11#   Determine the vendor of the C, C++ or Fortran compiler.  The vendor is
12#   returned in the cache variable $ax_cv_c_compiler_vendor for C,
13#   $ax_cv_cxx_compiler_vendor for C++ or $ax_cv_fc_compiler_vendor for
14#   (modern) Fortran.  The value is one of "intel", "ibm", "pathscale",
15#   "clang" (LLVM), "cray", "fujitsu", "sdcc", "sx", "portland" (PGI), "gnu"
16#   (GCC), "sun" (Oracle Developer Studio), "hp", "dec", "borland",
17#   "comeau", "kai", "lcc", "sgi", "microsoft", "metrowerks", "watcom",
18#   "tcc" (Tiny CC) or "unknown" (if the compiler cannot be determined).
19#
20#   To check for a Fortran compiler, you must first call AC_FC_PP_SRCEXT
21#   with an appropriate preprocessor-enabled extension.  For example:
22#
23#     AC_LANG_PUSH([Fortran])
24#     AC_PROG_FC
25#     AC_FC_PP_SRCEXT([F])
26#     AX_COMPILER_VENDOR
27#     AC_LANG_POP([Fortran])
28#
29# LICENSE
30#
31#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
32#   Copyright (c) 2008 Matteo Frigo
33#   Copyright (c) 2018-19 John Zaitseff <J.Zaitseff@zap.org.au>
34#
35#   This program is free software: you can redistribute it and/or modify it
36#   under the terms of the GNU General Public License as published by the
37#   Free Software Foundation, either version 3 of the License, or (at your
38#   option) any later version.
39#
40#   This program is distributed in the hope that it will be useful, but
41#   WITHOUT ANY WARRANTY; without even the implied warranty of
42#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
43#   Public License for more details.
44#
45#   You should have received a copy of the GNU General Public License along
46#   with this program. If not, see <https://www.gnu.org/licenses/>.
47#
48#   As a special exception, the respective Autoconf Macro's copyright owner
49#   gives unlimited permission to copy, distribute and modify the configure
50#   scripts that are the output of Autoconf when processing the Macro. You
51#   need not follow the terms of the GNU General Public License when using
52#   or distributing such scripts, even though portions of the text of the
53#   Macro appear in them. The GNU General Public License (GPL) does govern
54#   all other use of the material that constitutes the Autoconf Macro.
55#
56#   This special exception to the GPL applies to versions of the Autoconf
57#   Macro released by the Autoconf Archive. When you make and distribute a
58#   modified version of the Autoconf Macro, you may extend this special
59#   exception to the GPL to apply to your modified version as well.
60
61#serial 30
62
63AC_DEFUN([AX_COMPILER_VENDOR], [dnl
64    AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [dnl
65	dnl  If you modify this list of vendors, please add similar support
66	dnl  to ax_compiler_version.m4 if at all possible.
67	dnl
68	dnl  Note: Do NOT check for GCC first since some other compilers
69	dnl  define __GNUC__ to remain compatible with it.  Compilers that
70	dnl  are very slow to start (such as Intel) are listed first.
71
72	vendors="
73		intel:		__ICC,__ECC,__INTEL_COMPILER
74		ibm:		__xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__
75		pathscale:	__PATHCC__,__PATHSCALE__
76		clang:		__clang__
77		cray:		_CRAYC
78		fujitsu:	__FUJITSU
79		sdcc:		SDCC,__SDCC
80		sx:		_SX
81		portland:	__PGI
82		gnu:		__GNUC__
83		sun:		__SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95
84		hp:		__HP_cc,__HP_aCC
85		dec:		__DECC,__DECCXX,__DECC_VER,__DECCXX_VER
86		borland:	__BORLANDC__,__CODEGEARC__,__TURBOC__
87		comeau:		__COMO__
88		kai:		__KCC
89		lcc:		__LCC__
90		sgi:		__sgi,sgi
91		microsoft:	_MSC_VER
92		metrowerks:	__MWERKS__
93		watcom:		__WATCOMC__
94		tcc:		__TINYC__
95		unknown:	UNKNOWN
96	"
97	for ventest in $vendors; do
98	    case $ventest in
99		*:)
100		    vendor=$ventest
101		    continue
102		    ;;
103		*)
104		    vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")"
105		    ;;
106	    esac
107
108	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
109#if !($vencpp)
110      thisisanerror;
111#endif
112	    ]])], [break])
113	done
114
115	ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
116    ])
117])dnl
118