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