acx.m4 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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. dnl ####
  211. dnl # GCC_BASE_VER
  212. dnl # Determine GCC version number to use in compiler directories.
  213. AC_DEFUN([GCC_BASE_VER],
  214. [
  215. get_gcc_base_ver="cat"
  216. AC_ARG_WITH(gcc-major-version-only,
  217. [AS_HELP_STRING([--with-gcc-major-version-only], [use only GCC major number in filesystem paths])],
  218. [if test x$with_gcc_major_version_only = xyes ; then
  219. changequote(,)dnl
  220. get_gcc_base_ver="sed -e 's/^\([0-9]*\).*/\1/'"
  221. changequote([,])dnl
  222. fi
  223. ])
  224. AC_SUBST(get_gcc_base_ver)
  225. ])
  226. AC_DEFUN([ACX_TOOL_DIRS], [
  227. AC_REQUIRE([ACX_PATH_SEP])
  228. AC_REQUIRE([GCC_BASE_VER])
  229. if test "x$exec_prefix" = xNONE; then
  230. if test "x$prefix" = xNONE; then
  231. gcc_cv_tool_prefix=$ac_default_prefix
  232. else
  233. gcc_cv_tool_prefix=$prefix
  234. fi
  235. else
  236. gcc_cv_tool_prefix=$exec_prefix
  237. fi
  238. # If there is no compiler in the tree, use the PATH only. In any
  239. # case, if there is no compiler in the tree nobody should use
  240. # AS_FOR_TARGET and LD_FOR_TARGET.
  241. if test x$host = x$build && test -f $srcdir/gcc/BASE-VER; then
  242. if test x$with_gcc_major_version_only = xyes ; then
  243. changequote(,)dnl
  244. gcc_version=`sed -e 's/^\([0-9]*\).*$/\1/' $srcdir/gcc/BASE-VER`
  245. changequote([,])dnl
  246. else
  247. gcc_version=`cat $srcdir/gcc/BASE-VER`
  248. fi
  249. gcc_cv_tool_dirs="$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
  250. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical$PATH_SEPARATOR"
  251. gcc_cv_tool_dirs="$gcc_cv_tool_dirs/usr/lib/gcc/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
  252. gcc_cv_tool_dirs="$gcc_cv_tool_dirs/usr/lib/gcc/$target_noncanonical$PATH_SEPARATOR"
  253. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
  254. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/$target_noncanonical/bin$PATH_SEPARATOR"
  255. else
  256. gcc_cv_tool_dirs=
  257. fi
  258. if test x$build = x$target && test -n "$md_exec_prefix"; then
  259. gcc_cv_tool_dirs="$gcc_cv_tool_dirs$md_exec_prefix$PATH_SEPARATOR"
  260. fi
  261. ]) []dnl # ACX_TOOL_DIRS
  262. # ACX_HAVE_GCC_FOR_TARGET
  263. # Check if the variable GCC_FOR_TARGET really points to a GCC binary.
  264. AC_DEFUN([ACX_HAVE_GCC_FOR_TARGET], [
  265. cat > conftest.c << \EOF
  266. #ifdef __GNUC__
  267. gcc_yay;
  268. #endif
  269. EOF
  270. if ($GCC_FOR_TARGET -E conftest.c | grep gcc_yay) > /dev/null 2>&1; then
  271. have_gcc_for_target=yes
  272. else
  273. GCC_FOR_TARGET=${ncn_target_tool_prefix}gcc
  274. have_gcc_for_target=no
  275. fi
  276. rm conftest.c
  277. ])
  278. # ACX_CHECK_INSTALLED_TARGET_TOOL(VAR, PROG)
  279. # Searching for installed target binutils. We need to take extra care,
  280. # else we may find the wrong assembler, linker, etc., and lose.
  281. #
  282. # First try --with-build-time-tools, if specified.
  283. #
  284. # For build != host, we ask the installed GCC for the name of the tool it
  285. # uses, and accept it if it is an absolute path. This is because the
  286. # only good choice for a compiler is the same GCC version that is being
  287. # installed (or we couldn't make target libraries), and we assume that
  288. # on the host system we'll have not only the same GCC version, but also
  289. # the same binutils version.
  290. #
  291. # For build == host, search the same directories that the installed
  292. # compiler will search. We used to do this for the assembler, linker,
  293. # and nm only; for simplicity of configuration, however, we extend this
  294. # criterion to tools (such as ar and ranlib) that are never invoked by
  295. # the compiler, to avoid mismatches.
  296. #
  297. # Also note we have to check MD_EXEC_PREFIX before checking the user's path
  298. # if build == target. This makes the most sense only when bootstrapping,
  299. # but we also do so when build != host. In this case, we hope that the
  300. # build and host systems will have similar contents of MD_EXEC_PREFIX.
  301. #
  302. # If we do not find a suitable binary, then try the user's path.
  303. AC_DEFUN([ACX_CHECK_INSTALLED_TARGET_TOOL], [
  304. AC_REQUIRE([ACX_TOOL_DIRS])
  305. AC_REQUIRE([ACX_HAVE_GCC_FOR_TARGET])
  306. if test -z "$ac_cv_path_$1" ; then
  307. if test -n "$with_build_time_tools"; then
  308. AC_MSG_CHECKING([for $2 in $with_build_time_tools])
  309. if test -x $with_build_time_tools/$2; then
  310. $1=`cd $with_build_time_tools && pwd`/$2
  311. ac_cv_path_$1=[$]$1
  312. AC_MSG_RESULT([$ac_cv_path_$1])
  313. else
  314. AC_MSG_RESULT(no)
  315. fi
  316. elif test $build != $host && test $have_gcc_for_target = yes; then
  317. $1=`$GCC_FOR_TARGET --print-prog-name=$2`
  318. test [$]$1 = $2 && $1=
  319. test -n "[$]$1" && ac_cv_path_$1=[$]$1
  320. fi
  321. fi
  322. if test -z "$ac_cv_path_$1" && test -n "$gcc_cv_tool_dirs"; then
  323. AC_PATH_PROG([$1], [$2], [], [$gcc_cv_tool_dirs])
  324. fi
  325. if test -z "$ac_cv_path_$1" ; then
  326. NCN_STRICT_CHECK_TARGET_TOOLS([$1], [$2])
  327. else
  328. $1=$ac_cv_path_$1
  329. fi
  330. ]) []dnl # ACX_CHECK_INSTALLED_TARGET_TOOL
  331. ###
  332. # AC_PROG_CPP_WERROR
  333. # Used for autoconf 2.5x to force AC_PREPROC_IFELSE to reject code which
  334. # triggers warnings from the preprocessor. Will be in autoconf 2.58.
  335. # For now, using this also overrides header checks to use only the
  336. # preprocessor (matches 2.13 behavior; matching 2.58's behavior is a
  337. # bit harder from here).
  338. # Eventually autoconf will default to checking headers with the compiler
  339. # instead, and we'll have to do this differently.
  340. AC_DEFUN([AC_PROG_CPP_WERROR],
  341. [AC_REQUIRE([AC_PROG_CPP])dnl
  342. m4_define([AC_CHECK_HEADER],m4_defn([_AC_CHECK_HEADER_OLD]))
  343. ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
  344. # Test for GNAT.
  345. # We require the gnatbind & gnatmake programs, as well as a compiler driver
  346. # that understands Ada. We use the user's CC setting, already found, and
  347. # possibly add $1 to the command-line parameters.
  348. #
  349. # Sets the shell variable have_gnat to yes or no as appropriate, and
  350. # substitutes GNATBIND and GNATMAKE.
  351. AC_DEFUN([ACX_PROG_GNAT],
  352. [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
  353. AC_REQUIRE([AC_PROG_CC])
  354. AC_CHECK_TOOL(GNATBIND, gnatbind, no)
  355. AC_CHECK_TOOL(GNATMAKE, gnatmake, no)
  356. AC_CACHE_CHECK([whether compiler driver understands Ada],
  357. acx_cv_cc_gcc_supports_ada,
  358. [cat >conftest.adb <<EOF
  359. procedure conftest is begin null; end conftest;
  360. EOF
  361. acx_cv_cc_gcc_supports_ada=no
  362. # There is a bug in old released versions of GCC which causes the
  363. # driver to exit successfully when the appropriate language module
  364. # has not been installed. This is fixed in 2.95.4, 3.0.2, and 3.1.
  365. # Therefore we must check for the error message as well as an
  366. # unsuccessful exit.
  367. # Other compilers, like HP Tru64 UNIX cc, exit successfully when
  368. # given a .adb file, but produce no object file. So we must check
  369. # if an object file was really produced to guard against this.
  370. errors=`(${CC} $1[]m4_ifval([$1], [ ])-c conftest.adb) 2>&1 || echo failure`
  371. if test x"$errors" = x && test -f conftest.$ac_objext; then
  372. acx_cv_cc_gcc_supports_ada=yes
  373. fi
  374. rm -f conftest.*])
  375. if test "x$GNATBIND" != xno && test "x$GNATMAKE" != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
  376. have_gnat=yes
  377. else
  378. have_gnat=no
  379. fi
  380. ])
  381. dnl 'make compare' can be significantly faster, if cmp itself can
  382. dnl skip bytes instead of using tail. The test being performed is
  383. dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
  384. dnl but we need to sink errors and handle broken shells. We also test
  385. dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
  386. dnl accepted by cmp on some systems.
  387. AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
  388. [AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
  389. [ echo abfoo >t1
  390. echo cdfoo >t2
  391. gcc_cv_prog_cmp_skip='tail -c +17 $$f1 > tmp-foo1; tail -c +17 $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
  392. if cmp t1 t2 2 2 > /dev/null 2>&1; then
  393. if cmp t1 t2 1 1 > /dev/null 2>&1; then
  394. :
  395. else
  396. gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
  397. fi
  398. fi
  399. if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
  400. if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
  401. :
  402. else
  403. gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
  404. fi
  405. fi
  406. rm t1 t2
  407. ])
  408. do_compare="$gcc_cv_prog_cmp_skip"
  409. AC_SUBST(do_compare)
  410. ])
  411. dnl See whether we can include both string.h and strings.h.
  412. AC_DEFUN([ACX_HEADER_STRING],
  413. [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
  414. gcc_cv_header_string,
  415. [AC_TRY_COMPILE([#include <string.h>
  416. #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
  417. if test $gcc_cv_header_string = yes; then
  418. AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
  419. fi
  420. ])
  421. dnl See if stdbool.h properly defines bool and true/false.
  422. dnl Check whether _Bool is built-in.
  423. AC_DEFUN([ACX_HEADER_STDBOOL],
  424. [AC_CACHE_CHECK([for working stdbool.h],
  425. ac_cv_header_stdbool_h,
  426. [AC_TRY_COMPILE([#include <stdbool.h>],
  427. [bool foo = false;],
  428. ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
  429. if test $ac_cv_header_stdbool_h = yes; then
  430. AC_DEFINE(HAVE_STDBOOL_H, 1,
  431. [Define if you have a working <stdbool.h> header file.])
  432. fi
  433. AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
  434. [AC_TRY_COMPILE(,
  435. [_Bool foo;],
  436. gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
  437. ])
  438. if test $gcc_cv_c__bool = yes; then
  439. AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
  440. fi
  441. ])
  442. dnl See if hard links work and if not, try to substitute $1 or simple copy.
  443. AC_DEFUN([ACX_PROG_LN],
  444. [AC_MSG_CHECKING(whether ln works)
  445. AC_CACHE_VAL(acx_cv_prog_LN,
  446. [rm -f conftestdata_t
  447. echo >conftestdata_f
  448. if ln conftestdata_f conftestdata_t 2>/dev/null
  449. then
  450. acx_cv_prog_LN=ln
  451. else
  452. acx_cv_prog_LN=no
  453. fi
  454. rm -f conftestdata_f conftestdata_t
  455. ])dnl
  456. if test $acx_cv_prog_LN = no; then
  457. LN="ifelse([$1],,cp,[$1])"
  458. AC_MSG_RESULT([no, using $LN])
  459. else
  460. LN="$acx_cv_prog_LN"
  461. AC_MSG_RESULT(yes)
  462. fi
  463. AC_SUBST(LN)dnl
  464. ])
  465. dnl GCC_TARGET_TOOL(PROGRAM, TARGET-VAR, HOST-VAR, IN-TREE-TOOL, LANGUAGE)
  466. AC_DEFUN([GCC_TARGET_TOOL],
  467. [AC_MSG_CHECKING(where to find the target $1)
  468. if test "x${build}" != "x${host}" ; then
  469. if expr "x[$]$2" : "x/" > /dev/null; then
  470. # We already found the complete path
  471. ac_dir=`dirname [$]$2`
  472. AC_MSG_RESULT(pre-installed in $ac_dir)
  473. else
  474. # Canadian cross, just use what we found
  475. AC_MSG_RESULT(pre-installed)
  476. fi
  477. else
  478. ifelse([$4],,,
  479. [ok=yes
  480. case " ${configdirs} " in
  481. *" patsubst([$4], [/.*], []) "*) ;;
  482. *) ok=no ;;
  483. esac
  484. ifelse([$5],,,
  485. [case ,${enable_languages}, in
  486. *,$5,*) ;;
  487. *) ok=no ;;
  488. esac])
  489. if test $ok = yes; then
  490. # An in-tree tool is available and we can use it
  491. $2='$$r/$(HOST_SUBDIR)/$4'
  492. AC_MSG_RESULT(just compiled)
  493. el])if expr "x[$]$2" : "x/" > /dev/null; then
  494. # We already found the complete path
  495. ac_dir=`dirname [$]$2`
  496. AC_MSG_RESULT(pre-installed in $ac_dir)
  497. elif test "x$target" = "x$host"; then
  498. # We can use an host tool
  499. $2='$($3)'
  500. AC_MSG_RESULT(host tool)
  501. else
  502. # We need a cross tool
  503. AC_MSG_RESULT(pre-installed)
  504. fi
  505. fi
  506. AC_SUBST($2)])
  507. dnl Locate a program and check that its version is acceptable.
  508. dnl ACX_PROG_CHECK_VER(var, name, version-switch,
  509. dnl version-extract-regexp, version-glob)
  510. AC_DEFUN([ACX_CHECK_PROG_VER],[
  511. AC_CHECK_PROG([$1], [$2], [$2])
  512. if test -n "[$]$1"; then
  513. # Found it, now check the version.
  514. AC_CACHE_CHECK([for modern $2],
  515. [gcc_cv_prog_$2_modern],
  516. [ac_prog_version=`eval [$]$1 $3 2>&1 |
  517. sed -n 's/^.*patsubst([[$4]],/,\/).*$/\1/p'`
  518. [case $ac_prog_version in
  519. '') gcc_cv_prog_$2_modern=no;;
  520. $5) gcc_cv_prog_$2_modern=yes;;
  521. *) gcc_cv_prog_$2_modern=no;;
  522. esac]
  523. ])
  524. else
  525. gcc_cv_prog_$2_modern=no
  526. fi
  527. if test $gcc_cv_prog_$2_modern = no; then
  528. $1="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing $2"
  529. fi
  530. ])
  531. dnl Support the --with-pkgversion configure option.
  532. dnl ACX_PKGVERSION(default-pkgversion)
  533. AC_DEFUN([ACX_PKGVERSION],[
  534. AC_ARG_WITH(pkgversion,
  535. AS_HELP_STRING([--with-pkgversion=PKG],
  536. [Use PKG in the version string in place of "$1"]),
  537. [case "$withval" in
  538. yes) AC_MSG_ERROR([package version not specified]) ;;
  539. no) PKGVERSION= ;;
  540. *) PKGVERSION="($withval) " ;;
  541. esac],
  542. PKGVERSION="($1) "
  543. )
  544. AC_SUBST(PKGVERSION)
  545. ])
  546. dnl Support the --with-bugurl configure option.
  547. dnl ACX_BUGURL(default-bugurl)
  548. AC_DEFUN([ACX_BUGURL],[
  549. AC_ARG_WITH(bugurl,
  550. AS_HELP_STRING([--with-bugurl=URL],
  551. [Direct users to URL to report a bug]),
  552. [case "$withval" in
  553. yes) AC_MSG_ERROR([bug URL not specified]) ;;
  554. no) BUGURL=
  555. ;;
  556. *) BUGURL="$withval"
  557. ;;
  558. esac],
  559. BUGURL="$1"
  560. )
  561. case ${BUGURL} in
  562. "")
  563. REPORT_BUGS_TO=
  564. REPORT_BUGS_TEXI=
  565. ;;
  566. *)
  567. REPORT_BUGS_TO="<$BUGURL>"
  568. REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
  569. ;;
  570. esac;
  571. AC_SUBST(REPORT_BUGS_TO)
  572. AC_SUBST(REPORT_BUGS_TEXI)
  573. ])
  574. dnl ####
  575. dnl # ACX_CHECK_CYGWIN_CAT_WORKS
  576. dnl # On Cygwin hosts, check that the cat command ignores
  577. dnl # carriage returns as otherwise builds will not work.
  578. dnl # See binutils PR 4334 for more details.
  579. AC_DEFUN([ACX_CHECK_CYGWIN_CAT_WORKS],[
  580. AC_MSG_CHECKING([to see if cat works as expected])
  581. echo a >cygwin-cat-check
  582. if test `cat cygwin-cat-check` = a ; then
  583. rm cygwin-cat-check
  584. AC_MSG_RESULT(yes)
  585. else
  586. rm cygwin-cat-check
  587. AC_MSG_RESULT(no)
  588. AC_MSG_ERROR([The cat command does not ignore carriage return characters.
  589. Please either mount the build directory in binary mode or run the following
  590. commands before running any configure script:
  591. set -o igncr
  592. export SHELLOPTS
  593. ])
  594. fi
  595. ])