1 dnl Copyright (C) 1993-2008 Free Software Foundation, Inc.
2 dnl This file is free software, distributed under the terms of the GNU
3 dnl General Public License. As a special exception to the GNU General
4 dnl Public License, this file may be distributed as part of a program
5 dnl that contains a configuration script generated by Autoconf, under
6 dnl the same distribution terms as the rest of that program.
8 dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
12 dnl without AC_MSG_...: with AC_MSG_... and caching:
13 dnl AC_TRY_CPP CL_CPP_CHECK
14 dnl AC_TRY_COMPILE CL_COMPILE_CHECK
15 dnl AC_TRY_LINK CL_LINK_CHECK
16 dnl AC_TRY_RUN CL_RUN_CHECK - would require cross-compiling support
18 dnl AC_TRY_CPP(INCLUDES,
19 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
20 dnl CL_CPP_CHECK(ECHO-TEXT, CACHE-ID,
22 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
23 dnl AC_TRY_xxx(INCLUDES, FUNCTION-BODY,
24 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
25 dnl CL_xxx_CHECK(ECHO-TEXT, CACHE-ID,
26 dnl INCLUDES, FUNCTION-BODY,
27 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
29 AC_DEFUN([CL_CPP_CHECK],
30 [AC_MSG_CHECKING(for $1)
32 AC_TRY_CPP([$3], $2=yes, $2=no)
35 if test [$]$2 = yes; then
36 ifelse([$4], , :, [$4])
37 ifelse([$5], , , [else
43 AC_DEFUN([CL_COMPILE_CHECK],
44 [AC_MSG_CHECKING(for $1)
46 AC_TRY_COMPILE([$3],[$4], $2=yes, $2=no)
49 if test [$]$2 = yes; then
50 ifelse([$5], , :, [$5])
51 ifelse([$6], , , [else
57 AC_DEFUN([CL_LINK_CHECK],
58 [AC_MSG_CHECKING(for $1)
60 AC_TRY_LINK([$3],[$4], $2=yes, $2=no)
63 if test [$]$2 = yes; then
64 ifelse([$5], , :, [$5])
65 ifelse([$6], , , [else
72 dnl performs ACTION, with AC_MSG_CHECKING and AC_MSG_RESULT being defined away.
74 [pushdef([AC_MSG_CHECKING],[:])dnl
75 pushdef([AC_CHECKING],[:])dnl
76 pushdef([AC_MSG_RESULT],[:])dnl
78 popdef([AC_MSG_RESULT])dnl
79 popdef([AC_CHECKING])dnl
80 popdef([AC_MSG_CHECKING])dnl
83 dnl Expands to the "extern ..." prefix used for system declarations.
85 AC_DEFUN([AC_LANG_EXTERN],
92 AC_DEFUN([CL_CC_WORKS],
93 [AC_CACHE_CHECK(whether CC works at all, cl_cv_prog_cc_works, [
98 int main() { exit(0); }
100 cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no,
101 AC_TRY_LINK([], [], cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no))
104 case "$cl_cv_prog_cc_works" in
105 *no) echo "Installation or configuration problem: C compiler cannot create executables."; exit 1;;
110 AC_DEFUN([CL_CONFIG_SUBDIRS],
111 [dnl No AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
112 AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])
113 AC_CONFIG_SUBDIRS([$1])dnl
116 AC_DEFUN([CL_CANONICAL_HOST],
117 [AC_REQUIRE([AC_PROG_CC]) dnl Actually: AC_REQUIRE([CL_CC_WORKS])
118 dnl Set ac_aux_dir before the cache check, because AM_PROG_LIBTOOL needs it.
119 ac_aux_dir=${srcdir}/$1
120 dnl A substitute for AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
121 ac_config_guess="$SHELL $ac_aux_dir/config.guess"
122 ac_config_sub="$SHELL $ac_aux_dir/config.sub"
123 dnl We have defined $ac_aux_dir.
124 AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
125 dnl In autoconf-2.52, a single AC_CANONICAL_HOST has the effect of inserting
126 dnl the code of AC_CANONICAL_BUILD *before* CL_CANONICAL_HOST, i.e. before
127 dnl ac_aux_dir has been set. To work around this, we list AC_CANONICAL_BUILD
133 AC_DEFUN([CL_CANONICAL_HOST_CPU],
134 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
140 alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
143 hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
149 c1 | c2 | c32 | c34 | c38 | c4 )
157 AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
159 [#if defined(_MIPS_SZLONG)
160 #if (_MIPS_SZLONG == 64)
161 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
165 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
167 if test $cl_cv_host_mips64 = yes; then
171 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
172 dnl still generates 32-bit code.
174 AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
176 [#if defined(__sparcv9) || defined(__arch64__)
179 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
181 if test $cl_cv_host_sparc64 = yes; then
187 dnl MacOS X 10.5 machines on x86_64 platforms have 'uname -m' = "i386" even
188 dnl if 64-bit programs are fully supported.
189 dnl AMD64 running Linux have 'uname -m' = "x86_64" even if userland is purely
192 AC_CACHE_CHECK([for 64-bit userland on x86-64], cl_cv_host_x86_64, [
193 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
194 [[#if !defined __x86_64__
195 # error __x86_64__ not defined
198 ], [cl_cv_host_x86_64=yes], [cl_cv_host_x86_64=no])
200 if test $cl_cv_host_x86_64 = yes; then
206 dnl PowerPC64 is another case where 'uname -m' and userland may disagree.
208 AC_CACHE_CHECK([for 64-bit userland on PowerPC64], cl_cv_host_powerpc64, [
209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
210 [[#if !defined __powerpc64__
211 # error __powerpc64__ not defined
214 ], [cl_cv_host_powerpc64=yes], [cl_cv_host_powerpc64=no])
216 if test $cl_cv_host_powerpc64 = yes; then
223 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
224 cat >> confdefs.h <<EOF
225 #ifndef __${host_cpu}__
226 #define __${host_cpu}__ 1
231 AC_DEFUN([CL_CANONICAL_HOST_CPU_FOR_FFCALL],
232 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
238 alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
241 hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
247 c1 | c2 | c32 | c34 | c38 | c4 )
255 AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
257 [#if defined(_MIPS_SZLONG)
258 #if (_MIPS_SZLONG == 64)
259 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
263 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
265 if test $cl_cv_host_mips64 = yes; then
268 AC_CACHE_CHECK([for MIPS with n32 ABI], cl_cv_host_mipsn32, [
269 dnl Strictly speaking, the MIPS ABI (-32 or -n32) is independent from the CPU
270 dnl identification (-mips[12] or -mips[34]). But -n32 is commonly used together
271 dnl with -mips3, and it's easier to test the CPU identification.
276 ], cl_cv_host_mipsn32=yes, cl_cv_host_mipsn32=no)
278 if test $cl_cv_host_mipsn32 = yes; then
283 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
284 dnl still generates 32-bit code.
286 AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
288 [#if defined(__sparcv9) || defined(__arch64__)
291 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
293 if test $cl_cv_host_sparc64 = yes; then
300 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
301 cat >> confdefs.h <<EOF
302 #ifndef __${host_cpu}__
303 #define __${host_cpu}__ 1