1dnl Autoconf macros used by libusb
2dnl
3dnl Copyright (C) 2003 Brad Hards <bradh@frogmouth.net
4dnl Qt tests based on pinentry code Copyright (C) 2002 g10 Code GmbH
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 2, or (at your option)
9dnl any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program; if not, write to the Free Software
18dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19dnl
20
21dnl LIBUSB_FIND_PATH(program-name, variable-name, list of directories, if-not-found, test-parameter)
22AC_DEFUN([LIBUSB_FIND_PATH],
23[
24   AC_MSG_CHECKING([for $1])
25   if test -n "$$2"; then
26        libusb_cv_path="$$2";
27   else
28        libusb_cache=`echo $1 | sed 'y%./+-%__p_%'`
29
30        AC_CACHE_VAL(libusb_cv_path_$libusb_cache,
31        [
32        libusb_cv_path="NONE"
33        dirs="$3"
34        libusb_save_IFS=$IFS
35        IFS=':'
36        for dir in $PATH; do
37          dirs="$dirs $dir"
38        done
39        IFS=$libusb_save_IFS
40
41        for dir in $dirs; do
42          if test -x "$dir/$1"; then
43            if test -n "$5"
44            then
45              evalstr="$dir/$1 $5 2>&1 "
46              if eval $evalstr; then
47                libusb_cv_path="$dir/$1"
48                break
49              fi
50            else
51                libusb_cv_path="$dir/$1"
52                break
53            fi
54          fi
55        done
56
57        eval "libusb_cv_path_$libusb_cache=$libusb_cv_path"
58
59        ])
60
61      eval "libusb_cv_path=\"`echo '$libusb_cv_path_'$libusb_cache`\""
62
63   fi
64
65   if test -z "$libusb_cv_path" || test "$libusb_cv_path" = NONE; then
66      AC_MSG_RESULT(not found)
67      $4
68   else
69      AC_MSG_RESULT($libusb_cv_path)
70      $2=$libusb_cv_path
71
72   fi
73])
74
75AC_DEFUN([LIBUSB_INIT_DOXYGEN],
76[
77AC_MSG_CHECKING([for Doxygen tools])
78
79LIBUSB_FIND_PATH(dot, DOT, [], [])
80if test -n "$DOT"; then
81  LIBUSB_HAVE_DOT="YES"
82else
83  LIBUSB_HAVE_DOT="NO"
84fi
85AC_SUBST(LIBUSB_HAVE_DOT)
86
87LIBUSB_FIND_PATH(doxygen, DOXYGEN, [], [])
88AC_SUBST(DOXYGEN)
89
90DOXYGEN_PROJECT_NAME="$1"
91DOXYGEN_PROJECT_NUMBER="$2"
92AC_SUBST(DOXYGEN_PROJECT_NAME)
93AC_SUBST(DOXYGEN_PROJECT_NUMBER)
94
95LIBUSB_HAS_DOXYGEN=no
96if test -n "$DOXYGEN" && test -x "$DOXYGEN"; then
97  LIBUSB_HAS_DOXYGEN=yes
98fi
99AC_SUBST(LIBUSB_HAS_DOXYGEN)
100
101])
102