xref: /netbsd-src/external/bsd/flex/dist/m4/progtest.m4 (revision 463ae347b383ca644b1399e7e5228310d0bdf969)
1*463ae347Schristos# progtest.m4 serial 6 (gettext-0.18)
2*463ae347Schristosdnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc.
37f71b389Schristosdnl This file is free software; the Free Software Foundation
47f71b389Schristosdnl gives unlimited permission to copy and/or distribute it,
57f71b389Schristosdnl with or without modifications, as long as this notice is preserved.
63c3a7b76Schristosdnl
73c3a7b76Schristosdnl This file can can be used in projects which are not available under
83c3a7b76Schristosdnl the GNU General Public License or the GNU Library General Public
93c3a7b76Schristosdnl License but which still want to provide support for the GNU gettext
103c3a7b76Schristosdnl functionality.
113c3a7b76Schristosdnl Please note that the actual code of the GNU gettext library is covered
123c3a7b76Schristosdnl by the GNU Library General Public License, and the rest of the GNU
133c3a7b76Schristosdnl gettext package package is covered by the GNU General Public License.
143c3a7b76Schristosdnl They are *not* in the public domain.
153c3a7b76Schristos
163c3a7b76Schristosdnl Authors:
173c3a7b76Schristosdnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
183c3a7b76Schristos
197f71b389SchristosAC_PREREQ([2.50])
207f71b389Schristos
213c3a7b76Schristos# Search path for a program which passes the given test.
223c3a7b76Schristos
233c3a7b76Schristosdnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
243c3a7b76Schristosdnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
253c3a7b76SchristosAC_DEFUN([AM_PATH_PROG_WITH_TEST],
263c3a7b76Schristos[
273c3a7b76Schristos# Prepare PATH_SEPARATOR.
283c3a7b76Schristos# The user is always right.
293c3a7b76Schristosif test "${PATH_SEPARATOR+set}" != set; then
30*463ae347Schristos  echo "#! /bin/sh" >conf$$.sh
31*463ae347Schristos  echo  "exit 0"   >>conf$$.sh
32*463ae347Schristos  chmod +x conf$$.sh
33*463ae347Schristos  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
34*463ae347Schristos    PATH_SEPARATOR=';'
35*463ae347Schristos  else
363c3a7b76Schristos    PATH_SEPARATOR=:
37*463ae347Schristos  fi
38*463ae347Schristos  rm -f conf$$.sh
393c3a7b76Schristosfi
403c3a7b76Schristos
413c3a7b76Schristos# Find out how to test for executable files. Don't use a zero-byte file,
423c3a7b76Schristos# as systems may use methods other than mode bits to determine executability.
433c3a7b76Schristoscat >conf$$.file <<_ASEOF
443c3a7b76Schristos#! /bin/sh
453c3a7b76Schristosexit 0
463c3a7b76Schristos_ASEOF
473c3a7b76Schristoschmod +x conf$$.file
483c3a7b76Schristosif test -x conf$$.file >/dev/null 2>&1; then
493c3a7b76Schristos  ac_executable_p="test -x"
503c3a7b76Schristoselse
513c3a7b76Schristos  ac_executable_p="test -f"
523c3a7b76Schristosfi
533c3a7b76Schristosrm -f conf$$.file
543c3a7b76Schristos
553c3a7b76Schristos# Extract the first word of "$2", so it can be a program name with args.
563c3a7b76Schristosset dummy $2; ac_word=[$]2
573c3a7b76SchristosAC_MSG_CHECKING([for $ac_word])
587f71b389SchristosAC_CACHE_VAL([ac_cv_path_$1],
593c3a7b76Schristos[case "[$]$1" in
603c3a7b76Schristos  [[\\/]]* | ?:[[\\/]]*)
613c3a7b76Schristos    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
623c3a7b76Schristos    ;;
633c3a7b76Schristos  *)
643c3a7b76Schristos    ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
653c3a7b76Schristos    for ac_dir in ifelse([$5], , $PATH, [$5]); do
663c3a7b76Schristos      IFS="$ac_save_IFS"
673c3a7b76Schristos      test -z "$ac_dir" && ac_dir=.
683c3a7b76Schristos      for ac_exec_ext in '' $ac_executable_extensions; do
693c3a7b76Schristos        if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
707f71b389Schristos          echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
713c3a7b76Schristos          if [$3]; then
723c3a7b76Schristos            ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
733c3a7b76Schristos            break 2
743c3a7b76Schristos          fi
753c3a7b76Schristos        fi
763c3a7b76Schristos      done
773c3a7b76Schristos    done
783c3a7b76Schristos    IFS="$ac_save_IFS"
793c3a7b76Schristosdnl If no 4th arg is given, leave the cache variable unset,
803c3a7b76Schristosdnl so AC_PATH_PROGS will keep looking.
813c3a7b76Schristosifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
823c3a7b76Schristos])dnl
833c3a7b76Schristos    ;;
843c3a7b76Schristosesac])dnl
853c3a7b76Schristos$1="$ac_cv_path_$1"
863c3a7b76Schristosif test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
877f71b389Schristos  AC_MSG_RESULT([$][$1])
883c3a7b76Schristoselse
897f71b389Schristos  AC_MSG_RESULT([no])
903c3a7b76Schristosfi
917f71b389SchristosAC_SUBST([$1])dnl
923c3a7b76Schristos])
93