xref: /minix3/external/bsd/flex/dist/m4/progtest.m4 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc# progtest.m4 serial 6 (gettext-0.18)
2*0a6a1f1dSLionel Sambucdnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc.
3*0a6a1f1dSLionel Sambucdnl This file is free software; the Free Software Foundation
4*0a6a1f1dSLionel Sambucdnl gives unlimited permission to copy and/or distribute it,
5*0a6a1f1dSLionel Sambucdnl with or without modifications, as long as this notice is preserved.
6357f1050SThomas Veermandnl
7357f1050SThomas Veermandnl This file can can be used in projects which are not available under
8357f1050SThomas Veermandnl the GNU General Public License or the GNU Library General Public
9357f1050SThomas Veermandnl License but which still want to provide support for the GNU gettext
10357f1050SThomas Veermandnl functionality.
11357f1050SThomas Veermandnl Please note that the actual code of the GNU gettext library is covered
12357f1050SThomas Veermandnl by the GNU Library General Public License, and the rest of the GNU
13357f1050SThomas Veermandnl gettext package package is covered by the GNU General Public License.
14357f1050SThomas Veermandnl They are *not* in the public domain.
15357f1050SThomas Veerman
16357f1050SThomas Veermandnl Authors:
17357f1050SThomas Veermandnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
18357f1050SThomas Veerman
19*0a6a1f1dSLionel SambucAC_PREREQ([2.50])
20*0a6a1f1dSLionel Sambuc
21357f1050SThomas Veerman# Search path for a program which passes the given test.
22357f1050SThomas Veerman
23357f1050SThomas Veermandnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
24357f1050SThomas Veermandnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
25357f1050SThomas VeermanAC_DEFUN([AM_PATH_PROG_WITH_TEST],
26357f1050SThomas Veerman[
27357f1050SThomas Veerman# Prepare PATH_SEPARATOR.
28357f1050SThomas Veerman# The user is always right.
29357f1050SThomas Veermanif test "${PATH_SEPARATOR+set}" != set; then
30357f1050SThomas Veerman  echo "#! /bin/sh" >conf$$.sh
31357f1050SThomas Veerman  echo  "exit 0"   >>conf$$.sh
32357f1050SThomas Veerman  chmod +x conf$$.sh
33357f1050SThomas Veerman  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
34357f1050SThomas Veerman    PATH_SEPARATOR=';'
35357f1050SThomas Veerman  else
36357f1050SThomas Veerman    PATH_SEPARATOR=:
37357f1050SThomas Veerman  fi
38357f1050SThomas Veerman  rm -f conf$$.sh
39357f1050SThomas Veermanfi
40357f1050SThomas Veerman
41357f1050SThomas Veerman# Find out how to test for executable files. Don't use a zero-byte file,
42357f1050SThomas Veerman# as systems may use methods other than mode bits to determine executability.
43357f1050SThomas Veermancat >conf$$.file <<_ASEOF
44357f1050SThomas Veerman#! /bin/sh
45357f1050SThomas Veermanexit 0
46357f1050SThomas Veerman_ASEOF
47357f1050SThomas Veermanchmod +x conf$$.file
48357f1050SThomas Veermanif test -x conf$$.file >/dev/null 2>&1; then
49357f1050SThomas Veerman  ac_executable_p="test -x"
50357f1050SThomas Veermanelse
51357f1050SThomas Veerman  ac_executable_p="test -f"
52357f1050SThomas Veermanfi
53357f1050SThomas Veermanrm -f conf$$.file
54357f1050SThomas Veerman
55357f1050SThomas Veerman# Extract the first word of "$2", so it can be a program name with args.
56357f1050SThomas Veermanset dummy $2; ac_word=[$]2
57357f1050SThomas VeermanAC_MSG_CHECKING([for $ac_word])
58*0a6a1f1dSLionel SambucAC_CACHE_VAL([ac_cv_path_$1],
59357f1050SThomas Veerman[case "[$]$1" in
60357f1050SThomas Veerman  [[\\/]]* | ?:[[\\/]]*)
61357f1050SThomas Veerman    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
62357f1050SThomas Veerman    ;;
63357f1050SThomas Veerman  *)
64357f1050SThomas Veerman    ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
65357f1050SThomas Veerman    for ac_dir in ifelse([$5], , $PATH, [$5]); do
66357f1050SThomas Veerman      IFS="$ac_save_IFS"
67357f1050SThomas Veerman      test -z "$ac_dir" && ac_dir=.
68357f1050SThomas Veerman      for ac_exec_ext in '' $ac_executable_extensions; do
69357f1050SThomas Veerman        if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
70*0a6a1f1dSLionel Sambuc          echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
71357f1050SThomas Veerman          if [$3]; then
72357f1050SThomas Veerman            ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
73357f1050SThomas Veerman            break 2
74357f1050SThomas Veerman          fi
75357f1050SThomas Veerman        fi
76357f1050SThomas Veerman      done
77357f1050SThomas Veerman    done
78357f1050SThomas Veerman    IFS="$ac_save_IFS"
79357f1050SThomas Veermandnl If no 4th arg is given, leave the cache variable unset,
80357f1050SThomas Veermandnl so AC_PATH_PROGS will keep looking.
81357f1050SThomas Veermanifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
82357f1050SThomas Veerman])dnl
83357f1050SThomas Veerman    ;;
84357f1050SThomas Veermanesac])dnl
85357f1050SThomas Veerman$1="$ac_cv_path_$1"
86357f1050SThomas Veermanif test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
87*0a6a1f1dSLionel Sambuc  AC_MSG_RESULT([$][$1])
88357f1050SThomas Veermanelse
89*0a6a1f1dSLionel Sambuc  AC_MSG_RESULT([no])
90357f1050SThomas Veermanfi
91*0a6a1f1dSLionel SambucAC_SUBST([$1])dnl
92357f1050SThomas Veerman])
93