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