]>
Commit | Line | Data |
---|---|---|
2e91a01a | 1 | dnl |
15e5ef78 | 2 | dnl This file is part of Bakefile (http://www.bakefile.org) |
2e91a01a VZ |
3 | dnl |
4 | dnl Copyright (C) 2003-2007 Vaclav Slavik, David Elliott and others | |
5 | dnl | |
6 | dnl Permission is hereby granted, free of charge, to any person obtaining a | |
7 | dnl copy of this software and associated documentation files (the "Software"), | |
8 | dnl to deal in the Software without restriction, including without limitation | |
9 | dnl the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
10 | dnl and/or sell copies of the Software, and to permit persons to whom the | |
11 | dnl Software is furnished to do so, subject to the following conditions: | |
12 | dnl | |
13 | dnl The above copyright notice and this permission notice shall be included in | |
14 | dnl all copies or substantial portions of the Software. | |
15 | dnl | |
16 | dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
21 | dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
22 | dnl DEALINGS IN THE SOFTWARE. | |
23 | dnl | |
e3b13be4 | 24 | dnl Compiler detection macros by David Elliott and Vadim Zeitlin |
2e91a01a | 25 | dnl |
948b08e2 VZ |
26 | |
27 | ||
28 | dnl =========================================================================== | |
e3b13be4 | 29 | dnl Macros to detect different C/C++ compilers |
948b08e2 VZ |
30 | dnl =========================================================================== |
31 | ||
948b08e2 VZ |
32 | dnl Based on autoconf _AC_LANG_COMPILER_GNU |
33 | dnl _AC_BAKEFILE_LANG_COMPILER(NAME, LANG, SYMBOL, IF-YES, IF-NO) | |
34 | AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER], | |
35 | [ | |
36 | AC_LANG_PUSH($2) | |
37 | AC_CACHE_CHECK( | |
38 | [whether we are using the $1 $2 compiler], | |
39 | [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3], | |
40 | [AC_TRY_COMPILE( | |
41 | [], | |
42 | [ | |
43 | #ifndef $3 | |
44 | choke me | |
45 | #endif | |
46 | ], | |
47 | [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=yes], | |
48 | [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=no] | |
49 | ) | |
50 | ] | |
51 | ) | |
948b08e2 VZ |
52 | if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3" = "xyes"; then |
53 | :; $4 | |
54 | else | |
55 | :; $5 | |
56 | fi | |
e3b13be4 VZ |
57 | AC_LANG_POP($2) |
58 | ]) | |
59 | ||
05622061 VZ |
60 | dnl More specific version of the above macro checking whether the compiler |
61 | dnl version is at least the given one (assumes that we do use this compiler) | |
62 | dnl | |
63 | dnl _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(NAME, LANG, SYMBOL, VER, VERMSG, IF-YES, IF-NO) | |
64 | AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER_LATER_THAN], | |
65 | [ | |
66 | AC_LANG_PUSH($2) | |
67 | AC_CACHE_CHECK( | |
68 | [whether we are using $1 $2 compiler v$5 or later], | |
69 | [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4], | |
70 | [AC_TRY_COMPILE( | |
71 | [], | |
72 | [ | |
73 | #ifndef $3 || $3 < $4 | |
74 | choke me | |
75 | #endif | |
76 | ], | |
77 | [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4=yes], | |
78 | [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4=no] | |
79 | ) | |
80 | ] | |
81 | ) | |
82 | if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4" = "xyes"; then | |
83 | :; $6 | |
84 | else | |
85 | :; $7 | |
86 | fi | |
87 | AC_LANG_POP($2) | |
88 | ]) | |
89 | ||
e3b13be4 VZ |
90 | dnl CodeWarrior Metrowerks compiler defines __MWERKS__ for both C and C++ |
91 | AC_DEFUN([AC_BAKEFILE_PROG_MWCC], | |
92 | [ | |
93 | _AC_BAKEFILE_LANG_COMPILER(Metrowerks, C, __MWERKS__, MWCC=yes) | |
94 | ]) | |
95 | ||
96 | AC_DEFUN([AC_BAKEFILE_PROG_MWCXX], | |
97 | [ | |
98 | _AC_BAKEFILE_LANG_COMPILER(Metrowerks, C++, __MWERKS__, MWCXX=yes) | |
99 | ]) | |
100 | ||
101 | dnl IBM xlC compiler defines __xlC__ for both C and C++ | |
102 | AC_DEFUN([AC_BAKEFILE_PROG_XLCC], | |
103 | [ | |
104 | _AC_BAKEFILE_LANG_COMPILER([IBM xlC], C, __xlC__, XLCC=yes) | |
105 | ]) | |
106 | ||
107 | AC_DEFUN([AC_BAKEFILE_PROG_XLCXX], | |
108 | [ | |
109 | _AC_BAKEFILE_LANG_COMPILER([IBM xlC], C++, __xlC__, XLCXX=yes) | |
948b08e2 VZ |
110 | ]) |
111 | ||
ab0ad5f1 VZ |
112 | dnl recent versions of SGI mipsPro compiler define _SGI_COMPILER_VERSION |
113 | dnl | |
114 | dnl NB: old versions define _COMPILER_VERSION but this could probably be | |
115 | dnl defined by other compilers too so don't test for it to be safe | |
948b08e2 VZ |
116 | AC_DEFUN([AC_BAKEFILE_PROG_SGICC], |
117 | [ | |
118 | _AC_BAKEFILE_LANG_COMPILER(SGI, C, _SGI_COMPILER_VERSION, SGICC=yes) | |
119 | ]) | |
120 | ||
121 | AC_DEFUN([AC_BAKEFILE_PROG_SGICXX], | |
122 | [ | |
123 | _AC_BAKEFILE_LANG_COMPILER(SGI, C++, _SGI_COMPILER_VERSION, SGICXX=yes) | |
124 | ]) | |
125 | ||
ab0ad5f1 | 126 | dnl Sun compiler defines __SUNPRO_C/__SUNPRO_CC |
948b08e2 VZ |
127 | AC_DEFUN([AC_BAKEFILE_PROG_SUNCC], |
128 | [ | |
129 | _AC_BAKEFILE_LANG_COMPILER(Sun, C, __SUNPRO_C, SUNCC=yes) | |
130 | ]) | |
131 | ||
948b08e2 VZ |
132 | AC_DEFUN([AC_BAKEFILE_PROG_SUNCXX], |
133 | [ | |
134 | _AC_BAKEFILE_LANG_COMPILER(Sun, C++, __SUNPRO_CC, SUNCXX=yes) | |
135 | ]) | |
136 | ||
ab0ad5f1 VZ |
137 | dnl Intel icc compiler defines __INTEL_COMPILER for both C and C++ |
138 | AC_DEFUN([AC_BAKEFILE_PROG_INTELCC], | |
139 | [ | |
140 | _AC_BAKEFILE_LANG_COMPILER(Intel, C, __INTEL_COMPILER, INTELCC=yes) | |
141 | ]) | |
142 | ||
143 | AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX], | |
144 | [ | |
145 | _AC_BAKEFILE_LANG_COMPILER(Intel, C++, __INTEL_COMPILER, INTELCXX=yes) | |
146 | ]) | |
948b08e2 | 147 | |
05622061 VZ |
148 | dnl Intel compiler command line options changed in incompatible ways sometimes |
149 | dnl before v8 (-KPIC was replaced with gcc-compatible -fPIC) and again in v10 | |
150 | dnl (-create-pch deprecated in favour of -pch-create) so we need to test for | |
151 | dnl its exact version too | |
152 | AC_DEFUN([AC_BAKEFILE_PROG_INTELCC_8], | |
153 | [ | |
154 | _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C, __INTEL_COMPILER, 800, 8, INTELCC8=yes) | |
155 | ]) | |
156 | AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX_8], | |
157 | [ | |
158 | _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C++, __INTEL_COMPILER, 800, 8, INTELCXX8=yes) | |
159 | ]) | |
160 | ||
161 | AC_DEFUN([AC_BAKEFILE_PROG_INTELCC_10], | |
162 | [ | |
163 | _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C, __INTEL_COMPILER, 1000, 10, INTELCC10=yes) | |
164 | ]) | |
165 | ||
166 | AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX_10], | |
167 | [ | |
168 | _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C++, __INTEL_COMPILER, 1000, 10, INTELCXX10=yes) | |
169 | ]) | |
170 | ||
14cde513 VZ |
171 | dnl HP-UX aCC: see http://docs.hp.com/en/6162/preprocess.htm#macropredef |
172 | AC_DEFUN([AC_BAKEFILE_PROG_HPCC], | |
173 | [ | |
174 | _AC_BAKEFILE_LANG_COMPILER(HP, C, __HP_cc, HPCC=yes) | |
175 | ]) | |
176 | ||
177 | AC_DEFUN([AC_BAKEFILE_PROG_HPCXX], | |
178 | [ | |
179 | _AC_BAKEFILE_LANG_COMPILER(HP, C++, __HP_aCC, HPCXX=yes) | |
180 | ]) | |
181 | ||
a1aa0349 VZ |
182 | dnl Tru64 cc and cxx |
183 | AC_DEFUN([AC_BAKEFILE_PROG_COMPAQCC], | |
184 | [ | |
185 | _AC_BAKEFILE_LANG_COMPILER(Compaq, C, __DECC, COMPAQCC=yes) | |
186 | ]) | |
187 | ||
188 | AC_DEFUN([AC_BAKEFILE_PROG_COMPAQCXX], | |
189 | [ | |
190 | _AC_BAKEFILE_LANG_COMPILER(Compaq, C++, __DECCXX, COMPAQCXX=yes) | |
191 | ]) | |
192 | ||
948b08e2 VZ |
193 | dnl =========================================================================== |
194 | dnl macros to detect specialty compiler options | |
195 | dnl =========================================================================== | |
196 | ||
197 | dnl Figure out if we need to pass -ext o to compiler (MetroWerks) | |
198 | AC_DEFUN([AC_BAKEFILE_METROWERKS_EXTO], | |
a1aa0349 | 199 | [AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], bakefile_cv_[]_AC_LANG_ABBREV[]_exto, |
948b08e2 VZ |
200 | dnl First create an empty conf test |
201 | [AC_LANG_CONFTEST([AC_LANG_PROGRAM()]) | |
202 | dnl Now remove .o and .c.o or .cc.o | |
203 | rm -f conftest.$ac_objext conftest.$ac_ext.o | |
204 | dnl Now compile the test | |
205 | AS_IF([AC_TRY_EVAL(ac_compile)], | |
206 | dnl If the test succeeded look for conftest.c.o or conftest.cc.o | |
207 | [for ac_file in `(ls conftest.* 2>/dev/null)`; do | |
208 | case $ac_file in | |
209 | conftest.$ac_ext.o) | |
a1aa0349 | 210 | bakefile_cv_[]_AC_LANG_ABBREV[]_exto="-ext o" |
948b08e2 VZ |
211 | ;; |
212 | *) | |
213 | ;; | |
214 | esac | |
215 | done], | |
216 | [AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile]) | |
217 | ]) dnl AS_IF | |
218 | ||
219 | rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext | |
220 | ]) dnl AC_CACHE_CHECK | |
221 | ||
a1aa0349 | 222 | if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then |
948b08e2 | 223 | if test "[]_AC_LANG_ABBREV[]" = "c"; then |
a1aa0349 | 224 | CFLAGS="$bakefile_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS" |
948b08e2 VZ |
225 | fi |
226 | if test "[]_AC_LANG_ABBREV[]" = "cxx"; then | |
a1aa0349 | 227 | CXXFLAGS="$bakefile_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS" |
948b08e2 VZ |
228 | fi |
229 | fi | |
230 | ]) dnl AC_DEFUN | |
231 | ||
232 | ||
233 | dnl =========================================================================== | |
234 | dnl Macros to do all of the compiler detections as one macro | |
235 | dnl =========================================================================== | |
3006edc0 VZ |
236 | |
237 | dnl check for different proprietary compilers depending on target platform | |
238 | dnl _AC_BAKEFILE_PROG_COMPILER(LANG) | |
239 | AC_DEFUN([_AC_BAKEFILE_PROG_COMPILER], | |
948b08e2 | 240 | [ |
4164cd68 | 241 | AC_REQUIRE([AC_PROG_$1]) |
15e5ef78 VZ |
242 | |
243 | dnl Intel compiler can be used under several different OS and even | |
244 | dnl different architectures (x86, amd64 and Itanium) so it's easier to just | |
245 | dnl always test for it | |
3006edc0 | 246 | AC_BAKEFILE_PROG_INTEL$1 |
15e5ef78 | 247 | |
05622061 VZ |
248 | dnl If we use Intel compiler we also need to know its version |
249 | if test "$INTEL$1" = "yes"; then | |
250 | AC_BAKEFILE_PROG_INTEL$1_8 | |
251 | AC_BAKEFILE_PROG_INTEL$1_10 | |
252 | fi | |
253 | ||
ab0ad5f1 | 254 | dnl if we're using gcc, we can't be using any of incompatible compilers |
3006edc0 VZ |
255 | if test "x$G$1" != "xyes"; then |
256 | if test "x$1" = "xC"; then | |
257 | AC_BAKEFILE_METROWERKS_EXTO | |
a1aa0349 | 258 | if test "x$bakefile_cv_c_exto" '!=' "x"; then |
3006edc0 VZ |
259 | unset ac_cv_prog_cc_g |
260 | _AC_PROG_CC_G | |
261 | fi | |
ab0ad5f1 | 262 | fi |
3006edc0 VZ |
263 | |
264 | dnl most of these compilers are only used under well-defined OS so | |
265 | dnl don't waste time checking for them on other ones | |
266 | case `uname -s` in | |
267 | AIX*) | |
268 | AC_BAKEFILE_PROG_XL$1 | |
269 | ;; | |
270 | ||
271 | Darwin) | |
272 | AC_BAKEFILE_PROG_MW$1 | |
05622061 VZ |
273 | if test "$MW$1" != "yes"; then |
274 | AC_BAKEFILE_PROG_XL$1 | |
275 | fi | |
3006edc0 VZ |
276 | ;; |
277 | ||
278 | IRIX*) | |
279 | AC_BAKEFILE_PROG_SGI$1 | |
280 | ;; | |
281 | ||
15e5ef78 | 282 | Linux*) |
05622061 VZ |
283 | dnl Sun CC is now available under Linux too, test for it unless |
284 | dnl we already found that we were using a different compiler | |
285 | if test "$INTEL$1" != "yes"; then | |
286 | AC_BAKEFILE_PROG_SUN$1 | |
287 | fi | |
15e5ef78 VZ |
288 | ;; |
289 | ||
3006edc0 VZ |
290 | HP-UX*) |
291 | AC_BAKEFILE_PROG_HP$1 | |
292 | ;; | |
a1aa0349 VZ |
293 | |
294 | OSF1) | |
295 | AC_BAKEFILE_PROG_COMPAQ$1 | |
296 | ;; | |
297 | ||
298 | SunOS) | |
299 | AC_BAKEFILE_PROG_SUN$1 | |
300 | ;; | |
3006edc0 | 301 | esac |
948b08e2 | 302 | fi |
948b08e2 VZ |
303 | ]) |
304 | ||
3006edc0 VZ |
305 | AC_DEFUN([AC_BAKEFILE_PROG_CC], |
306 | [ | |
307 | _AC_BAKEFILE_PROG_COMPILER(CC) | |
308 | ]) | |
309 | ||
948b08e2 VZ |
310 | AC_DEFUN([AC_BAKEFILE_PROG_CXX], |
311 | [ | |
3006edc0 | 312 | _AC_BAKEFILE_PROG_COMPILER(CXX) |
948b08e2 VZ |
313 | ]) |
314 |