1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for programs.
4 # Copyright (C) 1992-1996, 1998-2017, 2020 Free Software Foundation,
7 # This file is part of Autoconf. This program is free
8 # software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the
10 # Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # Under Section 7 of GPL version 3, you are granted additional
19 # permissions described in the Autoconf Configure Script Exception,
20 # version 3.0, as published by the Free Software Foundation.
22 # You should have received a copy of the GNU General Public License
23 # and a copy of the Autoconf Configure Script Exception along with
24 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
25 # respectively. If not, see <https://www.gnu.org/licenses/>.
27 # Written by David MacKenzie, with help from
28 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
29 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
32 ## ----------------------------- ##
33 ## Generic checks for programs. ##
34 ## ----------------------------- ##
37 # _AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
38 # [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
40 # -----------------------------------------------------
41 AC_DEFUN([_AC_CHECK_PROG],
42 [# Extract the first word of "$2", so it can be a program name with args.
43 set dummy $2; ac_word=$[2]
44 AC_MSG_CHECKING([for $ac_word])
45 AC_CACHE_VAL(ac_cv_prog_$1,
46 [if test -n "$$1"; then
47 ac_cv_prog_$1="$$1" # Let the user override the test.
50 [ ac_prog_rejected=no])dnl
52 [for ac_exec_ext in '' $ac_executable_extensions; do
53 if AS_EXECUTABLE_P(["$as_dir$ac_word$ac_exec_ext"]); then
55 [ if test "$as_dir$ac_word$ac_exec_ext" = "$6"; then
60 _AS_ECHO_LOG([found $as_dir$ac_word$ac_exec_ext])
65 [if test $ac_prog_rejected = yes; then
66 # We found a bogon in the path, so make sure we never use it.
67 set dummy $ac_cv_prog_$1
69 if test $[@%:@] != 0; then
70 # We chose a different compiler from the bogus one.
71 # However, it has the same basename, so the bogon will be chosen
72 # first if we set $1 to just the basename; use the full file name.
74 ac_cv_prog_$1="$as_dir$ac_word${1+' '}$[@]"
78 AC_MSG_ERROR([$1=$6 unacceptable, but no other $4 found in dnl
79 m4_default([$5], [\$PATH])])
83 dnl If no 4th arg is given, leave the cache variable unset,
84 dnl so AC_CHECK_PROGS will keep looking.
86 [ test -z "$ac_cv_prog_$1" && ac_cv_prog_$1="$4"])dnl
89 if test -n "$$1"; then
97 # AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
98 # [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
100 # -----------------------------------------------------
101 AC_DEFUN([AC_CHECK_PROG],
107 # AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
109 # ------------------------------------------------------------------
110 AC_DEFUN([AC_CHECK_PROGS],
113 AC_CHECK_PROG([$1], [$ac_prog], [$ac_prog], , [$4])
114 test -n "$$1" && break
116 m4_ifvaln([$3], [test -n "$$1" || $1="$3"])])
119 # _AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
120 # ------------------------------------------------------------------------
121 AC_DEFUN([_AC_PATH_PROG],
122 [# Extract the first word of "$2", so it can be a program name with args.
123 set dummy $2; ac_word=$[2]
124 AC_MSG_CHECKING([for $ac_word])
125 AC_CACHE_VAL([ac_cv_path_$1],
127 [[\\/]]* | ?:[[\\/]]*)
128 ac_cv_path_$1="$$1" # Let the user override the test with a path.
132 [for ac_exec_ext in '' $ac_executable_extensions; do
133 if AS_EXECUTABLE_P(["$as_dir$ac_word$ac_exec_ext"]); then
134 ac_cv_path_$1="$as_dir$ac_word$ac_exec_ext"
135 _AS_ECHO_LOG([found $as_dir$ac_word$ac_exec_ext])
139 dnl If no 3rd arg is given, leave the cache variable unset,
140 dnl so AC_PATH_PROGS will keep looking.
142 [ test -z "$ac_cv_path_$1" && ac_cv_path_$1="$3"])dnl
146 if test -n "$$1"; then
154 # AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
155 # -----------------------------------------------------------------------
156 AC_DEFUN([AC_PATH_PROG],
162 # AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
164 # -----------------------------------------------------------------
165 AC_DEFUN([AC_PATH_PROGS],
168 AC_PATH_PROG([$1], [$ac_prog], , [$4])
169 test -n "$$1" && break
171 m4_ifvaln([$3], [test -n "$$1" || $1="$3"])dnl
177 ## -------------------------- ##
178 ## Generic checks for tools. ##
179 ## -------------------------- ##
182 # AC_CHECK_TOOL_PREFIX
183 # --------------------
184 AU_DEFUN([AC_CHECK_TOOL_PREFIX])
189 AC_DEFUN([_AC_TOOL_WARN],
190 [case $cross_compiling:$ac_tool_warned in
192 AC_MSG_WARN([using cross tools not prefixed with host triplet])
193 ac_tool_warned=yes ;;
196 # AC_PATH_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
197 # -----------------------------------------------------------------------
198 # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
199 AC_DEFUN([AC_PATH_TOOL],
200 [if test -n "$ac_tool_prefix"; then
201 AC_PATH_PROG([$1], [${ac_tool_prefix}$2], , [$4])
203 if test -z "$ac_cv_path_$1"; then
205 _AC_PATH_PROG([ac_pt_$1], [$2], [], [$4])
206 if test "x$ac_pt_$1" = x; then
218 # AC_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
219 # ------------------------------------------------------------------------
220 # (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
221 AC_DEFUN([AC_CHECK_TOOL],
222 [if test -n "$ac_tool_prefix"; then
223 AC_CHECK_PROG([$1], [${ac_tool_prefix}$2], [${ac_tool_prefix}$2], , [$4])
225 if test -z "$ac_cv_prog_$1"; then
227 _AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [], [$4])
228 if test "x$ac_ct_$1" = x; then
240 # AC_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
242 # ------------------------------------------------------------------
243 # Check for each tool in PROGS-TO-CHECK-FOR with the cross prefix. If
244 # none can be found with a cross prefix, then use the first one that
245 # was found without the cross prefix.
246 AC_DEFUN([AC_CHECK_TOOLS],
247 [if test -n "$ac_tool_prefix"; then
251 [$ac_tool_prefix$ac_prog], [$ac_tool_prefix$ac_prog],,
253 test -n "$$1" && break
256 if test -z "$$1"; then
258 AC_CHECK_PROGS([ac_ct_$1], [$2], [], [$4])
259 if test "x$ac_ct_$1" = x; then
269 # AC_PATH_TARGET_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
270 # ------------------------------------------------------------------------------
271 # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
272 AC_DEFUN([AC_PATH_TARGET_TOOL],
273 [AC_REQUIRE([AC_CANONICAL_TARGET])dnl
274 AC_PATH_PROG([$1], [$target_alias-$2], , [$4])
275 if test -z "$ac_cv_path_$1"; then
276 if test "$build" = "$target"; then
278 _AC_PATH_PROG([ac_pt_$1], [$2], [$3], [$4])
286 ])# AC_PATH_TARGET_TOOL
289 # AC_CHECK_TARGET_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
290 # -------------------------------------------------------------------------------
291 # (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
292 AC_DEFUN([AC_CHECK_TARGET_TOOL],
293 [AC_REQUIRE([AC_CANONICAL_TARGET])dnl
294 AC_CHECK_PROG([$1], [$target_alias-$2], [$target_alias-$2], , [$4])
295 if test -z "$ac_cv_prog_$1"; then
296 if test "$build" = "$target"; then
298 _AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
306 ])# AC_CHECK_TARGET_TOOL
309 # AC_CHECK_TARGET_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
311 # -------------------------------------------------------------------------
312 # Check for each tool in PROGS-TO-CHECK-FOR with the cross prefix. If
313 # none can be found with a cross prefix, then use the first one that
314 # was found without the cross prefix.
315 AC_DEFUN([AC_CHECK_TARGET_TOOLS],
316 [AC_REQUIRE([AC_CANONICAL_TARGET])dnl
320 [$target_alias-$ac_prog], [$target_alias-$ac_prog],,
322 test -n "$$1" && break
324 if test -z "$$1"; then
325 if test "$build" = "$target"; then
327 AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
333 ])# AC_CHECK_TARGET_TOOLS
337 ## ---------------- ##
338 ## Specific tests. ##
339 ## ---------------- ##
341 # Please, keep this section sorted.
342 # (But of course when keeping related things together).
344 # Check for gawk first since it's generally better.
345 AN_MAKEVAR([AWK], [AC_PROG_AWK])
346 AN_PROGRAM([awk], [AC_PROG_AWK])
347 AN_PROGRAM([gawk], [AC_PROG_AWK])
348 AN_PROGRAM([mawk], [AC_PROG_AWK])
349 AN_PROGRAM([nawk], [AC_PROG_AWK])
350 AC_DEFUN([AC_PROG_AWK],
351 [AC_CHECK_PROGS(AWK, gawk mawk nawk awk, )])
356 AC_DEFUN([AC_PROG_EGREP],
357 [AC_REQUIRE([AC_PROG_GREP])dnl
358 AC_CACHE_CHECK([for egrep], ac_cv_path_EGREP,
359 [if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
360 then ac_cv_path_EGREP="$GREP -E"
362 _AC_PROG_GREP(EGREP, egrep, ['EGREP$'])
364 EGREP="$ac_cv_path_EGREP"
371 AC_DEFUN([AC_PROG_FGREP],
372 [AC_REQUIRE([AC_PROG_GREP])dnl
373 AC_CACHE_CHECK([for fgrep], ac_cv_path_FGREP,
374 [if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
375 then ac_cv_path_FGREP="$GREP -F"
377 _AC_PROG_GREP(FGREP, fgrep, [FGREP])
379 FGREP="$ac_cv_path_FGREP"
386 # Check for a fully functional grep program that handles
387 # the longest lines possible and which respects multiple -e options.
388 # Prefer GNU grep if found.
389 AC_DEFUN([AC_PROG_GREP],
390 [AC_CACHE_CHECK([for grep that handles long lines and -e], ac_cv_path_GREP,
391 [_$0(GREP, [grep ggrep], [-e 'GREP$' -e '-(cannot match)-'])])
392 GREP="$ac_cv_path_GREP"
397 # _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, PROG-ARGUMENTS)
398 # ------------------------------------------------------
399 # Solaris 9 /usr/xpg4/bin/*grep is suitable, but /usr/bin/*grep lacks -e.
400 # AIX silently truncates long lines before matching.
401 # NeXT understands only one -e and truncates long lines.
402 m4_define([_AC_PROG_GREP],
403 [_AC_PATH_PROGS_FEATURE_CHECK([$1], [$2],
404 [_AC_FEATURE_CHECK_LENGTH([ac_path_$1], [ac_cv_path_$1],
405 ["$ac_path_$1" $3], [$1])], [],
406 [$PATH$PATH_SEPARATOR/usr/xpg4/bin])dnl
410 # _AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, FEATURE-TEST,
411 # [ACTION-IF-NOT-FOUND], [PATH=$PATH])
412 # -------------------------------------------------------------------
413 # FEATURE-TEST is called repeatedly with $ac_path_VARIABLE set to the
414 # name of a program in PROGNAME-LIST found in PATH. FEATURE-TEST must set
415 # $ac_cv_path_VARIABLE to the path of an acceptable program, or else
416 # ACTION-IF-NOT-FOUND is executed; the default action (for internal use
417 # only) issues a fatal error message. If a suitable $ac_path_VARIABLE is
418 # found in the FEATURE-TEST macro, it can set $ac_path_VARIABLE_found=':'
419 # to accept that value without any further checks.
420 m4_define([_AC_PATH_PROGS_FEATURE_CHECK],
421 [if test -z "$$1"; then
422 ac_path_$1_found=false
423 # Loop through the user's path and test for each of PROGNAME-LIST
427 for ac_exec_ext in '' $ac_executable_extensions; do
428 ac_path_$1="$as_dir$ac_prog$ac_exec_ext"
429 AS_EXECUTABLE_P(["$ac_path_$1"]) || continue
431 $ac_path_$1_found && break 3
434 if test -z "$ac_cv_path_$1"; then
436 [AC_MSG_ERROR([no acceptable m4_bpatsubst([$2], [ .*]) could be dnl
437 found in m4_default([$5], [\$PATH])])])
445 # AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST,
446 # FEATURE-TEST, [ACTION-IF-NOT-FOUND=:],
448 # ------------------------------------------------------------------
449 # Designed to be used inside AC_CACHE_VAL. It is recommended,
450 # but not required, that the user also use AC_ARG_VAR([VARIABLE]).
451 # If VARIABLE is not empty, set the cache variable
452 # $ac_cv_path_VARIABLE to VARIABLE without any further tests.
453 # Otherwise, call FEATURE_TEST repeatedly with $ac_path_VARIABLE
454 # set to the name of a program in PROGNAME-LIST found in PATH. If
455 # no invocation of FEATURE-TEST sets $ac_cv_path_VARIABLE to the
456 # path of an acceptable program, ACTION-IF-NOT-FOUND is executed.
457 # FEATURE-TEST is invoked even when $ac_cv_path_VARIABLE is set,
458 # in case a better candidate occurs later in PATH; to accept the
459 # current setting and bypass further checks, FEATURE-TEST can set
460 # $ac_path_VARIABLE_found=':'. Note that, unlike AC_CHECK_PROGS,
461 # this macro does not have any side effect on the current value
463 m4_define([AC_PATH_PROGS_FEATURE_CHECK],
464 [_$0([$1], [$2], [$3], m4_default([$4], [:]), [$5])dnl
468 # _AC_FEATURE_CHECK_LENGTH(PROGPATH, CACHE-VAR, CHECK-CMD, [MATCH-STRING])
469 # ------------------------------------------------------------------------
470 # For use as the FEATURE-TEST argument to _AC_PATH_PROGS_FEATURE_TEST.
471 # On each iteration run CHECK-CMD on an input file, storing the value
472 # of PROGPATH in CACHE-VAR if the CHECK-CMD succeeds. The input file
473 # is always one line, starting with only 10 characters, and doubling
474 # in length at each iteration until approx 10000 characters or the
475 # feature check succeeds. The feature check is called at each
476 # iteration by appending (optionally, MATCH-STRING and) a newline
477 # to the file, and using the result as input to CHECK-CMD.
478 m4_define([_AC_FEATURE_CHECK_LENGTH],
479 [# Check for GNU $1 and select it if it is found.
480 _AC_PATH_PROG_FLAVOR_GNU([$$1],
481 [$2="$$1" $1_found=:],
483 AS_ECHO_N([0123456789]) >"conftest.in"
486 cat "conftest.in" "conftest.in" >"conftest.tmp"
487 mv "conftest.tmp" "conftest.in"
488 cp "conftest.in" "conftest.nl"
489 AS_ECHO(['$4']) >> "conftest.nl"
490 $3 < "conftest.nl" >"conftest.out" 2>/dev/null || break
491 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
492 AS_VAR_ARITH([ac_count], [$ac_count + 1])
493 if test $ac_count -gt ${$1_max-0}; then
494 # Best one so far, save it but keep looking for a better one
496 dnl # Using $1_max so that each tool feature checked gets its
497 dnl # own variable. Don't reset it otherwise the implied search
498 dnl # for best performing tool in a list breaks down.
501 # 10*(2^10) chars as input seems more than enough
502 test $ac_count -gt 10 && break
504 rm -f conftest.in conftest.tmp conftest.nl conftest.out])dnl
508 # _AC_PATH_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
509 # ----------------------------------------------------------------
510 m4_define([_AC_PATH_PROG_FLAVOR_GNU],
512 case `"$1" --version 2>&1` in
519 ])# _AC_PATH_PROG_FLAVOR_GNU
524 AN_MAKEVAR([INSTALL], [AC_PROG_INSTALL])
525 AN_PROGRAM([install], [AC_PROG_INSTALL])
526 AC_DEFUN_ONCE([AC_PROG_INSTALL],
527 [AC_REQUIRE_AUX_FILE([install-sh])dnl
528 # Find a good install program. We prefer a C program (faster),
529 # so one script is as good as another. But avoid the broken or
530 # incompatible versions:
531 # SysV /etc/install, /usr/sbin/install
532 # SunOS /usr/etc/install
535 # AmigaOS /C/install, which installs bootblocks on floppy discs
536 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
537 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
538 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
539 # OS/2's system install, which has a completely different semantic
540 # ./install, which can be erroneously created by make from ./install.sh.
541 # Reject install programs that cannot install multiple files.
542 AC_MSG_CHECKING([for a BSD-compatible install])
543 if test -z "$INSTALL"; then
544 AC_CACHE_VAL(ac_cv_path_install,
545 [_AS_PATH_WALK([$PATH],
546 [[# Account for fact that we put trailing slashes in our PATH walk.
547 case $as_dir in @%:@((
549 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
550 ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
553 # OSF1 and SCO ODT 3.0 have their own names for install.
554 # Don't use installbsd from OSF since it installs stuff as root
556 for ac_prog in ginstall scoinst install; do
557 for ac_exec_ext in '' $ac_executable_extensions; do
558 if AS_EXECUTABLE_P(["$as_dir$ac_prog$ac_exec_ext"]); then
559 if test $ac_prog = install &&
560 grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
561 # AIX install. It has an incompatible calling convention.
563 elif test $ac_prog = install &&
564 grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
565 # program-specific install script used by HP pwplus--don't use.
568 rm -rf conftest.one conftest.two conftest.dir
569 echo one > conftest.one
570 echo two > conftest.two
572 if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" &&
573 test -s conftest.one && test -s conftest.two &&
574 test -s conftest.dir/conftest.one &&
575 test -s conftest.dir/conftest.two
577 ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c"
587 rm -rf conftest.one conftest.two conftest.dir
589 if test ${ac_cv_path_install+y}; then
590 INSTALL=$ac_cv_path_install
592 # As a last resort, use the slow shell script. Don't cache a
593 # value for INSTALL within a source directory, because that will
594 # break other packages using the cache if that directory is
595 # removed, or if the value is a relative name.
596 INSTALL=$ac_install_sh
599 dnl Do special magic for INSTALL instead of AC_SUBST, to get
600 dnl relative names right.
601 AC_MSG_RESULT([$INSTALL])
603 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
604 # It thinks the first close brace ends the variable substitution.
605 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
606 AC_SUBST(INSTALL_PROGRAM)dnl
608 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
609 AC_SUBST(INSTALL_SCRIPT)dnl
611 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
612 AC_SUBST(INSTALL_DATA)dnl
618 # Check whether `mkdir -p' is known to be race-free, and fall back to
619 # install-sh -d otherwise.
621 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
622 # created by `make install' are always world readable, even if the
623 # installer happens to have an overly restrictive umask (e.g. 077).
624 # This was a mistake. There are at least two reasons why we must not
626 # - it causes special bits like SGID to be ignored,
627 # - it may be too restrictive (some setups expect 775 directories).
629 # Do not use -m 0755 and let people choose whatever they expect by
632 # We cannot accept any implementation of `mkdir' that recognizes `-p'.
633 # Some implementations (such as Solaris 8's) are vulnerable to race conditions:
634 # if a parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
635 # concurrently, both version can detect that a/ is missing, but only
636 # one can create it and the other will error out. Consequently we
637 # restrict ourselves to known race-free implementations.
639 # Automake used to define mkdir_p as `mkdir -p .', in order to
640 # allow $(mkdir_p) to be used without argument. As in
641 # $(mkdir_p) $(somedir)
642 # where $(somedir) is conditionally defined. However we don't do
644 # 1. before we restricted the check to GNU mkdir, `mkdir -p .' was
645 # reported to fail in read-only directories. The system where this
646 # happened has been forgotten.
647 # 2. in practice we call $(MKDIR_P) on directories such as
648 # $(MKDIR_P) "$(DESTDIR)$(somedir)"
649 # and we don't want to create $(DESTDIR) if $(somedir) is empty.
650 # To support the latter case, we have to write
651 # test -z "$(somedir)" || $(MKDIR_P) "$(DESTDIR)$(somedir)"
652 # so $(MKDIR_P) always has an argument.
653 # We will have better chances of detecting a missing test if
654 # $(MKDIR_P) complains about missing arguments.
655 # 3. $(MKDIR_P) is named after `mkdir -p' and we don't expect this
656 # to accept no argument.
657 # 4. having something like `mkdir .' in the output is unsightly.
659 # On NextStep and OpenStep, the `mkdir' command does not
660 # recognize any option. It will interpret all options as
661 # directories to create.
662 AN_MAKEVAR([MKDIR_P], [AC_PROG_MKDIR_P])
663 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
664 [AC_REQUIRE_AUX_FILE([install-sh])dnl
665 AC_MSG_CHECKING([for a race-free mkdir -p])
666 if test -z "$MKDIR_P"; then
667 AC_CACHE_VAL([ac_cv_path_mkdir],
668 [_AS_PATH_WALK([$PATH$PATH_SEPARATOR/opt/sfw/bin],
669 [for ac_prog in mkdir gmkdir; do
670 for ac_exec_ext in '' $ac_executable_extensions; do
671 AS_EXECUTABLE_P(["$as_dir$ac_prog$ac_exec_ext"]) || continue
672 case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #(
673 'mkdir ('*'coreutils) '* | \
675 'mkdir (fileutils) '4.1*)
676 ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext
681 test -d ./--version && rmdir ./--version
682 if test ${ac_cv_path_mkdir+y}; then
683 MKDIR_P="$ac_cv_path_mkdir -p"
685 # As a last resort, use the slow shell script. Don't cache a
686 # value for MKDIR_P within a source directory, because that will
687 # break other packages using the cache if that directory is
688 # removed, or if the value is a relative name.
689 MKDIR_P="$ac_install_sh -d"
692 dnl status.m4 does special magic for MKDIR_P instead of AC_SUBST,
693 dnl to get relative names right. However, also AC_SUBST here so
694 dnl that Automake versions before 1.10 will pick it up (they do not
695 dnl trace AC_SUBST_TRACE).
696 dnl FIXME: Remove this once we drop support for Automake < 1.10.
697 AC_SUBST([MKDIR_P])dnl
698 AC_MSG_RESULT([$MKDIR_P])
704 # Look for flex or lex. Set its associated library to LEXLIB.
705 # Check if lex declares yytext as a char * by default, not a char[].
706 AN_MAKEVAR([LEX], [AC_PROG_LEX])
707 AN_PROGRAM([lex], [AC_PROG_LEX])
708 AN_PROGRAM([flex], [AC_PROG_LEX])
709 AC_DEFUN([AC_PROG_LEX],
713 [m4_fatal([too many arguments to $0])])]dnl
714 [_$0(m4_normalize([$1]))])
716 AC_DEFUN([_AC_PROG_LEX],
721 [m4_fatal([AC_PROG_LEX: yywrap and noyywrap are mutually exclusive])],
723 [m4_fatal([AC_PROG_LEX: yywrap and noyywrap are mutually exclusive])],
726 [AC_PROG_LEX without either yywrap or noyywrap is obsolete])],
727 [m4_fatal([AC_PROG_LEX: unrecognized argument: $1])])]dnl
728 dnl We can't use AC_DEFUN_ONCE because this macro takes arguments.
729 dnl Silently skip a second invocation if the options match;
730 dnl warn if they don't.
731 [m4_ifdef([_AC_PROG_LEX_options],
732 [m4_if([$1], m4_defn([_AC_PROG_LEX_options]), [],
733 [m4_warn([syntax], [AC_PROG_LEX used twice with mismatched options])])],
735 dnl _AC_PROG_LEX_options not defined: first use
736 m4_define([_AC_PROG_LEX_options], [$1])dnl
737 AC_CHECK_PROGS(LEX, flex lex, :)
738 if test "x$LEX" != "x:"; then
739 _AC_PROG_LEX_YYTEXT_DECL([$1])
743 # _AC_PROG_LEX_YYTEXT_DECL
744 # ------------------------
745 # Check for the Lex output root, the Lex library, and whether Lex
746 # declares yytext as a char * by default.
747 AC_DEFUN([_AC_PROG_LEX_YYTEXT_DECL],
748 [cat >conftest.l <<_ACEOF[
760 e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
762 yyless ((yyinput () != 0));
764 yyless ((input () != 0));
767 f { unput (yytext[0]); }
770 #ifdef YYTEXT_POINTER
784 AC_CACHE_CHECK([for lex output file root], [ac_cv_prog_lex_root], [
785 ac_cv_prog_lex_root=unknown
786 _AC_DO_VAR(LEX conftest.l) &&
787 if test -f lex.yy.c; then
788 ac_cv_prog_lex_root=lex.yy
789 elif test -f lexyy.c; then
790 ac_cv_prog_lex_root=lexyy
792 AS_IF([test "$ac_cv_prog_lex_root" = unknown],
793 [AC_MSG_WARN([cannot find output from $LEX; giving up on $LEX])
795 AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl
797 AS_VAR_SET_IF([LEXLIB], [], [
798 AC_CACHE_CHECK([for lex library], [ac_cv_lib_lex], [
801 for ac_cv_lib_lex in 'none needed' -lfl -ll 'not found'; do
802 AS_CASE([$ac_cv_lib_lex],
804 ['not found'], [break],
805 [*], [LIBS="$ac_cv_lib_lex $ac_save_LIBS"])
807 AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED[`cat $LEX_OUTPUT_ROOT.c`]],
816 [test "$ac_cv_lib_lex" = 'not found'],
817 [AC_MSG_WARN([required lex library not found; giving up on $LEX])
819 [test "$ac_cv_lib_lex" = 'none needed'],
821 [LEXLIB=$ac_cv_lib_lex])
823 dnl For compatibility with autoconf 2.69 and prior, if $1 is not `noyywrap',
824 dnl and we didn't already set LEXLIB to -ll or -lfl, see if one of those
825 dnl libraries provides yywrap and set LEXLIB to it if so. If $1 is `yywrap',
826 dnl and we don't find a library that provides yywrap, we fail.
831 [ac_save_LIBS="$LIBS"
832 AS_IF([test -n "$LEXLIB"],
834 AC_CHECK_FUNC([yywrap],
836 [AC_MSG_WARN([$LEXLIB does not contain yywrap; giving up on $LEX])
840 AC_SEARCH_LIBS([yywrap], [fl l], [LEXLIB="$LIBS"])
841 AS_IF([test x"$ac_cv_search_yywrap" = xno],
842 [AC_MSG_WARN([yywrap not found; giving up on $LEX])
844 LIBS="$ac_save_LIBS"],
846 [ac_save_LIBS="$LIBS"
848 AC_SEARCH_LIBS([yywrap], [fl l], [LEXLIB="$LIBS"])
849 LIBS="$ac_save_LIBS"])dnl
853 dnl This test is done last so that we don't define YYTEXT_POINTER if
854 dnl any of the above tests gave up on lex.
855 AS_IF([test "$LEX" != :], [
856 AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
857 [# POSIX says lex can declare yytext either as a pointer or an array; the
858 # default is implementation-dependent. Figure out which it is, since
859 # not all implementations provide the %pointer and %array declarations.
860 ac_cv_prog_lex_yytext_pointer=no
861 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED
862 [#define YYTEXT_POINTER 1
863 `cat $LEX_OUTPUT_ROOT.c`]],
864 [ac_cv_prog_lex_yytext_pointer=yes])
867 if test $ac_cv_prog_lex_yytext_pointer = yes; then
868 AC_DEFINE(YYTEXT_POINTER, 1,
869 [Define to 1 if `lex' declares `yytext' as a `char *' by default,
873 rm -f conftest.l $LEX_OUTPUT_ROOT.c
874 ])# _AC_PROG_LEX_YYTEXT_DECL
877 # Require AC_PROG_LEX in case some people were just calling this macro.
878 AU_DEFUN([AC_DECL_YYTEXT], [AC_PROG_LEX])
883 AN_MAKEVAR([LN], [AC_PROG_LN_S])
884 AN_PROGRAM([ln], [AC_PROG_LN_S])
885 AC_DEFUN([AC_PROG_LN_S],
886 [AC_MSG_CHECKING([whether ln -s works])
887 AC_SUBST([LN_S], [$as_ln_s])dnl
888 if test "$LN_S" = "ln -s"; then
891 AC_MSG_RESULT([no, using $LN_S])
898 # Define SET_MAKE to set ${MAKE} if Make does not do so automatically. If Make
899 # does not run the test Makefile, we assume that the Make program the user will
900 # invoke does set $(MAKE). This is typical, and emitting `MAKE=foomake' is
901 # always wrong if `foomake' is not available or does not work.
902 AN_MAKEVAR([MAKE], [AC_PROG_MAKE_SET])
903 AN_PROGRAM([make], [AC_PROG_MAKE_SET])
904 AC_DEFUN([AC_PROG_MAKE_SET],
905 [AC_MSG_CHECKING([whether ${MAKE-make} sets \$(MAKE)])
907 ac_make=`AS_ECHO(["$[2]"]) | sed 's/+/p/g; s/[[^a-zA-Z0-9_]]/_/g'`
908 AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
909 [cat >conftest.make <<\_ACEOF
912 @echo '@@@%%%=$(MAKE)=@@@%%%'
914 # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
915 case `${MAKE-make} -f conftest.make 2>/dev/null` in
917 eval ac_cv_prog_make_${ac_make}_set=yes;;
919 eval ac_cv_prog_make_${ac_make}_set=no;;
921 rm -f conftest.make])dnl
922 if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
927 SET_MAKE="MAKE=${MAKE-make}"
929 AC_SUBST([SET_MAKE])dnl
935 AN_MAKEVAR([RANLIB], [AC_PROG_RANLIB])
936 AN_PROGRAM([ranlib], [AC_PROG_RANLIB])
937 AC_DEFUN([AC_PROG_RANLIB],
938 [AC_CHECK_TOOL(RANLIB, ranlib, :)])
943 # I don't know what it used to do, but it no longer does.
944 AU_DEFUN([AC_RSH], [],
945 [$0 is no longer supported. Remove this warning when you
951 # Check for a fully functional sed program that truncates
952 # as few characters as possible. Prefer GNU sed if found.
953 AC_DEFUN([AC_PROG_SED],
954 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
955 [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
956 dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
957 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
958 for ac_i in 1 2 3 4 5 6 7; do
959 ac_script="$ac_script$as_nl$ac_script"
961 echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
962 AS_UNSET([ac_script])
963 _AC_PATH_PROGS_FEATURE_CHECK(SED, [sed gsed],
964 [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
965 ["$ac_path_SED" -f conftest.sed])])])
966 SED="$ac_cv_path_SED"
974 AN_MAKEVAR([BISON], [AC_PROG_YACC])
975 AN_MAKEVAR([YACC], [AC_PROG_YACC])
976 AN_MAKEVAR([YFLAGS], [AC_PROG_YACC])
977 AN_PROGRAM([yacc], [AC_PROG_YACC])
978 AN_PROGRAM([byacc], [AC_PROG_YACC])
979 AN_PROGRAM([bison], [AC_PROG_YACC])
980 AC_DEFUN([AC_PROG_YACC],
981 [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)dnl
983 [The `Yet Another Compiler Compiler' implementation to use. Defaults to
984 the first program found out of: `bison -y', `byacc', `yacc'.])dnl
986 [The list of arguments that will be passed by default to $YACC. This script
987 will default YFLAGS to the empty string to avoid a default value of `-d' given
988 by some make applications.])])