You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

306 lines
7.8 KiB

  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.
  7. dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
  8. AC_PREREQ(2.13)
  9. dnl without AC_MSG_...: with AC_MSG_... and caching:
  10. dnl AC_TRY_CPP CL_CPP_CHECK
  11. dnl AC_TRY_COMPILE CL_COMPILE_CHECK
  12. dnl AC_TRY_LINK CL_LINK_CHECK
  13. dnl AC_TRY_RUN CL_RUN_CHECK - would require cross-compiling support
  14. dnl Usage:
  15. dnl AC_TRY_CPP(INCLUDES,
  16. dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
  17. dnl CL_CPP_CHECK(ECHO-TEXT, CACHE-ID,
  18. dnl INCLUDES,
  19. dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
  20. dnl AC_TRY_xxx(INCLUDES, FUNCTION-BODY,
  21. dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
  22. dnl CL_xxx_CHECK(ECHO-TEXT, CACHE-ID,
  23. dnl INCLUDES, FUNCTION-BODY,
  24. dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
  25. AC_DEFUN([CL_CPP_CHECK],
  26. [AC_MSG_CHECKING(for $1)
  27. AC_CACHE_VAL($2,[
  28. AC_TRY_CPP([$3], $2=yes, $2=no)
  29. ])
  30. AC_MSG_RESULT([$]$2)
  31. if test [$]$2 = yes; then
  32. ifelse([$4], , :, [$4])
  33. ifelse([$5], , , [else
  34. $5
  35. ])dnl
  36. fi
  37. ])
  38. AC_DEFUN([CL_COMPILE_CHECK],
  39. [AC_MSG_CHECKING(for $1)
  40. AC_CACHE_VAL($2,[
  41. AC_TRY_COMPILE([$3],[$4], $2=yes, $2=no)
  42. ])
  43. AC_MSG_RESULT([$]$2)
  44. if test [$]$2 = yes; then
  45. ifelse([$5], , :, [$5])
  46. ifelse([$6], , , [else
  47. $6
  48. ])dnl
  49. fi
  50. ])
  51. AC_DEFUN([CL_LINK_CHECK],
  52. [AC_MSG_CHECKING(for $1)
  53. AC_CACHE_VAL($2,[
  54. AC_TRY_LINK([$3],[$4], $2=yes, $2=no)
  55. ])
  56. AC_MSG_RESULT([$]$2)
  57. if test [$]$2 = yes; then
  58. ifelse([$5], , :, [$5])
  59. ifelse([$6], , , [else
  60. $6
  61. ])dnl
  62. fi
  63. ])
  64. dnl CL_SILENT(ACTION)
  65. dnl performs ACTION, with AC_MSG_CHECKING and AC_MSG_RESULT being defined away.
  66. AC_DEFUN([CL_SILENT],
  67. [pushdef([AC_MSG_CHECKING],[:])dnl
  68. pushdef([AC_CHECKING],[:])dnl
  69. pushdef([AC_MSG_RESULT],[:])dnl
  70. $1[]dnl
  71. popdef([AC_MSG_RESULT])dnl
  72. popdef([AC_CHECKING])dnl
  73. popdef([AC_MSG_CHECKING])dnl
  74. ])
  75. dnl Expands to the "extern ..." prefix used for system declarations.
  76. dnl AC_LANG_EXTERN()
  77. AC_DEFUN([AC_LANG_EXTERN],
  78. [extern
  79. #ifdef __cplusplus
  80. "C"
  81. #endif
  82. ])
  83. AC_DEFUN([CL_CC_WORKS],
  84. [AC_CACHE_CHECK(whether CC works at all, cl_cv_prog_cc_works, [
  85. AC_LANG_SAVE()
  86. AC_LANG_C()
  87. AC_TRY_RUN([
  88. #include <stdlib.h>
  89. int main() { exit(0); }
  90. ],
  91. cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no,
  92. AC_TRY_LINK([], [], cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no))
  93. AC_LANG_RESTORE()
  94. ])
  95. case "$cl_cv_prog_cc_works" in
  96. *no) echo "Installation or configuration problem: C compiler cannot create executables."; exit 1;;
  97. *yes) ;;
  98. esac
  99. ])
  100. AC_DEFUN([CL_CONFIG_SUBDIRS],
  101. [dnl No AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
  102. AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])
  103. AC_CONFIG_SUBDIRS([$1])dnl
  104. ])
  105. AC_DEFUN([CL_CANONICAL_HOST],
  106. [AC_REQUIRE([AC_PROG_CC]) dnl Actually: AC_REQUIRE([CL_CC_WORKS])
  107. dnl Set ac_aux_dir before the cache check, because AM_PROG_LIBTOOL needs it.
  108. ac_aux_dir=${srcdir}/$1
  109. dnl A substitute for AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
  110. ac_config_guess="$SHELL $ac_aux_dir/config.guess"
  111. ac_config_sub="$SHELL $ac_aux_dir/config.sub"
  112. dnl We have defined $ac_aux_dir.
  113. AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  114. dnl In autoconf-2.52, a single AC_CANONICAL_HOST has the effect of inserting
  115. dnl the code of AC_CANONICAL_BUILD *before* CL_CANONICAL_HOST, i.e. before
  116. dnl ac_aux_dir has been set. To work around this, we list AC_CANONICAL_BUILD
  117. dnl explicitly.
  118. AC_CANONICAL_BUILD
  119. AC_CANONICAL_HOST
  120. ])
  121. AC_DEFUN([CL_CANONICAL_HOST_CPU],
  122. [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
  123. case "$host_cpu" in
  124. changequote(,)dnl
  125. i[4567]86 )
  126. host_cpu=i386
  127. ;;
  128. alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
  129. host_cpu=alpha
  130. ;;
  131. hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
  132. host_cpu=hppa
  133. ;;
  134. powerpc )
  135. host_cpu=rs6000
  136. ;;
  137. c1 | c2 | c32 | c34 | c38 | c4 )
  138. host_cpu=convex
  139. ;;
  140. arm* )
  141. host_cpu=arm
  142. ;;
  143. changequote([,])dnl
  144. mips )
  145. AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
  146. AC_EGREP_CPP(yes,
  147. [#if defined(_MIPS_SZLONG)
  148. #if (_MIPS_SZLONG == 64)
  149. /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
  150. yes
  151. #endif
  152. #endif
  153. ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
  154. ])
  155. if test $cl_cv_host_mips64 = yes; then
  156. host_cpu=mips64
  157. fi
  158. ;;
  159. dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
  160. dnl still generates 32-bit code.
  161. sparc | sparc64 )
  162. AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
  163. AC_EGREP_CPP(yes,
  164. [#if defined(__sparcv9) || defined(__arch64__)
  165. yes
  166. #endif
  167. ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
  168. ])
  169. if test $cl_cv_host_sparc64 = yes; then
  170. host_cpu=sparc64
  171. else
  172. host_cpu=sparc
  173. fi
  174. ;;
  175. dnl MacOS X 10.5 machines on x86_64 platforms have 'uname -m' = "i386" even
  176. dnl if 64-bit programs are fully supported.
  177. dnl AMD64 running Linux have 'uname -m' = "x86_64" even if userland is purely
  178. dnl 32-bit.
  179. i386 | x86_64 )
  180. AC_CACHE_CHECK([for 64-bit userland on x86-64], cl_cv_host_x86_64, [
  181. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  182. [[#if !defined __x86_64__
  183. # error __x86_64__ not defined
  184. #endif
  185. ]])
  186. ], [cl_cv_host_x86_64=yes], [cl_cv_host_x86_64=no])
  187. ])
  188. if test $cl_cv_host_x86_64 = yes; then
  189. host_cpu=x86_64
  190. else
  191. host_cpu=i386
  192. fi
  193. ;;
  194. dnl PowerPC64 is another case where 'uname -m' and userland may disagree.
  195. powerpc64 )
  196. AC_CACHE_CHECK([for 64-bit userland on PowerPC64], cl_cv_host_powerpc64, [
  197. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  198. [[#if !defined __powerpc64__
  199. # error __powerpc64__ not defined
  200. #endif
  201. ]])
  202. ], [cl_cv_host_powerpc64=yes], [cl_cv_host_powerpc64=no])
  203. ])
  204. if test $cl_cv_host_powerpc64 = yes; then
  205. host_cpu=powerpc64
  206. else
  207. host_cpu=rs6000
  208. fi
  209. ;;
  210. esac
  211. dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
  212. cat >> confdefs.h <<EOF
  213. #ifndef __${host_cpu}__
  214. #define __${host_cpu}__ 1
  215. #endif
  216. EOF
  217. ])
  218. AC_DEFUN([CL_CANONICAL_HOST_CPU_FOR_FFCALL],
  219. [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
  220. case "$host_cpu" in
  221. changequote(,)dnl
  222. i[4567]86 )
  223. host_cpu=i386
  224. ;;
  225. alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
  226. host_cpu=alpha
  227. ;;
  228. hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
  229. host_cpu=hppa
  230. ;;
  231. powerpc )
  232. host_cpu=rs6000
  233. ;;
  234. c1 | c2 | c32 | c34 | c38 | c4 )
  235. host_cpu=convex
  236. ;;
  237. arm* )
  238. host_cpu=arm
  239. ;;
  240. changequote([,])dnl
  241. mips )
  242. AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
  243. AC_EGREP_CPP(yes,
  244. [#if defined(_MIPS_SZLONG)
  245. #if (_MIPS_SZLONG == 64)
  246. /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
  247. yes
  248. #endif
  249. #endif
  250. ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
  251. ])
  252. if test $cl_cv_host_mips64 = yes; then
  253. host_cpu=mips64
  254. else
  255. AC_CACHE_CHECK([for MIPS with n32 ABI], cl_cv_host_mipsn32, [
  256. dnl Strictly speaking, the MIPS ABI (-32 or -n32) is independent from the CPU
  257. dnl identification (-mips[12] or -mips[34]). But -n32 is commonly used together
  258. dnl with -mips3, and it's easier to test the CPU identification.
  259. AC_EGREP_CPP(yes,
  260. [#if __mips >= 3
  261. yes
  262. #endif
  263. ], cl_cv_host_mipsn32=yes, cl_cv_host_mipsn32=no)
  264. ])
  265. if test $cl_cv_host_mipsn32 = yes; then
  266. host_cpu=mipsn32
  267. fi
  268. fi
  269. ;;
  270. dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
  271. dnl still generates 32-bit code.
  272. sparc | sparc64 )
  273. AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
  274. AC_EGREP_CPP(yes,
  275. [#if defined(__sparcv9) || defined(__arch64__)
  276. yes
  277. #endif
  278. ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
  279. ])
  280. if test $cl_cv_host_sparc64 = yes; then
  281. host_cpu=sparc64
  282. else
  283. host_cpu=sparc
  284. fi
  285. ;;
  286. esac
  287. dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
  288. cat >> confdefs.h <<EOF
  289. #ifndef __${host_cpu}__
  290. #define __${host_cpu}__ 1
  291. #endif
  292. EOF
  293. ])