xref: /openbsd-src/gnu/usr.bin/texinfo/m4/progtest.m4 (revision a1acfa9b69ad64eb720639240c8438f11107dc85)
1*a1acfa9bSespie# progtest.m4 serial 3 (gettext-0.12)
2*a1acfa9bSespiednl Copyright (C) 1996-2003 Free Software Foundation, Inc.
3f8dd34f6Sespiednl This file is free software, distributed under the terms of the GNU
4f8dd34f6Sespiednl General Public License.  As a special exception to the GNU General
5f8dd34f6Sespiednl Public License, this file may be distributed as part of a program
6f8dd34f6Sespiednl that contains a configuration script generated by Autoconf, under
7f8dd34f6Sespiednl the same distribution terms as the rest of that program.
8f8dd34f6Sespiednl
9f8dd34f6Sespiednl This file can can be used in projects which are not available under
10f8dd34f6Sespiednl the GNU General Public License or the GNU Library General Public
11f8dd34f6Sespiednl License but which still want to provide support for the GNU gettext
12f8dd34f6Sespiednl functionality.
13f8dd34f6Sespiednl Please note that the actual code of the GNU gettext library is covered
14f8dd34f6Sespiednl by the GNU Library General Public License, and the rest of the GNU
15f8dd34f6Sespiednl gettext package package is covered by the GNU General Public License.
16f8dd34f6Sespiednl They are *not* in the public domain.
17f8dd34f6Sespie
18f8dd34f6Sespiednl Authors:
19f8dd34f6Sespiednl   Ulrich Drepper <drepper@cygnus.com>, 1996.
20f8dd34f6Sespie
21f8dd34f6Sespie# Search path for a program which passes the given test.
22f8dd34f6Sespie
23f8dd34f6Sespiednl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
24f8dd34f6Sespiednl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
25f8dd34f6SespieAC_DEFUN([AM_PATH_PROG_WITH_TEST],
26*a1acfa9bSespie[
27*a1acfa9bSespie# Prepare PATH_SEPARATOR.
28*a1acfa9bSespie# The user is always right.
29*a1acfa9bSespieif test "${PATH_SEPARATOR+set}" != set; then
30*a1acfa9bSespie  echo "#! /bin/sh" >conf$$.sh
31*a1acfa9bSespie  echo  "exit 0"   >>conf$$.sh
32*a1acfa9bSespie  chmod +x conf$$.sh
33*a1acfa9bSespie  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
34*a1acfa9bSespie    PATH_SEPARATOR=';'
35*a1acfa9bSespie  else
36*a1acfa9bSespie    PATH_SEPARATOR=:
37*a1acfa9bSespie  fi
38*a1acfa9bSespie  rm -f conf$$.sh
39*a1acfa9bSespiefi
40*a1acfa9bSespie
41*a1acfa9bSespie# Find out how to test for executable files. Don't use a zero-byte file,
42*a1acfa9bSespie# as systems may use methods other than mode bits to determine executability.
43*a1acfa9bSespiecat >conf$$.file <<_ASEOF
44*a1acfa9bSespie#! /bin/sh
45*a1acfa9bSespieexit 0
46*a1acfa9bSespie_ASEOF
47*a1acfa9bSespiechmod +x conf$$.file
48*a1acfa9bSespieif test -x conf$$.file >/dev/null 2>&1; then
49*a1acfa9bSespie  ac_executable_p="test -x"
50*a1acfa9bSespieelse
51*a1acfa9bSespie  ac_executable_p="test -f"
52*a1acfa9bSespiefi
53*a1acfa9bSespierm -f conf$$.file
54*a1acfa9bSespie
55*a1acfa9bSespie# Extract the first word of "$2", so it can be a program name with args.
56f8dd34f6Sespieset dummy $2; ac_word=[$]2
57f8dd34f6SespieAC_MSG_CHECKING([for $ac_word])
58f8dd34f6SespieAC_CACHE_VAL(ac_cv_path_$1,
59f8dd34f6Sespie[case "[$]$1" in
60*a1acfa9bSespie  [[\\/]]* | ?:[[\\/]]*)
61f8dd34f6Sespie    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
62f8dd34f6Sespie    ;;
63f8dd34f6Sespie  *)
64*a1acfa9bSespie    ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
65f8dd34f6Sespie    for ac_dir in ifelse([$5], , $PATH, [$5]); do
66*a1acfa9bSespie      IFS="$ac_save_IFS"
67f8dd34f6Sespie      test -z "$ac_dir" && ac_dir=.
68*a1acfa9bSespie      for ac_exec_ext in '' $ac_executable_extensions; do
69*a1acfa9bSespie        if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
70f8dd34f6Sespie          if [$3]; then
71*a1acfa9bSespie            ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
72*a1acfa9bSespie            break 2
73f8dd34f6Sespie          fi
74f8dd34f6Sespie        fi
75f8dd34f6Sespie      done
76*a1acfa9bSespie    done
77*a1acfa9bSespie    IFS="$ac_save_IFS"
78f8dd34f6Sespiednl If no 4th arg is given, leave the cache variable unset,
79f8dd34f6Sespiednl so AC_PATH_PROGS will keep looking.
80f8dd34f6Sespieifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
81f8dd34f6Sespie])dnl
82f8dd34f6Sespie    ;;
83f8dd34f6Sespieesac])dnl
84f8dd34f6Sespie$1="$ac_cv_path_$1"
85f8dd34f6Sespieif test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
86f8dd34f6Sespie  AC_MSG_RESULT([$]$1)
87f8dd34f6Sespieelse
88f8dd34f6Sespie  AC_MSG_RESULT(no)
89f8dd34f6Sespiefi
90f8dd34f6SespieAC_SUBST($1)dnl
91f8dd34f6Sespie])
92