1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for programs.
3 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
4 # Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf. You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them. The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf. We call these the "data" portions. The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case. We call these
34 # comments and executable code the "non-data" portions. Autoconf never
35 # copies any of the non-data portions into its output.
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation. When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with. (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.) If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
48 # Written by David MacKenzie, with help from
49 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
53 ## ----------------------------- ##
54 ## Generic checks for programs. ##
55 ## ----------------------------- ##
58 # AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
59 # [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
61 # -----------------------------------------------------
62 AC_DEFUN([AC_CHECK_PROG],
63 [# Extract the first word of "$2", so it can be a program name with args.
64 set dummy $2; ac_word=$[2]
65 AC_MSG_CHECKING([for $ac_word])
66 AC_CACHE_VAL(ac_cv_prog_$1,
67 [if test -n "$$1"; then
68 ac_cv_prog_$1="$$1" # Let the user override the test.
71 [ ac_prog_rejected=no])dnl
73 [for ac_exec_ext in '' $ac_executable_extensions; do
74 if AS_EXECUTABLE_P(["$as_dir/$ac_word$ac_exec_ext"]); then
76 [ if test "$as_dir/$ac_word$ac_exec_ext" = "$6"; then
81 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&AS_MESSAGE_LOG_FD
86 [if test $ac_prog_rejected = yes; then
87 # We found a bogon in the path, so make sure we never use it.
88 set dummy $ac_cv_prog_$1
90 if test $[@%:@] != 0; then
91 # We chose a different compiler from the bogus one.
92 # However, it has the same basename, so the bogon will be chosen
93 # first if we set $1 to just the basename; use the full file name.
95 ac_cv_prog_$1="$as_dir/$ac_word${1+' '}$[@]"
99 AC_MSG_ERROR([$1=$6 unacceptable, but no other $4 found in dnl
100 m4_default([$5], [\$PATH])])
104 dnl If no 4th arg is given, leave the cache variable unset,
105 dnl so AC_CHECK_PROGS will keep looking.
107 [ test -z "$ac_cv_prog_$1" && ac_cv_prog_$1="$4"])dnl
110 if test -n "$$1"; then
119 # AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
121 # ------------------------------------------------------------------
122 AC_DEFUN([AC_CHECK_PROGS],
125 AC_CHECK_PROG([$1], [$ac_prog], [$ac_prog], , [$4])
126 test -n "$$1" && break
128 m4_ifvaln([$3], [test -n "$$1" || $1="$3"])])
131 # AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
132 # -----------------------------------------------------------------------
133 AC_DEFUN([AC_PATH_PROG],
134 [# Extract the first word of "$2", so it can be a program name with args.
135 set dummy $2; ac_word=$[2]
136 AC_MSG_CHECKING([for $ac_word])
137 AC_CACHE_VAL([ac_cv_path_$1],
139 [[\\/]]* | ?:[[\\/]]*)
140 ac_cv_path_$1="$$1" # Let the user override the test with a path.
144 [for ac_exec_ext in '' $ac_executable_extensions; do
145 if AS_EXECUTABLE_P(["$as_dir/$ac_word$ac_exec_ext"]); then
146 ac_cv_path_$1="$as_dir/$ac_word$ac_exec_ext"
147 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&AS_MESSAGE_LOG_FD
151 dnl If no 3rd arg is given, leave the cache variable unset,
152 dnl so AC_PATH_PROGS will keep looking.
154 [ test -z "$ac_cv_path_$1" && ac_cv_path_$1="$3"])dnl
157 AC_SUBST([$1], [$ac_cv_path_$1])
158 if test -n "$$1"; then
166 # AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
168 # -----------------------------------------------------------------
169 AC_DEFUN([AC_PATH_PROGS],
172 AC_PATH_PROG([$1], [$ac_prog], , [$4])
173 test -n "$$1" && break
175 m4_ifvaln([$3], [test -n "$$1" || $1="$3"])dnl
181 ## -------------------------- ##
182 ## Generic checks for tools. ##
183 ## -------------------------- ##
186 # AC_CHECK_TOOL_PREFIX
187 # --------------------
188 AU_DEFUN([AC_CHECK_TOOL_PREFIX])
191 # AC_PATH_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
192 # -----------------------------------------------------------------------
193 # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
194 AC_DEFUN([AC_PATH_TOOL],
195 [if test -n "$ac_tool_prefix"; then
196 AC_PATH_PROG([$1], [${ac_tool_prefix}$2], , [$4])
198 if test -z "$ac_cv_path_$1"; then
200 AC_PATH_PROG([ac_pt_$1], [$2], [$3], [$4])
208 # AC_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
209 # ------------------------------------------------------------------------
210 # (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
211 AC_DEFUN([AC_CHECK_TOOL],
212 [if test -n "$ac_tool_prefix"; then
213 AC_CHECK_PROG([$1], [${ac_tool_prefix}$2], [${ac_tool_prefix}$2], , [$4])
215 if test -z "$ac_cv_prog_$1"; then
217 AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
225 # AC_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
227 # ------------------------------------------------------------------
228 # Check for each tool in PROGS-TO-CHECK-FOR with the cross prefix. If
229 # none can be found with a cross prefix, then use the first one that
230 # was found without the cross prefix.
231 AC_DEFUN([AC_CHECK_TOOLS],
232 [if test -n "$ac_tool_prefix"; then
236 [$ac_tool_prefix$ac_prog], [$ac_tool_prefix$ac_prog],,
238 test -n "$$1" && break
241 if test -z "$$1"; then
243 AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
250 ## ---------------- ##
251 ## Specific tests. ##
252 ## ---------------- ##
254 # Please, keep this section sorted.
255 # (But of course when keeping related things together).
257 # Check for gawk first since it's generally better.
258 AN_MAKEVAR([AWK], [AC_PROG_AWK])
259 AN_PROGRAM([awk], [AC_PROG_AWK])
260 AN_PROGRAM([gawk], [AC_PROG_AWK])
261 AN_PROGRAM([mawk], [AC_PROG_AWK])
262 AN_PROGRAM([nawk], [AC_PROG_AWK])
263 AC_DEFUN([AC_PROG_AWK],
264 [AC_CHECK_PROGS(AWK, gawk mawk nawk awk, )])
269 AC_DEFUN([AC_PROG_EGREP],
270 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
271 [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
272 then ac_cv_prog_egrep='grep -E'
273 else ac_cv_prog_egrep='egrep'
275 EGREP=$ac_cv_prog_egrep
282 AC_DEFUN([AC_PROG_FGREP],
283 [AC_CACHE_CHECK([for fgrep], [ac_cv_prog_fgrep],
284 [if echo 'ab*c' | (grep -F 'ab*c') >/dev/null 2>&1
285 then ac_cv_prog_fgrep='grep -F'
286 else ac_cv_prog_fgrep='fgrep'
288 FGREP=$ac_cv_prog_fgrep
295 AN_MAKEVAR([INSTALL], [AC_PROG_INSTALL])
296 AN_PROGRAM([install], [AC_PROG_INSTALL])
297 AC_DEFUN([AC_PROG_INSTALL],
298 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
299 # Find a good install program. We prefer a C program (faster),
300 # so one script is as good as another. But avoid the broken or
301 # incompatible versions:
302 # SysV /etc/install, /usr/sbin/install
303 # SunOS /usr/etc/install
306 # AmigaOS /C/install, which installs bootblocks on floppy discs
307 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
308 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
309 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
310 # ./install, which can be erroneously created by make from ./install.sh.
311 AC_MSG_CHECKING([for a BSD-compatible install])
312 if test -z "$INSTALL"; then
313 AC_CACHE_VAL(ac_cv_path_install,
314 [_AS_PATH_WALK([$PATH],
315 [# Account for people who put trailing slashes in PATH elements.
317 ./ | .// | /[cC]/* | \
318 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
321 # OSF1 and SCO ODT 3.0 have their own names for install.
322 # Don't use installbsd from OSF since it installs stuff as root
324 for ac_prog in ginstall scoinst install; do
325 for ac_exec_ext in '' $ac_executable_extensions; do
326 if AS_EXECUTABLE_P(["$as_dir/$ac_prog$ac_exec_ext"]); then
327 if test $ac_prog = install &&
328 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
329 # AIX install. It has an incompatible calling convention.
331 elif test $ac_prog = install &&
332 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
333 # program-specific install script used by HP pwplus--don't use.
336 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
345 if test "${ac_cv_path_install+set}" = set; then
346 INSTALL=$ac_cv_path_install
348 # As a last resort, use the slow shell script. We don't cache a
349 # path for INSTALL within a source directory, because that will
350 # break other packages using the cache if that directory is
351 # removed, or if the path is relative.
352 INSTALL=$ac_install_sh
355 dnl We do special magic for INSTALL instead of AC_SUBST, to get
356 dnl relative paths right.
357 AC_MSG_RESULT([$INSTALL])
359 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
360 # It thinks the first close brace ends the variable substitution.
361 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
362 AC_SUBST(INSTALL_PROGRAM)dnl
364 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
365 AC_SUBST(INSTALL_SCRIPT)dnl
367 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
368 AC_SUBST(INSTALL_DATA)dnl
374 # Look for flex or lex. Set its associated library to LEXLIB.
375 # Check if lex declares yytext as a char * by default, not a char[].
376 AN_MAKEVAR([LEX], [AC_PROG_LEX])
377 AN_PROGRAM([lex], [AC_PROG_LEX])
378 AN_PROGRAM([flex], [AC_PROG_LEX])
379 AC_DEFUN_ONCE([AC_PROG_LEX],
380 [AC_CHECK_PROGS(LEX, flex lex, :)
383 AC_CHECK_LIB(fl, yywrap, LEXLIB="-lfl",
384 [AC_CHECK_LIB(l, yywrap, LEXLIB="-ll")])
387 if test "x$LEX" != "x:"; then
388 _AC_PROG_LEX_YYTEXT_DECL
392 # _AC_PROG_LEX_YYTEXT_DECL
393 # ------------------------
394 # Check if lex declares yytext as a char * by default, not a char[].
395 m4_define([_AC_PROG_LEX_YYTEXT_DECL],
396 [AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
397 [# The minimal lex program is just a single line: %%. But some broken lexes
398 # (Solaris, I think it was) want two %% lines, so accommodate them.
399 cat >conftest.l <<_ACEOF
403 AC_TRY_EVAL(LEX conftest.l)
404 if test -f lex.yy.c; then
405 ac_cv_prog_lex_root=lex.yy
406 elif test -f lexyy.c; then
407 ac_cv_prog_lex_root=lexyy
409 AC_MSG_ERROR([cannot find output from $LEX; giving up])
412 AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl
414 AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
415 [# POSIX says lex can declare yytext either as a pointer or an array; the
416 # default is implementation-dependent. Figure out which it is, since
417 # not all implementations provide the %pointer and %array declarations.
418 ac_cv_prog_lex_yytext_pointer=no
419 echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
422 AC_LINK_IFELSE([`cat $LEX_OUTPUT_ROOT.c`], ac_cv_prog_lex_yytext_pointer=yes)
424 rm -f "${LEX_OUTPUT_ROOT}.c"
427 if test $ac_cv_prog_lex_yytext_pointer = yes; then
428 AC_DEFINE(YYTEXT_POINTER, 1,
429 [Define to 1 if `lex' declares `yytext' as a `char *' by default,
432 ])# _AC_PROG_LEX_YYTEXT_DECL
435 # Require AC_PROG_LEX in case some people were just calling this macro.
436 AU_DEFUN([AC_DECL_YYTEXT], [AC_PROG_LEX])
441 AN_MAKEVAR([LN], [AC_PROG_LN_S])
442 AN_PROGRAM([ln], [AC_PROG_LN_S])
443 AC_DEFUN([AC_PROG_LN_S],
444 [AC_MSG_CHECKING([whether ln -s works])
445 AC_SUBST([LN_S], [$as_ln_s])dnl
446 if test "$LN_S" = "ln -s"; then
449 AC_MSG_RESULT([no, using $LN_S])
456 # Define SET_MAKE to set ${MAKE} if make doesn't.
457 AN_MAKEVAR([MAKE], [AC_PROG_MAKE_SET])
458 AN_PROGRAM([make], [AC_PROG_MAKE_SET])
459 AC_DEFUN([AC_PROG_MAKE_SET],
460 [AC_MSG_CHECKING([whether ${MAKE-make} sets \$(MAKE)])
461 set dummy ${MAKE-make}; ac_make=`echo "$[2]" | sed 'y,./+-,__p_,'`
462 AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
463 [cat >conftest.make <<\_ACEOF
465 @echo 'ac_maketemp="$(MAKE)"'
467 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
468 eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
469 if test -n "$ac_maketemp"; then
470 eval ac_cv_prog_make_${ac_make}_set=yes
472 eval ac_cv_prog_make_${ac_make}_set=no
474 rm -f conftest.make])dnl
475 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
480 SET_MAKE="MAKE=${MAKE-make}"
482 AC_SUBST([SET_MAKE])dnl
488 AN_MAKEVAR([RANLIB], [AC_PROG_RANLIB])
489 AN_PROGRAM([ranlib], [AC_PROG_RANLIB])
490 AC_DEFUN([AC_PROG_RANLIB],
491 [AC_CHECK_TOOL(RANLIB, ranlib, :)])
496 # I don't know what it used to do, but it no longer does.
498 [AC_DIAGNOSE([obsolete], [$0: is no longer supported.
499 Remove this warning when you adjust the code.])])
504 AN_MAKEVAR([BISON], [AC_PROG_YACC])
505 AN_MAKEVAR([YACC], [AC_PROG_YACC])
506 AN_PROGRAM([yacc], [AC_PROG_YACC])
507 AN_PROGRAM([byacc], [AC_PROG_YACC])
508 AN_PROGRAM([bison], [AC_PROG_YACC])
509 AC_DEFUN([AC_PROG_YACC],
510 [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)])