1 dnl ---------------------------------------------------------------------------
2 dnl Compiler detection macros by David Elliott
3 dnl ---------------------------------------------------------------------------
6 dnl ===========================================================================
7 dnl Macros to detect non-GNU compilers (MetroWerks, XLC)
8 dnl ===========================================================================
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__
18 [bakefile_compiler_mwerks=yes],
19 [bakefile_compiler_mwerks=no])
20 bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_mwerks=$bakefile_compiler_mwerks
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],
28 _AC_BAKEFILE_LANG_COMPILER_MWERKS
29 MWCC=`test $bakefile_cv_c_compiler_mwerks = yes && echo yes`
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],
37 _AC_BAKEFILE_LANG_COMPILER_MWERKS
38 MWCXX=`test $bakefile_cv_cxx_compiler_mwerks = yes && echo yes`
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__
50 [wx_compiler_xlc=yes],
52 wx_cv_[]_AC_LANG_ABBREV[]_compiler_xlc=$wx_compiler_xlc
56 dnl Loosely based on autoconf AC_PROG_CC
57 AC_DEFUN([AC_BAKEFILE_PROG_XLCC],
59 _AC_BAKEFILE_LANG_COMPILER_XLC
60 XLCC=`test $wx_cv_c_compiler_xlc = yes && echo yes`
64 dnl Loosely based on autoconf AC_PROG_CXX
65 AC_DEFUN([AC_BAKEFILE_PROG_XLCXX],
67 _AC_BAKEFILE_LANG_COMPILER_XLC
68 XLCXX=`test $wx_cv_cxx_compiler_xlc = yes && echo yes`
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],
78 [whether we are using the $1 $2 compiler],
79 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3],
87 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=yes],
88 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=no]
93 if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3" = "xyes"; then
100 dnl recent versions of SGI mipsPro compiler define _SGI_COMPILER_VERSION
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],
106 _AC_BAKEFILE_LANG_COMPILER(SGI, C, _SGI_COMPILER_VERSION, SGICC=yes)
109 AC_DEFUN([AC_BAKEFILE_PROG_SGICXX],
111 _AC_BAKEFILE_LANG_COMPILER(SGI, C++, _SGI_COMPILER_VERSION, SGICXX=yes)
114 dnl Sun compiler defines __SUNPRO_C/__SUNPRO_CC
115 AC_DEFUN([AC_BAKEFILE_PROG_SUNCC],
117 _AC_BAKEFILE_LANG_COMPILER(Sun, C, __SUNPRO_C, SUNCC=yes)
120 AC_DEFUN([AC_BAKEFILE_PROG_SUNCXX],
122 _AC_BAKEFILE_LANG_COMPILER(Sun, C++, __SUNPRO_CC, SUNCXX=yes)
125 dnl Intel icc compiler defines __INTEL_COMPILER for both C and C++
126 AC_DEFUN([AC_BAKEFILE_PROG_INTELCC],
128 _AC_BAKEFILE_LANG_COMPILER(Intel, C, __INTEL_COMPILER, INTELCC=yes)
131 AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX],
133 _AC_BAKEFILE_LANG_COMPILER(Intel, C++, __INTEL_COMPILER, INTELCXX=yes)
136 dnl ===========================================================================
137 dnl macros to detect specialty compiler options
138 dnl ===========================================================================
140 dnl Figure out if we need to pass -ext o to compiler (MetroWerks)
141 AC_DEFUN([AC_BAKEFILE_METROWERKS_EXTO],
142 [AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], wx_cv_[]_AC_LANG_ABBREV[]_exto,
143 dnl First create an empty conf test
144 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
145 dnl Now remove .o and .c.o or .cc.o
146 rm -f conftest.$ac_objext conftest.$ac_ext.o
147 dnl Now compile the test
148 AS_IF([AC_TRY_EVAL(ac_compile)],
149 dnl If the test succeeded look for conftest.c.o or conftest.cc.o
150 [for ac_file in `(ls conftest.* 2>/dev/null)`; do
153 wx_cv_[]_AC_LANG_ABBREV[]_exto="-ext o"
159 [AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile])
162 rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
163 ]) dnl AC_CACHE_CHECK
165 if test "x$wx_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then
166 if test "[]_AC_LANG_ABBREV[]" = "c"; then
167 CFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS"
169 if test "[]_AC_LANG_ABBREV[]" = "cxx"; then
170 CXXFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS"
176 dnl ===========================================================================
177 dnl Macros to do all of the compiler detections as one macro
178 dnl ===========================================================================
179 AC_DEFUN([AC_BAKEFILE_PROG_CC],
182 AC_BAKEFILE_PROG_INTELCC
183 dnl if we're using gcc, we can't be using any of incompatible compilers
184 if test "x$GCC" != "xyes"; then
185 AC_BAKEFILE_METROWERKS_EXTO
186 dnl By the time we find out that we need -ext o some tests have failed.
187 if test "x$wx_cv_c_exto" '!=' "x"; then
188 unset ac_cv_prog_cc_g
191 AC_BAKEFILE_PROG_MWCC
192 AC_BAKEFILE_PROG_XLCC
193 AC_BAKEFILE_PROG_SGICC
194 AC_BAKEFILE_PROG_SUNCC
198 AC_DEFUN([AC_BAKEFILE_PROG_CXX],
201 AC_BAKEFILE_PROG_INTELCXX
202 if test "x$GXX" != "xyes"; then
203 AC_BAKEFILE_METROWERKS_EXTO
204 dnl By the time we find out that we need -ext o some tests have failed.
205 if test "x$wx_cv_cxx_exto" '!=' "x"; then
206 unset ac_cv_prog_cxx_g
209 AC_BAKEFILE_PROG_MWCXX
210 AC_BAKEFILE_PROG_XLCXX
211 AC_BAKEFILE_PROG_SGICXX
212 AC_BAKEFILE_PROG_SUNCXX