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