]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/bakefile-lang.m4
optimization: don't test for various proprietary Unix compilers unless we're running...
[wxWidgets.git] / build / aclocal / bakefile-lang.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Compiler detection macros by David Elliott
3 dnl ---------------------------------------------------------------------------
4
5
6 dnl ===========================================================================
7 dnl Macros to detect non-GNU compilers (MetroWerks, XLC)
8 dnl ===========================================================================
9
10 dnl Based on autoconf _AC_LANG_COMPILER_GNU
11 AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER_MWERKS],
12 [AC_CACHE_CHECK([whether we are using the Metrowerks _AC_LANG compiler],
13 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_mwerks],
14 [AC_TRY_COMPILE([],[#ifndef __MWERKS__
15 choke me
16 #endif
17 ],
18 [bakefile_compiler_mwerks=yes],
19 [bakefile_compiler_mwerks=no])
20 bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_mwerks=$bakefile_compiler_mwerks
21 ])
22 ])
23
24 dnl Loosely based on autoconf AC_PROG_CC
25 dnl TODO: Maybe this should wrap the call to AC_PROG_CC and be used instead.
26 AC_DEFUN([AC_BAKEFILE_PROG_MWCC],
27 [AC_LANG_PUSH(C)
28 _AC_BAKEFILE_LANG_COMPILER_MWERKS
29 MWCC=`test $bakefile_cv_c_compiler_mwerks = yes && echo yes`
30 AC_LANG_POP(C)
31 ])
32
33 dnl Loosely based on autoconf AC_PROG_CXX
34 dnl TODO: Maybe this should wrap the call to AC_PROG_CXX and be used instead.
35 AC_DEFUN([AC_BAKEFILE_PROG_MWCXX],
36 [AC_LANG_PUSH(C++)
37 _AC_BAKEFILE_LANG_COMPILER_MWERKS
38 MWCXX=`test $bakefile_cv_cxx_compiler_mwerks = yes && echo yes`
39 AC_LANG_POP(C++)
40 ])
41
42 dnl Based on autoconf _AC_LANG_COMPILER_GNU
43 AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER_XLC],
44 [AC_CACHE_CHECK([whether we are using the IBM xlC _AC_LANG compiler],
45 [wx_cv_[]_AC_LANG_ABBREV[]_compiler_xlc],
46 [AC_TRY_COMPILE([],[#ifndef __xlC__
47 choke me
48 #endif
49 ],
50 [wx_compiler_xlc=yes],
51 [wx_compiler_xlc=no])
52 wx_cv_[]_AC_LANG_ABBREV[]_compiler_xlc=$wx_compiler_xlc
53 ])
54 ])
55
56 dnl Loosely based on autoconf AC_PROG_CC
57 AC_DEFUN([AC_BAKEFILE_PROG_XLCC],
58 [AC_LANG_PUSH(C)
59 _AC_BAKEFILE_LANG_COMPILER_XLC
60 XLCC=`test $wx_cv_c_compiler_xlc = yes && echo yes`
61 AC_LANG_POP(C)
62 ])
63
64 dnl Loosely based on autoconf AC_PROG_CXX
65 AC_DEFUN([AC_BAKEFILE_PROG_XLCXX],
66 [AC_LANG_PUSH(C++)
67 _AC_BAKEFILE_LANG_COMPILER_XLC
68 XLCXX=`test $wx_cv_cxx_compiler_xlc = yes && echo yes`
69 AC_LANG_POP(C++)
70 ])
71
72 dnl Based on autoconf _AC_LANG_COMPILER_GNU
73 dnl _AC_BAKEFILE_LANG_COMPILER(NAME, LANG, SYMBOL, IF-YES, IF-NO)
74 AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER],
75 [
76 AC_LANG_PUSH($2)
77 AC_CACHE_CHECK(
78 [whether we are using the $1 $2 compiler],
79 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3],
80 [AC_TRY_COMPILE(
81 [],
82 [
83 #ifndef $3
84 choke me
85 #endif
86 ],
87 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=yes],
88 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=no]
89 )
90 ]
91 )
92 AC_LANG_POP($2)
93 if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3" = "xyes"; then
94 :; $4
95 else
96 :; $5
97 fi
98 ])
99
100 dnl recent versions of SGI mipsPro compiler define _SGI_COMPILER_VERSION
101 dnl
102 dnl NB: old versions define _COMPILER_VERSION but this could probably be
103 dnl defined by other compilers too so don't test for it to be safe
104 AC_DEFUN([AC_BAKEFILE_PROG_SGICC],
105 [
106 _AC_BAKEFILE_LANG_COMPILER(SGI, C, _SGI_COMPILER_VERSION, SGICC=yes)
107 ])
108
109 AC_DEFUN([AC_BAKEFILE_PROG_SGICXX],
110 [
111 _AC_BAKEFILE_LANG_COMPILER(SGI, C++, _SGI_COMPILER_VERSION, SGICXX=yes)
112 ])
113
114 dnl Sun compiler defines __SUNPRO_C/__SUNPRO_CC
115 AC_DEFUN([AC_BAKEFILE_PROG_SUNCC],
116 [
117 _AC_BAKEFILE_LANG_COMPILER(Sun, C, __SUNPRO_C, SUNCC=yes)
118 ])
119
120 AC_DEFUN([AC_BAKEFILE_PROG_SUNCXX],
121 [
122 _AC_BAKEFILE_LANG_COMPILER(Sun, C++, __SUNPRO_CC, SUNCXX=yes)
123 ])
124
125 dnl Intel icc compiler defines __INTEL_COMPILER for both C and C++
126 AC_DEFUN([AC_BAKEFILE_PROG_INTELCC],
127 [
128 _AC_BAKEFILE_LANG_COMPILER(Intel, C, __INTEL_COMPILER, INTELCC=yes)
129 ])
130
131 AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX],
132 [
133 _AC_BAKEFILE_LANG_COMPILER(Intel, C++, __INTEL_COMPILER, INTELCXX=yes)
134 ])
135
136 dnl HP-UX aCC: see http://docs.hp.com/en/6162/preprocess.htm#macropredef
137 AC_DEFUN([AC_BAKEFILE_PROG_HPCC],
138 [
139 _AC_BAKEFILE_LANG_COMPILER(HP, C, __HP_cc, HPCC=yes)
140 ])
141
142 AC_DEFUN([AC_BAKEFILE_PROG_HPCXX],
143 [
144 _AC_BAKEFILE_LANG_COMPILER(HP, C++, __HP_aCC, HPCXX=yes)
145 ])
146
147 dnl ===========================================================================
148 dnl macros to detect specialty compiler options
149 dnl ===========================================================================
150
151 dnl Figure out if we need to pass -ext o to compiler (MetroWerks)
152 AC_DEFUN([AC_BAKEFILE_METROWERKS_EXTO],
153 [AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], wx_cv_[]_AC_LANG_ABBREV[]_exto,
154 dnl First create an empty conf test
155 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
156 dnl Now remove .o and .c.o or .cc.o
157 rm -f conftest.$ac_objext conftest.$ac_ext.o
158 dnl Now compile the test
159 AS_IF([AC_TRY_EVAL(ac_compile)],
160 dnl If the test succeeded look for conftest.c.o or conftest.cc.o
161 [for ac_file in `(ls conftest.* 2>/dev/null)`; do
162 case $ac_file in
163 conftest.$ac_ext.o)
164 wx_cv_[]_AC_LANG_ABBREV[]_exto="-ext o"
165 ;;
166 *)
167 ;;
168 esac
169 done],
170 [AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile])
171 ]) dnl AS_IF
172
173 rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
174 ]) dnl AC_CACHE_CHECK
175
176 if test "x$wx_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then
177 if test "[]_AC_LANG_ABBREV[]" = "c"; then
178 CFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS"
179 fi
180 if test "[]_AC_LANG_ABBREV[]" = "cxx"; then
181 CXXFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS"
182 fi
183 fi
184 ]) dnl AC_DEFUN
185
186
187 dnl ===========================================================================
188 dnl Macros to do all of the compiler detections as one macro
189 dnl ===========================================================================
190
191 dnl check for different proprietary compilers depending on target platform
192 dnl _AC_BAKEFILE_PROG_COMPILER(LANG)
193 AC_DEFUN([_AC_BAKEFILE_PROG_COMPILER],
194 [
195 AC_PROG_$1
196 AC_BAKEFILE_PROG_INTEL$1
197 dnl if we're using gcc, we can't be using any of incompatible compilers
198 if test "x$G$1" != "xyes"; then
199 if test "x$1" = "xC"; then
200 AC_BAKEFILE_METROWERKS_EXTO
201 if test "x$wx_cv_c_exto" '!=' "x"; then
202 unset ac_cv_prog_cc_g
203 _AC_PROG_CC_G
204 fi
205 fi
206
207 dnl most of these compilers are only used under well-defined OS so
208 dnl don't waste time checking for them on other ones
209 case `uname -s` in
210 AIX*)
211 AC_BAKEFILE_PROG_XL$1
212 ;;
213
214 Darwin)
215 AC_BAKEFILE_PROG_MW$1
216 AC_BAKEFILE_PROG_XL$1
217 ;;
218
219 IRIX*)
220 AC_BAKEFILE_PROG_SGI$1
221 ;;
222
223 SunOS)
224 AC_BAKEFILE_PROG_SUN$1
225 ;;
226
227 HP-UX*)
228 AC_BAKEFILE_PROG_HP$1
229 ;;
230 esac
231 fi
232 ])
233
234 AC_DEFUN([AC_BAKEFILE_PROG_CC],
235 [
236 _AC_BAKEFILE_PROG_COMPILER(CC)
237 ])
238
239 AC_DEFUN([AC_BAKEFILE_PROG_CXX],
240 [
241 _AC_BAKEFILE_PROG_COMPILER(CXX)
242 ])
243