1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for programs.
4 # Copyright (C) 1992-1996, 1998-2017, 2020-2022 Free Software
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).
346 AN_MAKEVAR([AR], [AC_PROG_AR])
347 AN_PROGRAM([ar], [AC_PROG_AR])
348 AC_DEFUN([AC_PROG_AR],
349 [AC_CHECK_TOOL(AR, ar, :)])
352 # Check for gawk first since it's generally better.
353 AN_MAKEVAR([AWK], [AC_PROG_AWK])
354 AN_PROGRAM([awk], [AC_PROG_AWK])
355 AN_PROGRAM([gawk], [AC_PROG_AWK])
356 AN_PROGRAM([mawk], [AC_PROG_AWK])
357 AN_PROGRAM([nawk], [AC_PROG_AWK])
358 AC_DEFUN([AC_PROG_AWK],
359 [AC_CHECK_PROGS(AWK, gawk mawk nawk awk, )])
364 AC_DEFUN([AC_PROG_EGREP],
365 [AC_REQUIRE([AC_PROG_GREP])dnl
366 AC_CACHE_CHECK([for egrep], ac_cv_path_EGREP,
367 [if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
368 then ac_cv_path_EGREP="$GREP -E"
370 _AC_PROG_GREP(EGREP, egrep, ['EGREP$'])
372 EGREP="$ac_cv_path_EGREP"
379 AC_DEFUN([AC_PROG_FGREP],
380 [AC_REQUIRE([AC_PROG_GREP])dnl
381 AC_CACHE_CHECK([for fgrep], ac_cv_path_FGREP,
382 [if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
383 then ac_cv_path_FGREP="$GREP -F"
385 _AC_PROG_GREP(FGREP, fgrep, [FGREP])
387 FGREP="$ac_cv_path_FGREP"
394 # Check for a fully functional grep program that handles
395 # the longest lines possible and which respects multiple -e options.
396 # Prefer GNU grep if found.
397 AC_DEFUN([AC_PROG_GREP],
398 [AC_CACHE_CHECK([for grep that handles long lines and -e], ac_cv_path_GREP,
399 [_$0(GREP, [grep ggrep], [-e 'GREP$' -e '-(cannot match)-'])])
400 GREP="$ac_cv_path_GREP"
405 # _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, PROG-ARGUMENTS)
406 # ------------------------------------------------------
407 # Solaris 9 /usr/xpg4/bin/*grep is suitable, but /usr/bin/*grep lacks -e.
408 # AIX silently truncates long lines before matching.
409 # NeXT understands only one -e and truncates long lines.
410 m4_define([_AC_PROG_GREP],
411 [_AC_PATH_PROGS_FEATURE_CHECK([$1], [$2],
412 [_AC_FEATURE_CHECK_LENGTH([ac_path_$1], [ac_cv_path_$1],
413 ["$ac_path_$1" $3], [$1])], [],
414 [$PATH$PATH_SEPARATOR/usr/xpg4/bin])dnl
418 # _AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, FEATURE-TEST,
419 # [ACTION-IF-NOT-FOUND], [PATH=$PATH])
420 # -------------------------------------------------------------------
421 # FEATURE-TEST is called repeatedly with $ac_path_VARIABLE set to the
422 # name of a program in PROGNAME-LIST found in PATH. FEATURE-TEST must set
423 # $ac_cv_path_VARIABLE to the path of an acceptable program, or else
424 # ACTION-IF-NOT-FOUND is executed; the default action (for internal use
425 # only) issues a fatal error message. If a suitable $ac_path_VARIABLE is
426 # found in the FEATURE-TEST macro, it can set $ac_path_VARIABLE_found=':'
427 # to accept that value without any further checks.
428 m4_define([_AC_PATH_PROGS_FEATURE_CHECK],
429 [if test -z "$$1"; then
430 ac_path_$1_found=false
431 # Loop through the user's path and test for each of PROGNAME-LIST
435 for ac_exec_ext in '' $ac_executable_extensions; do
436 ac_path_$1="$as_dir$ac_prog$ac_exec_ext"
437 AS_EXECUTABLE_P(["$ac_path_$1"]) || continue
439 $ac_path_$1_found && break 3
442 if test -z "$ac_cv_path_$1"; then
444 [AC_MSG_ERROR([no acceptable m4_bpatsubst([$2], [ .*]) could be dnl
445 found in m4_default([$5], [\$PATH])])])
453 # AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST,
454 # FEATURE-TEST, [ACTION-IF-NOT-FOUND=:],
456 # ------------------------------------------------------------------
457 # Designed to be used inside AC_CACHE_VAL. It is recommended,
458 # but not required, that the user also use AC_ARG_VAR([VARIABLE]).
459 # If VARIABLE is not empty, set the cache variable
460 # $ac_cv_path_VARIABLE to VARIABLE without any further tests.
461 # Otherwise, call FEATURE_TEST repeatedly with $ac_path_VARIABLE
462 # set to the name of a program in PROGNAME-LIST found in PATH. If
463 # no invocation of FEATURE-TEST sets $ac_cv_path_VARIABLE to the
464 # path of an acceptable program, ACTION-IF-NOT-FOUND is executed.
465 # FEATURE-TEST is invoked even when $ac_cv_path_VARIABLE is set,
466 # in case a better candidate occurs later in PATH; to accept the
467 # current setting and bypass further checks, FEATURE-TEST can set
468 # $ac_path_VARIABLE_found=':'. Note that, unlike AC_CHECK_PROGS,
469 # this macro does not have any side effect on the current value
471 m4_define([AC_PATH_PROGS_FEATURE_CHECK],
472 [_$0([$1], [$2], [$3], m4_default([$4], [:]), [$5])dnl
476 # _AC_FEATURE_CHECK_LENGTH(PROGPATH, CACHE-VAR, CHECK-CMD, [MATCH-STRING])
477 # ------------------------------------------------------------------------
478 # For use as the FEATURE-TEST argument to _AC_PATH_PROGS_FEATURE_TEST.
479 # On each iteration run CHECK-CMD on an input file, storing the value
480 # of PROGPATH in CACHE-VAR if the CHECK-CMD succeeds. The input file
481 # is always one line, starting with only 10 characters, and doubling
482 # in length at each iteration until approx 10000 characters or the
483 # feature check succeeds. The feature check is called at each
484 # iteration by appending (optionally, MATCH-STRING and) a newline
485 # to the file, and using the result as input to CHECK-CMD.
486 m4_define([_AC_FEATURE_CHECK_LENGTH],
487 [# Check for GNU $1 and select it if it is found.
488 _AC_PATH_PROG_FLAVOR_GNU([$$1],
489 [$2="$$1" $1_found=:],
491 AS_ECHO_N([0123456789]) >"conftest.in"
494 cat "conftest.in" "conftest.in" >"conftest.tmp"
495 mv "conftest.tmp" "conftest.in"
496 cp "conftest.in" "conftest.nl"
497 AS_ECHO(['$4']) >> "conftest.nl"
498 $3 < "conftest.nl" >"conftest.out" 2>/dev/null || break
499 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
500 AS_VAR_ARITH([ac_count], [$ac_count + 1])
501 if test $ac_count -gt ${$1_max-0}; then
502 # Best one so far, save it but keep looking for a better one
504 dnl # Using $1_max so that each tool feature checked gets its
505 dnl # own variable. Don't reset it otherwise the implied search
506 dnl # for best performing tool in a list breaks down.
509 # 10*(2^10) chars as input seems more than enough
510 test $ac_count -gt 10 && break
512 rm -f conftest.in conftest.tmp conftest.nl conftest.out])dnl
516 # _AC_PATH_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
517 # ----------------------------------------------------------------
518 m4_define([_AC_PATH_PROG_FLAVOR_GNU],
520 case `"$1" --version 2>&1` in
527 ])# _AC_PATH_PROG_FLAVOR_GNU
532 AN_MAKEVAR([INSTALL], [AC_PROG_INSTALL])
533 AN_PROGRAM([install], [AC_PROG_INSTALL])
534 AC_DEFUN_ONCE([AC_PROG_INSTALL],
535 [AC_REQUIRE_AUX_FILE([install-sh])dnl
536 # Find a good install program. We prefer a C program (faster),
537 # so one script is as good as another. But avoid the broken or
538 # incompatible versions:
539 # SysV /etc/install, /usr/sbin/install
540 # SunOS /usr/etc/install
543 # AmigaOS /C/install, which installs bootblocks on floppy discs
544 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
545 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
546 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
547 # OS/2's system install, which has a completely different semantic
548 # ./install, which can be erroneously created by make from ./install.sh.
549 # Reject install programs that cannot install multiple files.
550 AC_MSG_CHECKING([for a BSD-compatible install])
551 if test -z "$INSTALL"; then
552 AC_CACHE_VAL(ac_cv_path_install,
553 [_AS_PATH_WALK([$PATH],
554 [[# Account for fact that we put trailing slashes in our PATH walk.
555 case $as_dir in @%:@((
557 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
558 ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
561 # OSF1 and SCO ODT 3.0 have their own names for install.
562 # Don't use installbsd from OSF since it installs stuff as root
564 for ac_prog in ginstall scoinst install; do
565 for ac_exec_ext in '' $ac_executable_extensions; do
566 if AS_EXECUTABLE_P(["$as_dir$ac_prog$ac_exec_ext"]); then
567 if test $ac_prog = install &&
568 grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
569 # AIX install. It has an incompatible calling convention.
571 elif test $ac_prog = install &&
572 grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
573 # program-specific install script used by HP pwplus--don't use.
576 rm -rf conftest.one conftest.two conftest.dir
577 echo one > conftest.one
578 echo two > conftest.two
580 if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" &&
581 test -s conftest.one && test -s conftest.two &&
582 test -s conftest.dir/conftest.one &&
583 test -s conftest.dir/conftest.two
585 ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c"
595 rm -rf conftest.one conftest.two conftest.dir
597 if test ${ac_cv_path_install+y}; then
598 INSTALL=$ac_cv_path_install
600 # As a last resort, use the slow shell script. Don't cache a
601 # value for INSTALL within a source directory, because that will
602 # break other packages using the cache if that directory is
603 # removed, or if the value is a relative name.
604 INSTALL=$ac_install_sh
607 dnl Do special magic for INSTALL instead of AC_SUBST, to get
608 dnl relative names right.
609 AC_MSG_RESULT([$INSTALL])
611 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
612 # It thinks the first close brace ends the variable substitution.
613 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
614 AC_SUBST(INSTALL_PROGRAM)dnl
616 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
617 AC_SUBST(INSTALL_SCRIPT)dnl
619 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
620 AC_SUBST(INSTALL_DATA)dnl
626 # Check whether 'mkdir -p' is known to be race-free, and fall back to
627 # install-sh -d otherwise.
629 # Automake 1.8 used 'mkdir -m 0755 -p --' to ensure that directories
630 # created by 'make install' are always world readable, even if the
631 # installer happens to have an overly restrictive umask (e.g. 077).
632 # This was a mistake. There are at least two reasons why we must not
634 # - it causes special bits like SGID to be ignored,
635 # - it may be too restrictive (some setups expect 775 directories).
637 # Do not use -m 0755 and let people choose whatever they expect by
640 # We cannot accept any implementation of 'mkdir' that recognizes '-p'.
641 # Some implementations (such as Solaris 8's) are vulnerable to race conditions:
642 # if a parallel make tries to run 'mkdir -p a/b' and 'mkdir -p a/c'
643 # concurrently, both version can detect that a/ is missing, but only
644 # one can create it and the other will error out. Consequently we
645 # restrict ourselves to known race-free implementations.
647 # Automake used to define mkdir_p as 'mkdir -p .', in order to
648 # allow $(mkdir_p) to be used without argument. As in
649 # $(mkdir_p) $(somedir)
650 # where $(somedir) is conditionally defined. However we don't do
652 # 1. before we restricted the check to GNU mkdir, 'mkdir -p .' was
653 # reported to fail in read-only directories. The system where this
654 # happened has been forgotten.
655 # 2. in practice we call $(MKDIR_P) on directories such as
656 # $(MKDIR_P) "$(DESTDIR)$(somedir)"
657 # and we don't want to create $(DESTDIR) if $(somedir) is empty.
658 # To support the latter case, we have to write
659 # test -z "$(somedir)" || $(MKDIR_P) "$(DESTDIR)$(somedir)"
660 # so $(MKDIR_P) always has an argument.
661 # We will have better chances of detecting a missing test if
662 # $(MKDIR_P) complains about missing arguments.
663 # 3. $(MKDIR_P) is named after 'mkdir -p' and we don't expect this
664 # to accept no argument.
665 # 4. having something like 'mkdir .' in the output is unsightly.
667 # On NextStep and OpenStep, the 'mkdir' command does not
668 # recognize any option. It will interpret all options as
669 # directories to create.
670 AN_MAKEVAR([MKDIR_P], [AC_PROG_MKDIR_P])
671 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
672 [AC_REQUIRE_AUX_FILE([install-sh])dnl
673 AC_MSG_CHECKING([for a race-free mkdir -p])
674 if test -z "$MKDIR_P"; then
675 AC_CACHE_VAL([ac_cv_path_mkdir],
676 [_AS_PATH_WALK([$PATH$PATH_SEPARATOR/opt/sfw/bin],
677 [for ac_prog in mkdir gmkdir; do
678 for ac_exec_ext in '' $ac_executable_extensions; do
679 AS_EXECUTABLE_P(["$as_dir$ac_prog$ac_exec_ext"]) || continue
680 case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #(
681 'mkdir ('*'coreutils) '* | \
683 'mkdir (fileutils) '4.1*)
684 ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext
689 test -d ./--version && rmdir ./--version
690 if test ${ac_cv_path_mkdir+y}; then
691 MKDIR_P="$ac_cv_path_mkdir -p"
693 # As a last resort, use the slow shell script. Don't cache a
694 # value for MKDIR_P within a source directory, because that will
695 # break other packages using the cache if that directory is
696 # removed, or if the value is a relative name.
697 MKDIR_P="$ac_install_sh -d"
700 dnl status.m4 does special magic for MKDIR_P instead of AC_SUBST,
701 dnl to get relative names right. However, also AC_SUBST here so
702 dnl that Automake versions before 1.10 will pick it up (they do not
703 dnl trace AC_SUBST_TRACE).
704 dnl FIXME: Remove this once we drop support for Automake < 1.10.
705 AC_SUBST([MKDIR_P])dnl
706 AC_MSG_RESULT([$MKDIR_P])
712 # Look for flex or lex. Set its associated library to LEXLIB.
713 # Check if lex declares yytext as a char * by default, not a char[].
714 AN_MAKEVAR([LEX], [AC_PROG_LEX])
715 AN_PROGRAM([lex], [AC_PROG_LEX])
716 AN_PROGRAM([flex], [AC_PROG_LEX])
717 AC_DEFUN([AC_PROG_LEX],
721 [m4_fatal([too many arguments to $0])])]dnl
722 [_$0(m4_normalize([$1]))])
724 AC_DEFUN([_AC_PROG_LEX],
729 [m4_fatal([AC_PROG_LEX: yywrap and noyywrap are mutually exclusive])],
731 [m4_fatal([AC_PROG_LEX: yywrap and noyywrap are mutually exclusive])],
734 [AC_PROG_LEX without either yywrap or noyywrap is obsolete])],
735 [m4_fatal([AC_PROG_LEX: unrecognized argument: $1])])]dnl
736 dnl We can't use AC_DEFUN_ONCE because this macro takes arguments.
737 dnl Silently skip a second invocation if the options match;
738 dnl warn if they don't.
739 [m4_ifdef([_AC_PROG_LEX_options],
740 [m4_if([$1], m4_defn([_AC_PROG_LEX_options]), [],
741 [m4_warn([syntax], [AC_PROG_LEX used twice with mismatched options])])],
743 dnl _AC_PROG_LEX_options not defined: first use
744 m4_define([_AC_PROG_LEX_options], [$1])dnl
745 AC_CHECK_PROGS(LEX, flex lex, :)
746 if test "x$LEX" != "x:"; then
747 _AC_PROG_LEX_YYTEXT_DECL([$1])
751 # _AC_PROG_LEX_YYTEXT_DECL
752 # ------------------------
753 # Check for the Lex output root, the Lex library, and whether Lex
754 # declares yytext as a char * by default.
755 AC_DEFUN([_AC_PROG_LEX_YYTEXT_DECL],
756 [cat >conftest.l <<_ACEOF[
768 e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
770 yyless ((yyinput () != 0));
772 yyless ((input () != 0));
775 f { unput (yytext[0]); }
778 #ifdef YYTEXT_POINTER
792 AC_CACHE_CHECK([for lex output file root], [ac_cv_prog_lex_root], [
793 ac_cv_prog_lex_root=unknown
794 _AC_DO_VAR(LEX conftest.l) &&
795 if test -f lex.yy.c; then
796 ac_cv_prog_lex_root=lex.yy
797 elif test -f lexyy.c; then
798 ac_cv_prog_lex_root=lexyy
800 AS_IF([test "$ac_cv_prog_lex_root" = unknown],
801 [AC_MSG_WARN([cannot find output from $LEX; giving up on $LEX])
803 AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl
805 AS_VAR_SET_IF([LEXLIB], [], [
806 AC_CACHE_CHECK([for lex library], [ac_cv_lib_lex], [
809 for ac_cv_lib_lex in 'none needed' -lfl -ll 'not found'; do
810 AS_CASE([$ac_cv_lib_lex],
812 ['not found'], [break],
813 [*], [LIBS="$ac_cv_lib_lex $ac_save_LIBS"])
815 AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED[`cat $LEX_OUTPUT_ROOT.c`]],
824 [test "$ac_cv_lib_lex" = 'not found'],
825 [AC_MSG_WARN([required lex library not found; giving up on $LEX])
827 [test "$ac_cv_lib_lex" = 'none needed'],
829 [LEXLIB=$ac_cv_lib_lex])
831 dnl For compatibility with autoconf 2.69 and prior, if $1 is not 'noyywrap',
832 dnl and we didn't already set LEXLIB to -ll or -lfl, see if one of those
833 dnl libraries provides yywrap and set LEXLIB to it if so. If $1 is 'yywrap',
834 dnl and we don't find a library that provides yywrap, we fail.
839 [ac_save_LIBS="$LIBS"
840 AS_IF([test -n "$LEXLIB"],
842 AC_CHECK_FUNC([yywrap],
844 [AC_MSG_WARN([$LEXLIB does not contain yywrap; giving up on $LEX])
848 AC_SEARCH_LIBS([yywrap], [fl l], [LEXLIB="$LIBS"])
849 AS_IF([test x"$ac_cv_search_yywrap" = xno],
850 [AC_MSG_WARN([yywrap not found; giving up on $LEX])
852 LIBS="$ac_save_LIBS"],
854 [ac_save_LIBS="$LIBS"
856 AC_SEARCH_LIBS([yywrap], [fl l], [LEXLIB="$LIBS"])
857 LIBS="$ac_save_LIBS"])dnl
861 dnl This test is done last so that we don't define YYTEXT_POINTER if
862 dnl any of the above tests gave up on lex.
863 AS_IF([test "$LEX" != :], [
864 AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
865 [# POSIX says lex can declare yytext either as a pointer or an array; the
866 # default is implementation-dependent. Figure out which it is, since
867 # not all implementations provide the %pointer and %array declarations.
868 ac_cv_prog_lex_yytext_pointer=no
869 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED
870 [#define YYTEXT_POINTER 1
871 `cat $LEX_OUTPUT_ROOT.c`]],
872 [ac_cv_prog_lex_yytext_pointer=yes])
875 if test $ac_cv_prog_lex_yytext_pointer = yes; then
876 AC_DEFINE(YYTEXT_POINTER, 1,
877 [Define to 1 if 'lex' declares 'yytext' as a 'char *' by default,
881 rm -f conftest.l $LEX_OUTPUT_ROOT.c
882 ])# _AC_PROG_LEX_YYTEXT_DECL
885 # Require AC_PROG_LEX in case some people were just calling this macro.
886 AU_DEFUN([AC_DECL_YYTEXT], [AC_PROG_LEX])
891 AN_MAKEVAR([LN], [AC_PROG_LN_S])
892 AN_PROGRAM([ln], [AC_PROG_LN_S])
893 AC_DEFUN([AC_PROG_LN_S],
894 [AC_MSG_CHECKING([whether ln -s works])
895 AC_SUBST([LN_S], [$as_ln_s])dnl
896 if test "$LN_S" = "ln -s"; then
899 AC_MSG_RESULT([no, using $LN_S])
906 # Define SET_MAKE to set ${MAKE} if Make does not do so automatically. If Make
907 # does not run the test Makefile, we assume that the Make program the user will
908 # invoke does set $(MAKE). This is typical, and emitting 'MAKE=foomake' is
909 # always wrong if 'foomake' is not available or does not work.
910 AN_MAKEVAR([MAKE], [AC_PROG_MAKE_SET])
911 AN_PROGRAM([make], [AC_PROG_MAKE_SET])
912 AC_DEFUN([AC_PROG_MAKE_SET],
913 [AC_MSG_CHECKING([whether ${MAKE-make} sets \$(MAKE)])
915 ac_make=`AS_ECHO(["$[2]"]) | sed 's/+/p/g; s/[[^a-zA-Z0-9_]]/_/g'`
916 AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
917 [cat >conftest.make <<\_ACEOF
920 @echo '@@@%%%=$(MAKE)=@@@%%%'
922 # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
923 case `${MAKE-make} -f conftest.make 2>/dev/null` in
925 eval ac_cv_prog_make_${ac_make}_set=yes;;
927 eval ac_cv_prog_make_${ac_make}_set=no;;
929 rm -f conftest.make])dnl
930 if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
935 SET_MAKE="MAKE=${MAKE-make}"
937 AC_SUBST([SET_MAKE])dnl
943 AN_MAKEVAR([RANLIB], [AC_PROG_RANLIB])
944 AN_PROGRAM([ranlib], [AC_PROG_RANLIB])
945 AC_DEFUN([AC_PROG_RANLIB],
946 [AC_CHECK_TOOL(RANLIB, ranlib, :)])
951 # I don't know what it used to do, but it no longer does.
952 AU_DEFUN([AC_RSH], [],
953 [$0 is no longer supported. Remove this warning when you
959 # Check for a fully functional sed program that truncates
960 # as few characters as possible. Prefer GNU sed if found.
961 AC_DEFUN([AC_PROG_SED],
962 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
963 [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
964 dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
965 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
966 for ac_i in 1 2 3 4 5 6 7; do
967 ac_script="$ac_script$as_nl$ac_script"
969 echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
970 AS_UNSET([ac_script])
971 _AC_PATH_PROGS_FEATURE_CHECK(SED, [sed gsed],
972 [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
973 ["$ac_path_SED" -f conftest.sed])])])
974 SED="$ac_cv_path_SED"
982 AN_MAKEVAR([BISON], [AC_PROG_YACC])
983 AN_MAKEVAR([YACC], [AC_PROG_YACC])
984 AN_MAKEVAR([YFLAGS], [AC_PROG_YACC])
985 AN_PROGRAM([yacc], [AC_PROG_YACC])
986 AN_PROGRAM([byacc], [AC_PROG_YACC])
987 AN_PROGRAM([bison], [AC_PROG_YACC])
988 AC_DEFUN([AC_PROG_YACC],
989 [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)dnl
991 [The 'Yet Another Compiler Compiler' implementation to use. Defaults to
992 the first program found out of: 'bison -y', 'byacc', 'yacc'.])dnl
994 [The list of arguments that will be passed by default to $YACC. This script
995 will default YFLAGS to the empty string to avoid a default value of '-d' given
996 by some make applications.])])