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