1dnl -*- shell-script -*-
2dnl
3dnl Copyright © 2004-2005 The Trustees of Indiana University and Indiana
4dnl                         University Research and Technology
5dnl                         Corporation.  All rights reserved.
6dnl Copyright © 2004-2005 The University of Tennessee and The University
7dnl                         of Tennessee Research Foundation.  All rights
8dnl                         reserved.
9dnl Copyright © 2004-2005 High Performance Computing Center Stuttgart,
10dnl                         University of Stuttgart.  All rights reserved.
11dnl Copyright © 2004-2005 The Regents of the University of California.
12dnl                         All rights reserved.
13dnl Copyright © 2011      Cisco Systems, Inc.  All rights reserved.
14dnl $COPYRIGHT$
15dnl
16dnl Additional copyrights may follow
17dnl
18dnl $HEADER$
19dnl
20
21dnl ------------------------------------------------------------------
22dnl This m4 file originally copied from Open MPI
23dnl config/ompi_check_vendor.m4.
24dnl ------------------------------------------------------------------
25
26
27# HWLOC_C_COMPILER_VENDOR(VENDOR_VARIABLE)
28# ---------------------------------------
29# Set shell variable VENDOR_VARIABLE to the name of the compiler
30# vendor for the current C compiler.
31#
32# See comment for _HWLOC_CHECK_COMPILER_VENDOR for a complete
33# list of currently detected compilers.
34AC_DEFUN([_HWLOC_C_COMPILER_VENDOR], [
35    AC_REQUIRE([AC_PROG_CC])
36
37    AC_CACHE_CHECK([for the C compiler vendor],
38        [hwloc_cv_c_compiler_vendor],
39        [AC_LANG_PUSH(C)
40         _HWLOC_CHECK_COMPILER_VENDOR([hwloc_cv_c_compiler_vendor])
41         AC_LANG_POP(C)])
42
43    $1="$hwloc_cv_c_compiler_vendor"
44])
45
46
47# workaround to avoid syntax error with Autoconf < 2.68:
48m4_ifndef([AC_LANG_DEFINES_PROVIDED],
49	  [m4_define([AC_LANG_DEFINES_PROVIDED])])
50
51# HWLOC_IFDEF_IFELSE(symbol, [action-if-defined],
52#                   [action-if-not-defined])
53# ----------------------------------------------
54# Run compiler to determine if preprocessor symbol "symbol" is
55# defined by the compiler.
56AC_DEFUN([HWLOC_IFDEF_IFELSE], [
57    AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED
58#ifndef $1
59#error "symbol $1 not defined"
60choke me
61#endif], [$2], [$3])])
62
63
64# HWLOC_IF_IFELSE(symbol, [action-if-defined],
65#                [action-if-not-defined])
66# ----------------------------------------------
67# Run compiler to determine if preprocessor symbol "symbol" is
68# defined by the compiler.
69AC_DEFUN([HWLOC_IF_IFELSE], [
70    AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED
71#if !( $1 )
72#error "condition $1 not met"
73choke me
74#endif], [$2], [$3])])
75
76
77# _HWLOC_CHECK_COMPILER_VENDOR(VENDOR_VARIABLE)
78# --------------------------------------------
79# Set shell variable VENDOR_VARIABLE to the name of the compiler
80# vendor for the compiler for the current language.  Language must be
81# one of C, OBJC, or C++.
82#
83# thanks to http://predef.sourceforge.net/precomp.html for the list
84# of defines to check.
85AC_DEFUN([_HWLOC_CHECK_COMPILER_VENDOR], [
86    hwloc_check_compiler_vendor_result="unknown"
87
88    # GNU is probably the most common, so check that one as soon as
89    # possible. Intel and Android pretend to be GNU, so need to
90    # check Intel and Android before checking for GNU.
91
92    # Android
93    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
94          [HWLOC_IFDEF_IFELSE([__ANDROID__],
95               [hwloc_check_compiler_vendor_result="android"])])
96
97    # Intel
98    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
99          [HWLOC_IF_IFELSE([defined(__INTEL_COMPILER) || defined(__ICC)],
100               [hwloc_check_compiler_vendor_result="intel"])])
101
102    # GNU
103    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
104          [HWLOC_IFDEF_IFELSE([__GNUC__],
105               [hwloc_check_compiler_vendor_result="gnu"])])
106
107    # Borland Turbo C
108    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
109          [HWLOC_IFDEF_IFELSE([__TURBOC__],
110               [hwloc_check_compiler_vendor_result="borland"])])
111
112    # Borland C++
113    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
114          [HWLOC_IFDEF_IFELSE([__BORLANDC__],
115               [hwloc_check_compiler_vendor_result="borland"])])
116
117    # Comeau C++
118    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
119          [HWLOC_IFDEF_IFELSE([__COMO__],
120               [hwloc_check_compiler_vendor_result="comeau"])])
121
122    # Compaq C/C++
123    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
124          [HWLOC_IF_IFELSE([defined(__DECC) || defined(VAXC) || defined(__VAXC)],
125               [hwloc_check_compiler_vendor_result="compaq"],
126               [HWLOC_IF_IFELSE([defined(__osf__) && defined(__LANGUAGE_C__)],
127                    [hwloc_check_compiler_vendor_result="compaq"],
128                    [HWLOC_IFDEF_IFELSE([__DECCXX],
129                         [hwloc_check_compiler_vendor_result="compaq"])])])])
130
131    # Cray C/C++
132    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
133          [HWLOC_IFDEF_IFELSE([_CRAYC],
134               [hwloc_check_compiler_vendor_result="cray"])])
135
136    # Diab C/C++
137    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
138          [HWLOC_IFDEF_IFELSE([__DCC__],
139               [hwloc_check_compiler_vendor_result="diab"])])
140
141    # Digital Mars
142    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
143          [HWLOC_IF_IFELSE([defined(__DMC__) || defined(__SC__) || defined(__ZTC__)],
144               [hwloc_check_compiler_vendor_result="digital mars"])])
145
146    # HP ANSI C / aC++
147    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
148          [HWLOC_IF_IFELSE([defined(__HP_cc) || defined(__HP_aCC)],
149               [hwloc_check_compiler_vendor_result="hp"])])
150
151    # IBM XL C/C++
152    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
153          [HWLOC_IF_IFELSE([defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)],
154               [hwloc_check_compiler_vendor_result="ibm"],
155               [HWLOC_IF_IFELSE([defined(_AIX) && !defined(__GNUC__)],
156                    [hwloc_check_compiler_vendor_result="ibm"])])])
157
158    # KAI C++ (rest in peace)
159    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
160          [HWLOC_IFDEF_IFELSE([__KCC],
161               [hwloc_check_compiler_vendor_result="kai"])])
162
163    # LCC
164    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
165          [HWLOC_IFDEF_IFELSE([__LCC__],
166               [hwloc_check_compiler_vendor_result="lcc"])])
167
168    # MetaWare High C/C++
169    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
170          [HWLOC_IFDEF_IFELSE([__HIGHC__],
171               [hwloc_check_compiler_vendor_result="metaware high"])])
172
173    # Metrowerks Codewarrior
174    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
175          [HWLOC_IFDEF_IFELSE([__MWERKS__],
176               [hwloc_check_compiler_vendor_result="metrowerks"])])
177
178    # MIPSpro (SGI)
179    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
180          [HWLOC_IF_IFELSE([defined(sgi) || defined(__sgi)],
181               [hwloc_check_compiler_vendor_result="sgi"])])
182
183    # MPW C++
184    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
185          [HWLOC_IF_IFELSE([defined(__MRC__) || defined(MPW_C) || defined(MPW_CPLUS)],
186               [hwloc_check_compiler_vendor_result="mpw"])])
187
188    # Microsoft
189    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
190          [# Always use C compiler when checking for Microsoft, as
191           # Visual C++ doesn't recognize .cc as a C++ file.
192           AC_LANG_PUSH(C)
193           HWLOC_IF_IFELSE([defined(_MSC_VER) || defined(__MSC_VER)],
194               [hwloc_check_compiler_vendor_result="microsoft"])
195           AC_LANG_POP(C)])
196
197    # Norcroft C
198    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
199          [HWLOC_IFDEF_IFELSE([__CC_NORCROFT],
200               [hwloc_check_compiler_vendor_result="norcroft"])])
201
202    # Pelles C
203    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
204          [HWLOC_IFDEF_IFELSE([__POCC__],
205               [hwloc_check_compiler_vendor_result="pelles"])])
206
207    # Portland Group
208    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
209          [HWLOC_IFDEF_IFELSE([__PGI],
210               [hwloc_check_compiler_vendor_result="portland group"])])
211
212    # SAS/C
213    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
214          [HWLOC_IF_IFELSE([defined(SASC) || defined(__SASC) || defined(__SASC__)],
215               [hwloc_check_compiler_vendor_result="sas"])])
216
217    # Sun Workshop C/C++
218    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
219          [HWLOC_IF_IFELSE([defined(__SUNPRO_C) || defined(__SUNPRO_CC)],
220               [hwloc_check_compiler_vendor_result="sun"])])
221
222    # TenDRA C/C++
223    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
224          [HWLOC_IFDEF_IFELSE([__TenDRA__],
225               [hwloc_check_compiler_vendor_result="tendra"])])
226
227    # Tiny C
228    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
229          [HWLOC_IFDEF_IFELSE([__TINYC__],
230               [hwloc_check_compiler_vendor_result="tiny"])])
231
232    # USL C
233    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
234          [HWLOC_IFDEF_IFELSE([__USLC__],
235               [hwloc_check_compiler_vendor_result="usl"])])
236
237    # Watcom C++
238    AS_IF([test "$hwloc_check_compiler_vendor_result" = "unknown"],
239          [HWLOC_IFDEF_IFELSE([__WATCOMC__],
240               [hwloc_check_compiler_vendor_result="watcom"])])
241
242    $1="$hwloc_check_compiler_vendor_result"
243    unset hwloc_check_compiler_vendor_result
244])
245