acx.m4 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. # Autoconf M4 include file defining utility macros for complex Canadian
  2. # cross builds.
  3. dnl ####
  4. dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
  5. dnl # $build_alias or canonical $build if blank.
  6. dnl # Used when we would use $build_alias, but empty is not OK.
  7. AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_BUILD],
  8. [AC_REQUIRE([AC_CANONICAL_BUILD]) []dnl
  9. case ${build_alias} in
  10. "") build_noncanonical=${build} ;;
  11. *) build_noncanonical=${build_alias} ;;
  12. esac
  13. ]) []dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
  14. dnl ####
  15. dnl # _GCC_TOPLEV_NONCANONICAL_HOST
  16. dnl # $host_alias, or $build_noncanonical if blank.
  17. dnl # Used when we would use $host_alias, but empty is not OK.
  18. AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_HOST],
  19. [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
  20. case ${host_alias} in
  21. "") host_noncanonical=${build_noncanonical} ;;
  22. *) host_noncanonical=${host_alias} ;;
  23. esac
  24. ]) []dnl # _GCC_TOPLEV_NONCANONICAL_HOST
  25. dnl ####
  26. dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
  27. dnl # $target_alias or $host_noncanonical if blank.
  28. dnl # Used when we would use $target_alias, but empty is not OK.
  29. AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_TARGET],
  30. [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
  31. case ${target_alias} in
  32. "") target_noncanonical=${host_noncanonical} ;;
  33. *) target_noncanonical=${target_alias} ;;
  34. esac
  35. ]) []dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
  36. dnl ####
  37. dnl # ACX_NONCANONICAL_BUILD
  38. dnl # Like underscored version, but AC_SUBST's.
  39. AC_DEFUN([ACX_NONCANONICAL_BUILD],
  40. [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
  41. AC_SUBST(build_noncanonical)
  42. ]) []dnl # ACX_NONCANONICAL_BUILD
  43. dnl ####
  44. dnl # ACX_NONCANONICAL_HOST
  45. dnl # Like underscored version, but AC_SUBST's.
  46. AC_DEFUN([ACX_NONCANONICAL_HOST],
  47. [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
  48. AC_SUBST(host_noncanonical)
  49. ]) []dnl # ACX_NONCANONICAL_HOST
  50. dnl ####
  51. dnl # ACX_NONCANONICAL_TARGET
  52. dnl # Like underscored version, but AC_SUBST's.
  53. AC_DEFUN([ACX_NONCANONICAL_TARGET],
  54. [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
  55. AC_SUBST(target_noncanonical)
  56. ]) []dnl # ACX_NONCANONICAL_TARGET
  57. dnl ####
  58. dnl # GCC_TOPLEV_SUBDIRS
  59. dnl # GCC & friends build 'build', 'host', and 'target' tools. These must
  60. dnl # be separated into three well-known subdirectories of the build directory:
  61. dnl # build_subdir, host_subdir, and target_subdir. The values are determined
  62. dnl # here so that they can (theoretically) be changed in the future. They
  63. dnl # were previously reproduced across many different files.
  64. dnl #
  65. dnl # This logic really amounts to very little with autoconf 2.13; it will
  66. dnl # amount to a lot more with autoconf 2.5x.
  67. AC_DEFUN([GCC_TOPLEV_SUBDIRS],
  68. [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
  69. AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
  70. # post-stage1 host modules use a different CC_FOR_BUILD so, in order to
  71. # have matching libraries, they should use host libraries: Makefile.tpl
  72. # arranges to pass --with-build-libsubdir=$(HOST_SUBDIR).
  73. # However, they still use the build modules, because the corresponding
  74. # host modules (e.g. bison) are only built for the host when bootstrap
  75. # finishes. So:
  76. # - build_subdir is where we find build modules, and never changes.
  77. # - build_libsubdir is where we find build libraries, and can be overridden.
  78. # Prefix 'build-' so this never conflicts with target_subdir.
  79. build_subdir="build-${build_noncanonical}"
  80. AC_ARG_WITH(build-libsubdir,
  81. [ --with-build-libsubdir=[DIR] Directory where to find libraries for build system],
  82. build_libsubdir="$withval",
  83. build_libsubdir="$build_subdir")
  84. # --srcdir=. covers the toplevel, while "test -d" covers the subdirectories
  85. if ( test $srcdir = . && test -d gcc ) \
  86. || test -d $srcdir/../host-${host_noncanonical}; then
  87. host_subdir="host-${host_noncanonical}"
  88. else
  89. host_subdir=.
  90. fi
  91. # No prefix.
  92. target_subdir=${target_noncanonical}
  93. AC_SUBST([build_libsubdir]) []dnl
  94. AC_SUBST([build_subdir]) []dnl
  95. AC_SUBST([host_subdir]) []dnl
  96. AC_SUBST([target_subdir]) []dnl
  97. ]) []dnl # GCC_TOPLEV_SUBDIRS
  98. ####
  99. # _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM
  100. # or AC_INIT.
  101. # These demand that AC_CANONICAL_SYSTEM be called beforehand.
  102. AC_DEFUN([_NCN_TOOL_PREFIXES],
  103. [ncn_tool_prefix=
  104. test -n "$host_alias" && ncn_tool_prefix=$host_alias-
  105. ncn_target_tool_prefix=
  106. test -n "$target_alias" && ncn_target_tool_prefix=$target_alias-
  107. ]) []dnl # _NCN_TOOL_PREFIXES
  108. ####
  109. # NCN_STRICT_CHECK_TOOLS(variable, progs-to-check-for,[value-if-not-found],[path])
  110. # Like plain AC_CHECK_TOOLS, but require prefix if build!=host.
  111. AC_DEFUN([NCN_STRICT_CHECK_TOOLS],
  112. [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
  113. AC_ARG_VAR([$1], [$1 for the host])
  114. if test -n "[$]$1"; then
  115. ac_cv_prog_$1=[$]$1
  116. elif test -n "$ac_cv_prog_$1"; then
  117. $1=$ac_cv_prog_$1
  118. fi
  119. if test -n "$ac_cv_prog_$1"; then
  120. for ncn_progname in $2; do
  121. AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
  122. done
  123. fi
  124. for ncn_progname in $2; do
  125. if test -n "$ncn_tool_prefix"; then
  126. AC_CHECK_PROG([$1], [${ncn_tool_prefix}${ncn_progname}],
  127. [${ncn_tool_prefix}${ncn_progname}], , [$4])
  128. fi
  129. if test -z "$ac_cv_prog_$1" && test $build = $host ; then
  130. AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
  131. fi
  132. test -n "$ac_cv_prog_$1" && break
  133. done
  134. if test -z "$ac_cv_prog_$1" ; then
  135. ifelse([$3],[], [set dummy $2
  136. if test $build = $host ; then
  137. $1="[$]2"
  138. else
  139. $1="${ncn_tool_prefix}[$]2"
  140. fi], [$1="$3"])
  141. fi
  142. ]) []dnl # NCN_STRICT_CHECK_TOOLS
  143. ####
  144. # NCN_STRICT_CHECK_TARGET_TOOLS(variable, progs-to-check-for,[value-if-not-found],[path])
  145. # Like CVS Autoconf AC_CHECK_TARGET_TOOLS, but require prefix if build!=target.
  146. AC_DEFUN([NCN_STRICT_CHECK_TARGET_TOOLS],
  147. [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
  148. AC_ARG_VAR([$1], patsubst([$1], [_FOR_TARGET$], [])[ for the target])
  149. if test -n "[$]$1"; then
  150. ac_cv_prog_$1=[$]$1
  151. elif test -n "$ac_cv_prog_$1"; then
  152. $1=$ac_cv_prog_$1
  153. fi
  154. if test -n "$ac_cv_prog_$1"; then
  155. for ncn_progname in $2; do
  156. AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
  157. done
  158. fi
  159. if test -z "$ac_cv_prog_$1" && test -n "$with_build_time_tools"; then
  160. for ncn_progname in $2; do
  161. AC_MSG_CHECKING([for ${ncn_progname} in $with_build_time_tools])
  162. if test -x $with_build_time_tools/${ncn_progname}; then
  163. ac_cv_prog_$1=$with_build_time_tools/${ncn_progname}
  164. AC_MSG_RESULT(yes)
  165. break
  166. else
  167. AC_MSG_RESULT(no)
  168. fi
  169. done
  170. fi
  171. if test -z "$ac_cv_prog_$1"; then
  172. for ncn_progname in $2; do
  173. if test -n "$ncn_target_tool_prefix"; then
  174. AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}${ncn_progname}],
  175. [${ncn_target_tool_prefix}${ncn_progname}], , [$4])
  176. fi
  177. if test -z "$ac_cv_prog_$1" && test $build = $target ; then
  178. AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
  179. fi
  180. test -n "$ac_cv_prog_$1" && break
  181. done
  182. fi
  183. if test -z "$ac_cv_prog_$1" ; then
  184. ifelse([$3],[], [set dummy $2
  185. if test $build = $target ; then
  186. $1="[$]2"
  187. else
  188. $1="${ncn_target_tool_prefix}[$]2"
  189. fi], [$1="$3"])
  190. else
  191. $1="$ac_cv_prog_$1"
  192. fi
  193. ]) []dnl # NCN_STRICT_CHECK_TARGET_TOOLS
  194. # Backported from Autoconf 2.5x; can go away when and if
  195. # we switch. Put the OS path separator in $PATH_SEPARATOR.
  196. AC_DEFUN([ACX_PATH_SEP], [
  197. # The user is always right.
  198. if test "${PATH_SEPARATOR+set}" != set; then
  199. echo "#! /bin/sh" >conf$$.sh
  200. echo "exit 0" >>conf$$.sh
  201. chmod +x conf$$.sh
  202. if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
  203. PATH_SEPARATOR=';'
  204. else
  205. PATH_SEPARATOR=:
  206. fi
  207. rm -f conf$$.sh
  208. fi
  209. ])
  210. AC_DEFUN([ACX_TOOL_DIRS], [
  211. AC_REQUIRE([ACX_PATH_SEP])
  212. if test "x$exec_prefix" = xNONE; then
  213. if test "x$prefix" = xNONE; then
  214. gcc_cv_tool_prefix=$ac_default_prefix
  215. else
  216. gcc_cv_tool_prefix=$prefix
  217. fi
  218. else
  219. gcc_cv_tool_prefix=$exec_prefix
  220. fi
  221. # If there is no compiler in the tree, use the PATH only. In any
  222. # case, if there is no compiler in the tree nobody should use
  223. # AS_FOR_TARGET and LD_FOR_TARGET.
  224. if test x$host = x$build && test -f $srcdir/gcc/BASE-VER; then
  225. gcc_version=`cat $srcdir/gcc/BASE-VER`
  226. gcc_cv_tool_dirs="$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
  227. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical$PATH_SEPARATOR"
  228. gcc_cv_tool_dirs="$gcc_cv_tool_dirs/usr/lib/gcc/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
  229. gcc_cv_tool_dirs="$gcc_cv_tool_dirs/usr/lib/gcc/$target_noncanonical$PATH_SEPARATOR"
  230. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
  231. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/$target_noncanonical/bin$PATH_SEPARATOR"
  232. else
  233. gcc_cv_tool_dirs=
  234. fi
  235. if test x$build = x$target && test -n "$md_exec_prefix"; then
  236. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$md_exec_prefix$PATH_SEPARATOR"
  237. fi
  238. ]) []dnl # ACX_TOOL_DIRS
  239. # ACX_HAVE_GCC_FOR_TARGET
  240. # Check if the variable GCC_FOR_TARGET really points to a GCC binary.
  241. AC_DEFUN([ACX_HAVE_GCC_FOR_TARGET], [
  242. cat > conftest.c << \EOF
  243. #ifdef __GNUC__
  244. gcc_yay;
  245. #endif
  246. EOF
  247. if ($GCC_FOR_TARGET -E conftest.c | grep gcc_yay) > /dev/null 2>&1; then
  248. have_gcc_for_target=yes
  249. else
  250. GCC_FOR_TARGET=${ncn_target_tool_prefix}gcc
  251. have_gcc_for_target=no
  252. fi
  253. rm conftest.c
  254. ])
  255. # ACX_CHECK_INSTALLED_TARGET_TOOL(VAR, PROG)
  256. # Searching for installed target binutils. We need to take extra care,
  257. # else we may find the wrong assembler, linker, etc., and lose.
  258. #
  259. # First try --with-build-time-tools, if specified.
  260. #
  261. # For build != host, we ask the installed GCC for the name of the tool it
  262. # uses, and accept it if it is an absolute path. This is because the
  263. # only good choice for a compiler is the same GCC version that is being
  264. # installed (or we couldn't make target libraries), and we assume that
  265. # on the host system we'll have not only the same GCC version, but also
  266. # the same binutils version.
  267. #
  268. # For build == host, search the same directories that the installed
  269. # compiler will search. We used to do this for the assembler, linker,
  270. # and nm only; for simplicity of configuration, however, we extend this
  271. # criterion to tools (such as ar and ranlib) that are never invoked by
  272. # the compiler, to avoid mismatches.
  273. #
  274. # Also note we have to check MD_EXEC_PREFIX before checking the user's path
  275. # if build == target. This makes the most sense only when bootstrapping,
  276. # but we also do so when build != host. In this case, we hope that the
  277. # build and host systems will have similar contents of MD_EXEC_PREFIX.
  278. #
  279. # If we do not find a suitable binary, then try the user's path.
  280. AC_DEFUN([ACX_CHECK_INSTALLED_TARGET_TOOL], [
  281. AC_REQUIRE([ACX_TOOL_DIRS])
  282. AC_REQUIRE([ACX_HAVE_GCC_FOR_TARGET])
  283. if test -z "$ac_cv_path_$1" ; then
  284. if test -n "$with_build_time_tools"; then
  285. AC_MSG_CHECKING([for $2 in $with_build_time_tools])
  286. if test -x $with_build_time_tools/$2; then
  287. $1=`cd $with_build_time_tools && pwd`/$2
  288. ac_cv_path_$1=[$]$1
  289. AC_MSG_RESULT([$ac_cv_path_$1])
  290. else
  291. AC_MSG_RESULT(no)
  292. fi
  293. elif test $build != $host && test $have_gcc_for_target = yes; then
  294. $1=`$GCC_FOR_TARGET --print-prog-name=$2`
  295. test [$]$1 = $2 && $1=
  296. test -n "[$]$1" && ac_cv_path_$1=[$]$1
  297. fi
  298. fi
  299. if test -z "$ac_cv_path_$1" && test -n "$gcc_cv_tool_dirs"; then
  300. AC_PATH_PROG([$1], [$2], [], [$gcc_cv_tool_dirs])
  301. fi
  302. if test -z "$ac_cv_path_$1" ; then
  303. NCN_STRICT_CHECK_TARGET_TOOLS([$1], [$2])
  304. else
  305. $1=$ac_cv_path_$1
  306. fi
  307. ]) []dnl # ACX_CHECK_INSTALLED_TARGET_TOOL
  308. ###
  309. # AC_PROG_CPP_WERROR
  310. # Used for autoconf 2.5x to force AC_PREPROC_IFELSE to reject code which
  311. # triggers warnings from the preprocessor. Will be in autoconf 2.58.
  312. # For now, using this also overrides header checks to use only the
  313. # preprocessor (matches 2.13 behavior; matching 2.58's behavior is a
  314. # bit harder from here).
  315. # Eventually autoconf will default to checking headers with the compiler
  316. # instead, and we'll have to do this differently.
  317. AC_DEFUN([AC_PROG_CPP_WERROR],
  318. [AC_REQUIRE([AC_PROG_CPP])dnl
  319. m4_define([AC_CHECK_HEADER],m4_defn([_AC_CHECK_HEADER_OLD]))
  320. ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
  321. # Test for GNAT.
  322. # We require the gnatbind & gnatmake programs, as well as a compiler driver
  323. # that understands Ada. We use the user's CC setting, already found, and
  324. # possibly add $1 to the command-line parameters.
  325. #
  326. # Sets the shell variable have_gnat to yes or no as appropriate, and
  327. # substitutes GNATBIND and GNATMAKE.
  328. AC_DEFUN([ACX_PROG_GNAT],
  329. [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
  330. AC_REQUIRE([AC_PROG_CC])
  331. AC_CHECK_TOOL(GNATBIND, gnatbind, no)
  332. AC_CHECK_TOOL(GNATMAKE, gnatmake, no)
  333. AC_CACHE_CHECK([whether compiler driver understands Ada],
  334. acx_cv_cc_gcc_supports_ada,
  335. [cat >conftest.adb <<EOF
  336. procedure conftest is begin null; end conftest;
  337. EOF
  338. acx_cv_cc_gcc_supports_ada=no
  339. # There is a bug in old released versions of GCC which causes the
  340. # driver to exit successfully when the appropriate language module
  341. # has not been installed. This is fixed in 2.95.4, 3.0.2, and 3.1.
  342. # Therefore we must check for the error message as well as an
  343. # unsuccessful exit.
  344. # Other compilers, like HP Tru64 UNIX cc, exit successfully when
  345. # given a .adb file, but produce no object file. So we must check
  346. # if an object file was really produced to guard against this.
  347. errors=`(${CC} $1[]m4_ifval([$1], [ ])-c conftest.adb) 2>&1 || echo failure`
  348. if test x"$errors" = x && test -f conftest.$ac_objext; then
  349. acx_cv_cc_gcc_supports_ada=yes
  350. fi
  351. rm -f conftest.*])
  352. if test "x$GNATBIND" != xno && test "x$GNATMAKE" != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
  353. have_gnat=yes
  354. else
  355. have_gnat=no
  356. fi
  357. ])
  358. dnl 'make compare' can be significantly faster, if cmp itself can
  359. dnl skip bytes instead of using tail. The test being performed is
  360. dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
  361. dnl but we need to sink errors and handle broken shells. We also test
  362. dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
  363. dnl accepted by cmp on some systems.
  364. AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
  365. [AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
  366. [ echo abfoo >t1
  367. echo cdfoo >t2
  368. gcc_cv_prog_cmp_skip='tail +16c $$f1 > tmp-foo1; tail +16c $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
  369. if cmp t1 t2 2 2 > /dev/null 2>&1; then
  370. if cmp t1 t2 1 1 > /dev/null 2>&1; then
  371. :
  372. else
  373. gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
  374. fi
  375. fi
  376. if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
  377. if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
  378. :
  379. else
  380. gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
  381. fi
  382. fi
  383. rm t1 t2
  384. ])
  385. do_compare="$gcc_cv_prog_cmp_skip"
  386. AC_SUBST(do_compare)
  387. ])
  388. dnl See whether we can include both string.h and strings.h.
  389. AC_DEFUN([ACX_HEADER_STRING],
  390. [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
  391. gcc_cv_header_string,
  392. [AC_TRY_COMPILE([#include <string.h>
  393. #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
  394. if test $gcc_cv_header_string = yes; then
  395. AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
  396. fi
  397. ])
  398. dnl See if stdbool.h properly defines bool and true/false.
  399. dnl Check whether _Bool is built-in.
  400. AC_DEFUN([ACX_HEADER_STDBOOL],
  401. [AC_CACHE_CHECK([for working stdbool.h],
  402. ac_cv_header_stdbool_h,
  403. [AC_TRY_COMPILE([#include <stdbool.h>],
  404. [bool foo = false;],
  405. ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
  406. if test $ac_cv_header_stdbool_h = yes; then
  407. AC_DEFINE(HAVE_STDBOOL_H, 1,
  408. [Define if you have a working <stdbool.h> header file.])
  409. fi
  410. AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
  411. [AC_TRY_COMPILE(,
  412. [_Bool foo;],
  413. gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
  414. ])
  415. if test $gcc_cv_c__bool = yes; then
  416. AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
  417. fi
  418. ])
  419. dnl See if hard links work and if not, try to substitute $1 or simple copy.
  420. AC_DEFUN([ACX_PROG_LN],
  421. [AC_MSG_CHECKING(whether ln works)
  422. AC_CACHE_VAL(acx_cv_prog_LN,
  423. [rm -f conftestdata_t
  424. echo >conftestdata_f
  425. if ln conftestdata_f conftestdata_t 2>/dev/null
  426. then
  427. acx_cv_prog_LN=ln
  428. else
  429. acx_cv_prog_LN=no
  430. fi
  431. rm -f conftestdata_f conftestdata_t
  432. ])dnl
  433. if test $acx_cv_prog_LN = no; then
  434. LN="ifelse([$1],,cp,[$1])"
  435. AC_MSG_RESULT([no, using $LN])
  436. else
  437. LN="$acx_cv_prog_LN"
  438. AC_MSG_RESULT(yes)
  439. fi
  440. AC_SUBST(LN)dnl
  441. ])
  442. dnl GCC_TARGET_TOOL(PROGRAM, TARGET-VAR, HOST-VAR, IN-TREE-TOOL, LANGUAGE)
  443. AC_DEFUN([GCC_TARGET_TOOL],
  444. [AC_MSG_CHECKING(where to find the target $1)
  445. if test "x${build}" != "x${host}" ; then
  446. if expr "x[$]$2" : "x/" > /dev/null; then
  447. # We already found the complete path
  448. ac_dir=`dirname [$]$2`
  449. AC_MSG_RESULT(pre-installed in $ac_dir)
  450. else
  451. # Canadian cross, just use what we found
  452. AC_MSG_RESULT(pre-installed)
  453. fi
  454. else
  455. ifelse([$4],,,
  456. [ok=yes
  457. case " ${configdirs} " in
  458. *" patsubst([$4], [/.*], []) "*) ;;
  459. *) ok=no ;;
  460. esac
  461. ifelse([$5],,,
  462. [case ,${enable_languages}, in
  463. *,$5,*) ;;
  464. *) ok=no ;;
  465. esac])
  466. if test $ok = yes; then
  467. # An in-tree tool is available and we can use it
  468. $2='$$r/$(HOST_SUBDIR)/$4'
  469. AC_MSG_RESULT(just compiled)
  470. el])if expr "x[$]$2" : "x/" > /dev/null; then
  471. # We already found the complete path
  472. ac_dir=`dirname [$]$2`
  473. AC_MSG_RESULT(pre-installed in $ac_dir)
  474. elif test "x$target" = "x$host"; then
  475. # We can use an host tool
  476. $2='$($3)'
  477. AC_MSG_RESULT(host tool)
  478. else
  479. # We need a cross tool
  480. AC_MSG_RESULT(pre-installed)
  481. fi
  482. fi
  483. AC_SUBST($2)])
  484. dnl Locate a program and check that its version is acceptable.
  485. dnl ACX_PROG_CHECK_VER(var, name, version-switch,
  486. dnl version-extract-regexp, version-glob)
  487. AC_DEFUN([ACX_CHECK_PROG_VER],[
  488. AC_CHECK_PROG([$1], [$2], [$2])
  489. if test -n "[$]$1"; then
  490. # Found it, now check the version.
  491. AC_CACHE_CHECK([for modern $2],
  492. [gcc_cv_prog_$2_modern],
  493. [ac_prog_version=`eval [$]$1 $3 2>&1 |
  494. sed -n 's/^.*patsubst([[$4]],/,\/).*$/\1/p'`
  495. [case $ac_prog_version in
  496. '') gcc_cv_prog_$2_modern=no;;
  497. $5) gcc_cv_prog_$2_modern=yes;;
  498. *) gcc_cv_prog_$2_modern=no;;
  499. esac]
  500. ])
  501. else
  502. gcc_cv_prog_$2_modern=no
  503. fi
  504. if test $gcc_cv_prog_$2_modern = no; then
  505. $1="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing $2"
  506. fi
  507. ])
  508. dnl Support the --with-pkgversion configure option.
  509. dnl ACX_PKGVERSION(default-pkgversion)
  510. AC_DEFUN([ACX_PKGVERSION],[
  511. AC_ARG_WITH(pkgversion,
  512. AS_HELP_STRING([--with-pkgversion=PKG],
  513. [Use PKG in the version string in place of "$1"]),
  514. [case "$withval" in
  515. yes) AC_MSG_ERROR([package version not specified]) ;;
  516. no) PKGVERSION= ;;
  517. *) PKGVERSION="($withval) " ;;
  518. esac],
  519. PKGVERSION="($1) "
  520. )
  521. AC_SUBST(PKGVERSION)
  522. ])
  523. dnl Support the --with-bugurl configure option.
  524. dnl ACX_BUGURL(default-bugurl)
  525. AC_DEFUN([ACX_BUGURL],[
  526. AC_ARG_WITH(bugurl,
  527. AS_HELP_STRING([--with-bugurl=URL],
  528. [Direct users to URL to report a bug]),
  529. [case "$withval" in
  530. yes) AC_MSG_ERROR([bug URL not specified]) ;;
  531. no) BUGURL=
  532. ;;
  533. *) BUGURL="$withval"
  534. ;;
  535. esac],
  536. BUGURL="$1"
  537. )
  538. case ${BUGURL} in
  539. "")
  540. REPORT_BUGS_TO=
  541. REPORT_BUGS_TEXI=
  542. ;;
  543. *)
  544. REPORT_BUGS_TO="<$BUGURL>"
  545. REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
  546. ;;
  547. esac;
  548. AC_SUBST(REPORT_BUGS_TO)
  549. AC_SUBST(REPORT_BUGS_TEXI)
  550. ])
  551. dnl ####
  552. dnl # ACX_CHECK_CYGWIN_CAT_WORKS
  553. dnl # On Cygwin hosts, check that the cat command ignores
  554. dnl # carriage returns as otherwise builds will not work.
  555. dnl # See binutils PR 4334 for more details.
  556. AC_DEFUN([ACX_CHECK_CYGWIN_CAT_WORKS],[
  557. AC_MSG_CHECKING([to see if cat works as expected])
  558. echo a >cygwin-cat-check
  559. if test `cat cygwin-cat-check` = a ; then
  560. rm cygwin-cat-check
  561. AC_MSG_RESULT(yes)
  562. else
  563. rm cygwin-cat-check
  564. AC_MSG_RESULT(no)
  565. AC_MSG_ERROR([The cat command does not ignore carriage return characters.
  566. Please either mount the build directory in binary mode or run the following
  567. commands before running any configure script:
  568. set -o igncr
  569. export SHELLOPTS
  570. ])
  571. fi
  572. ])