2 dnl This file is part of Bakefile (http://bakefile.sourceforge.net)
4 dnl Copyright (C) 2003-2007 Vaclav Slavik, David Elliott and others
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:
13 dnl The above copyright notice and this permission notice shall be included in
14 dnl all copies or substantial portions of the Software.
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.
26 dnl Compiler detection macros by David Elliott
30 dnl ===========================================================================
31 dnl Macros to detect non-GNU compilers (MetroWerks, XLC)
32 dnl ===========================================================================
34 dnl Based on autoconf _AC_LANG_COMPILER_GNU
35 AC_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__
42 [bakefile_compiler_mwerks=yes],
43 [bakefile_compiler_mwerks=no])
44 bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_mwerks=$bakefile_compiler_mwerks
48 dnl Loosely based on autoconf AC_PROG_CC
49 dnl TODO: Maybe this should wrap the call to AC_PROG_CC and be used instead.
50 AC_DEFUN([AC_BAKEFILE_PROG_MWCC],
52 _AC_BAKEFILE_LANG_COMPILER_MWERKS
53 MWCC=`test $bakefile_cv_c_compiler_mwerks = yes && echo yes`
57 dnl Loosely based on autoconf AC_PROG_CXX
58 dnl TODO: Maybe this should wrap the call to AC_PROG_CXX and be used instead.
59 AC_DEFUN([AC_BAKEFILE_PROG_MWCXX],
61 _AC_BAKEFILE_LANG_COMPILER_MWERKS
62 MWCXX=`test $bakefile_cv_cxx_compiler_mwerks = yes && echo yes`
66 dnl Based on autoconf _AC_LANG_COMPILER_GNU
67 AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER_XLC],
68 [AC_CACHE_CHECK([whether we are using the IBM xlC _AC_LANG compiler],
69 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_xlc],
70 [AC_TRY_COMPILE([],[#ifndef __xlC__
74 [bakefile_compiler_xlc=yes],
75 [bakefile_compiler_xlc=no])
76 bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_xlc=$bakefile_compiler_xlc
80 dnl Loosely based on autoconf AC_PROG_CC
81 AC_DEFUN([AC_BAKEFILE_PROG_XLCC],
83 _AC_BAKEFILE_LANG_COMPILER_XLC
84 XLCC=`test $bakefile_cv_c_compiler_xlc = yes && echo yes`
88 dnl Loosely based on autoconf AC_PROG_CXX
89 AC_DEFUN([AC_BAKEFILE_PROG_XLCXX],
91 _AC_BAKEFILE_LANG_COMPILER_XLC
92 XLCXX=`test $bakefile_cv_cxx_compiler_xlc = yes && echo yes`
96 dnl Based on autoconf _AC_LANG_COMPILER_GNU
97 dnl _AC_BAKEFILE_LANG_COMPILER(NAME, LANG, SYMBOL, IF-YES, IF-NO)
98 AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER],
102 [whether we are using the $1 $2 compiler],
103 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3],
111 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=yes],
112 [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=no]
117 if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3" = "xyes"; then
124 dnl recent versions of SGI mipsPro compiler define _SGI_COMPILER_VERSION
126 dnl NB: old versions define _COMPILER_VERSION but this could probably be
127 dnl defined by other compilers too so don't test for it to be safe
128 AC_DEFUN([AC_BAKEFILE_PROG_SGICC],
130 _AC_BAKEFILE_LANG_COMPILER(SGI, C, _SGI_COMPILER_VERSION, SGICC=yes)
133 AC_DEFUN([AC_BAKEFILE_PROG_SGICXX],
135 _AC_BAKEFILE_LANG_COMPILER(SGI, C++, _SGI_COMPILER_VERSION, SGICXX=yes)
138 dnl Sun compiler defines __SUNPRO_C/__SUNPRO_CC
139 AC_DEFUN([AC_BAKEFILE_PROG_SUNCC],
141 _AC_BAKEFILE_LANG_COMPILER(Sun, C, __SUNPRO_C, SUNCC=yes)
144 AC_DEFUN([AC_BAKEFILE_PROG_SUNCXX],
146 _AC_BAKEFILE_LANG_COMPILER(Sun, C++, __SUNPRO_CC, SUNCXX=yes)
149 dnl Intel icc compiler defines __INTEL_COMPILER for both C and C++
150 AC_DEFUN([AC_BAKEFILE_PROG_INTELCC],
152 _AC_BAKEFILE_LANG_COMPILER(Intel, C, __INTEL_COMPILER, INTELCC=yes)
155 AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX],
157 _AC_BAKEFILE_LANG_COMPILER(Intel, C++, __INTEL_COMPILER, INTELCXX=yes)
160 dnl HP-UX aCC: see http://docs.hp.com/en/6162/preprocess.htm#macropredef
161 AC_DEFUN([AC_BAKEFILE_PROG_HPCC],
163 _AC_BAKEFILE_LANG_COMPILER(HP, C, __HP_cc, HPCC=yes)
166 AC_DEFUN([AC_BAKEFILE_PROG_HPCXX],
168 _AC_BAKEFILE_LANG_COMPILER(HP, C++, __HP_aCC, HPCXX=yes)
172 AC_DEFUN([AC_BAKEFILE_PROG_COMPAQCC],
174 _AC_BAKEFILE_LANG_COMPILER(Compaq, C, __DECC, COMPAQCC=yes)
177 AC_DEFUN([AC_BAKEFILE_PROG_COMPAQCXX],
179 _AC_BAKEFILE_LANG_COMPILER(Compaq, C++, __DECCXX, COMPAQCXX=yes)
182 dnl ===========================================================================
183 dnl macros to detect specialty compiler options
184 dnl ===========================================================================
186 dnl Figure out if we need to pass -ext o to compiler (MetroWerks)
187 AC_DEFUN([AC_BAKEFILE_METROWERKS_EXTO],
188 [AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], bakefile_cv_[]_AC_LANG_ABBREV[]_exto,
189 dnl First create an empty conf test
190 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
191 dnl Now remove .o and .c.o or .cc.o
192 rm -f conftest.$ac_objext conftest.$ac_ext.o
193 dnl Now compile the test
194 AS_IF([AC_TRY_EVAL(ac_compile)],
195 dnl If the test succeeded look for conftest.c.o or conftest.cc.o
196 [for ac_file in `(ls conftest.* 2>/dev/null)`; do
199 bakefile_cv_[]_AC_LANG_ABBREV[]_exto="-ext o"
205 [AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile])
208 rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
209 ]) dnl AC_CACHE_CHECK
211 if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then
212 if test "[]_AC_LANG_ABBREV[]" = "c"; then
213 CFLAGS="$bakefile_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS"
215 if test "[]_AC_LANG_ABBREV[]" = "cxx"; then
216 CXXFLAGS="$bakefile_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS"
222 dnl ===========================================================================
223 dnl Macros to do all of the compiler detections as one macro
224 dnl ===========================================================================
226 dnl check for different proprietary compilers depending on target platform
227 dnl _AC_BAKEFILE_PROG_COMPILER(LANG)
228 AC_DEFUN([_AC_BAKEFILE_PROG_COMPILER],
231 AC_BAKEFILE_PROG_INTEL$1
232 dnl if we're using gcc, we can't be using any of incompatible compilers
233 if test "x$G$1" != "xyes"; then
234 if test "x$1" = "xC"; then
235 AC_BAKEFILE_METROWERKS_EXTO
236 if test "x$bakefile_cv_c_exto" '!=' "x"; then
237 unset ac_cv_prog_cc_g
242 dnl most of these compilers are only used under well-defined OS so
243 dnl don't waste time checking for them on other ones
246 AC_BAKEFILE_PROG_XL$1
250 AC_BAKEFILE_PROG_MW$1
251 AC_BAKEFILE_PROG_XL$1
255 AC_BAKEFILE_PROG_SGI$1
259 AC_BAKEFILE_PROG_HP$1
263 AC_BAKEFILE_PROG_COMPAQ$1
267 AC_BAKEFILE_PROG_SUN$1
273 AC_DEFUN([AC_BAKEFILE_PROG_CC],
275 _AC_BAKEFILE_PROG_COMPILER(CC)
278 AC_DEFUN([AC_BAKEFILE_PROG_CXX],
280 _AC_BAKEFILE_PROG_COMPILER(CXX)