acx.m4 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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. # Test for D.
  382. AC_DEFUN([ACX_PROG_GDC],
  383. [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
  384. AC_REQUIRE([AC_PROG_CC])
  385. AC_CHECK_TOOL(GDC, gdc, no)
  386. AC_CACHE_CHECK([whether the D compiler works],
  387. acx_cv_d_compiler_works,
  388. [cat >conftest.d <<EOF
  389. module conftest; int main() { return 0; }
  390. EOF
  391. acx_cv_d_compiler_works=no
  392. if test "x$GDC" != xno; then
  393. errors=`(${GDC} $1[]m4_ifval([$1], [ ])-c conftest.d) 2>&1 || echo failure`
  394. if test x"$errors" = x && test -f conftest.$ac_objext; then
  395. acx_cv_d_compiler_works=yes
  396. fi
  397. rm -f conftest.*
  398. fi])
  399. if test "x$GDC" != xno && test x$acx_cv_d_compiler_works != xno; then
  400. have_gdc=yes
  401. else
  402. have_gdc=no
  403. fi
  404. ])
  405. dnl 'make compare' can be significantly faster, if cmp itself can
  406. dnl skip bytes instead of using tail. The test being performed is
  407. dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
  408. dnl but we need to sink errors and handle broken shells. We also test
  409. dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
  410. dnl accepted by cmp on some systems.
  411. AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
  412. [AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
  413. [ echo abfoo >t1
  414. echo cdfoo >t2
  415. gcc_cv_prog_cmp_skip='tail -c +17 $$f1 > tmp-foo1; tail -c +17 $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
  416. if cmp t1 t2 2 2 > /dev/null 2>&1; then
  417. if cmp t1 t2 1 1 > /dev/null 2>&1; then
  418. :
  419. else
  420. gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
  421. fi
  422. fi
  423. if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
  424. if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
  425. :
  426. else
  427. gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
  428. fi
  429. fi
  430. rm t1 t2
  431. ])
  432. do_compare="$gcc_cv_prog_cmp_skip"
  433. AC_SUBST(do_compare)
  434. ])
  435. dnl See whether we can include both string.h and strings.h.
  436. AC_DEFUN([ACX_HEADER_STRING],
  437. [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
  438. gcc_cv_header_string,
  439. [AC_TRY_COMPILE([#include <string.h>
  440. #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
  441. if test $gcc_cv_header_string = yes; then
  442. AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
  443. fi
  444. ])
  445. dnl See if stdbool.h properly defines bool and true/false.
  446. dnl Check whether _Bool is built-in.
  447. AC_DEFUN([ACX_HEADER_STDBOOL],
  448. [AC_CACHE_CHECK([for working stdbool.h],
  449. ac_cv_header_stdbool_h,
  450. [AC_TRY_COMPILE([#include <stdbool.h>],
  451. [bool foo = false;],
  452. ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
  453. if test $ac_cv_header_stdbool_h = yes; then
  454. AC_DEFINE(HAVE_STDBOOL_H, 1,
  455. [Define if you have a working <stdbool.h> header file.])
  456. fi
  457. AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
  458. [AC_TRY_COMPILE(,
  459. [_Bool foo;],
  460. gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
  461. ])
  462. if test $gcc_cv_c__bool = yes; then
  463. AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
  464. fi
  465. ])
  466. dnl See if hard links work and if not, try to substitute $1 or simple copy.
  467. AC_DEFUN([ACX_PROG_LN],
  468. [AC_MSG_CHECKING(whether ln works)
  469. AC_CACHE_VAL(acx_cv_prog_LN,
  470. [rm -f conftestdata_t
  471. echo >conftestdata_f
  472. if ln conftestdata_f conftestdata_t 2>/dev/null
  473. then
  474. acx_cv_prog_LN=ln
  475. else
  476. acx_cv_prog_LN=no
  477. fi
  478. rm -f conftestdata_f conftestdata_t
  479. ])dnl
  480. if test $acx_cv_prog_LN = no; then
  481. LN="ifelse([$1],,cp,[$1])"
  482. AC_MSG_RESULT([no, using $LN])
  483. else
  484. LN="$acx_cv_prog_LN"
  485. AC_MSG_RESULT(yes)
  486. fi
  487. AC_SUBST(LN)dnl
  488. ])
  489. dnl GCC_TARGET_TOOL(PROGRAM, TARGET-VAR, HOST-VAR, IN-TREE-TOOL, LANGUAGE)
  490. AC_DEFUN([GCC_TARGET_TOOL],
  491. [AC_MSG_CHECKING(where to find the target $1)
  492. if test "x${build}" != "x${host}" ; then
  493. 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. else
  498. # Canadian cross, just use what we found
  499. AC_MSG_RESULT(pre-installed)
  500. fi
  501. else
  502. ifelse([$4],,,
  503. [ok=yes
  504. case " ${configdirs} " in
  505. *" patsubst([$4], [/.*], []) "*) ;;
  506. *) ok=no ;;
  507. esac
  508. ifelse([$5],,,
  509. [case ,${enable_languages}, in
  510. *,$5,*) ;;
  511. *) ok=no ;;
  512. esac])
  513. if test $ok = yes; then
  514. # An in-tree tool is available and we can use it
  515. $2='$$r/$(HOST_SUBDIR)/$4'
  516. AC_MSG_RESULT(just compiled)
  517. el])if expr "x[$]$2" : "x/" > /dev/null; then
  518. # We already found the complete path
  519. ac_dir=`dirname [$]$2`
  520. AC_MSG_RESULT(pre-installed in $ac_dir)
  521. elif test "x$target" = "x$host"; then
  522. # We can use an host tool
  523. $2='$($3)'
  524. AC_MSG_RESULT(host tool)
  525. else
  526. # We need a cross tool
  527. AC_MSG_RESULT(pre-installed)
  528. fi
  529. fi
  530. AC_SUBST($2)])
  531. dnl Locate a program and check that its version is acceptable.
  532. dnl ACX_PROG_CHECK_VER(var, name, version-switch,
  533. dnl version-extract-regexp, version-glob)
  534. AC_DEFUN([ACX_CHECK_PROG_VER],[
  535. AC_CHECK_PROG([$1], [$2], [$2])
  536. if test -n "[$]$1"; then
  537. # Found it, now check the version.
  538. AC_CACHE_CHECK([for modern $2],
  539. [gcc_cv_prog_$2_modern],
  540. [ac_prog_version=`eval [$]$1 $3 2>&1 |
  541. sed -n 's/^.*patsubst([[$4]],/,\/).*$/\1/p'`
  542. [case $ac_prog_version in
  543. '') gcc_cv_prog_$2_modern=no;;
  544. $5) gcc_cv_prog_$2_modern=yes;;
  545. *) gcc_cv_prog_$2_modern=no;;
  546. esac]
  547. ])
  548. else
  549. gcc_cv_prog_$2_modern=no
  550. fi
  551. if test $gcc_cv_prog_$2_modern = no; then
  552. $1="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing $2"
  553. fi
  554. ])
  555. dnl Support the --with-pkgversion configure option.
  556. dnl ACX_PKGVERSION(default-pkgversion)
  557. AC_DEFUN([ACX_PKGVERSION],[
  558. AC_ARG_WITH(pkgversion,
  559. AS_HELP_STRING([--with-pkgversion=PKG],
  560. [Use PKG in the version string in place of "$1"]),
  561. [case "$withval" in
  562. yes) AC_MSG_ERROR([package version not specified]) ;;
  563. no) PKGVERSION= ;;
  564. *) PKGVERSION="($withval) " ;;
  565. esac],
  566. PKGVERSION="($1) "
  567. )
  568. AC_SUBST(PKGVERSION)
  569. ])
  570. dnl Support the --with-bugurl configure option.
  571. dnl ACX_BUGURL(default-bugurl)
  572. AC_DEFUN([ACX_BUGURL],[
  573. AC_ARG_WITH(bugurl,
  574. AS_HELP_STRING([--with-bugurl=URL],
  575. [Direct users to URL to report a bug]),
  576. [case "$withval" in
  577. yes) AC_MSG_ERROR([bug URL not specified]) ;;
  578. no) BUGURL=
  579. ;;
  580. *) BUGURL="$withval"
  581. ;;
  582. esac],
  583. BUGURL="$1"
  584. )
  585. case ${BUGURL} in
  586. "")
  587. REPORT_BUGS_TO=
  588. REPORT_BUGS_TEXI=
  589. ;;
  590. *)
  591. REPORT_BUGS_TO="<$BUGURL>"
  592. REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
  593. ;;
  594. esac;
  595. AC_SUBST(REPORT_BUGS_TO)
  596. AC_SUBST(REPORT_BUGS_TEXI)
  597. ])
  598. dnl ####
  599. dnl # ACX_CHECK_CYGWIN_CAT_WORKS
  600. dnl # On Cygwin hosts, check that the cat command ignores
  601. dnl # carriage returns as otherwise builds will not work.
  602. dnl # See binutils PR 4334 for more details.
  603. AC_DEFUN([ACX_CHECK_CYGWIN_CAT_WORKS],[
  604. AC_MSG_CHECKING([to see if cat works as expected])
  605. echo a >cygwin-cat-check
  606. if test `cat cygwin-cat-check` = a ; then
  607. rm cygwin-cat-check
  608. AC_MSG_RESULT(yes)
  609. else
  610. rm cygwin-cat-check
  611. AC_MSG_RESULT(no)
  612. AC_MSG_ERROR([The cat command does not ignore carriage return characters.
  613. Please either mount the build directory in binary mode or run the following
  614. commands before running any configure script:
  615. set -o igncr
  616. export SHELLOPTS
  617. ])
  618. fi
  619. ])