1e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#!/bin/sh
2e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevprefix=@prefix@
4e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexec_prefix=@exec_prefix@
5e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevincludedir=@includedir@
6e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlibdir=@libdir@
7e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexec_prefix_set=no
8e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
9e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevusage()
10e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
11e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	cat <<EOF
12e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevUsage: libusb-config [OPTIONS] [LIBRARIES]
13e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevOptions:
14e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[--prefix[=DIR]]
15e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[--exec-prefix[=DIR]]
16e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[--version]
17e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[--libs]
18e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[--cflags]
19e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
20e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $1
21e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
22e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
23e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test $# -eq 0; then
24e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	usage 1 1>&2
25e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
26e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
27e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevwhile test $# -gt 0; do
28e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case "$1" in
29e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
30e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *) optarg= ;;
31e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
32e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
33e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case $1 in
34e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --prefix=*)
35e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      prefix=$optarg
36e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test $exec_prefix_set = no ; then
37e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        exec_prefix=$optarg
38e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
39e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
40e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --prefix)
41e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      echo_prefix=yes
42e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
43e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --exec-prefix=*)
44e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec_prefix=$optarg
45e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec_prefix_set=yes
46e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
47e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --exec-prefix)
48e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      echo_exec_prefix=yes
49e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
50e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --version)
51e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      echo @LIBUSB01_VERSION@
52e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exit 0
53e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
54e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --cflags)
55e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$includedir" != /usr/include ; then
56e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        includes="-I$includedir"
57e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
58e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      echo_cflags=yes
59e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
60e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    --libs)
61e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      echo_libs=yes
62e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
63e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
64e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      usage 1 1>&2
65e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
66e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
67e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  shift
68e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdone
69e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
70e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "$echo_prefix" = "yes"; then
71e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	echo $prefix
72e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
73e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "$echo_exec_prefix" = "yes"; then
74e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	echo $exec_prefix
75e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
76e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "$echo_cflags" = "yes"; then
77e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	echo $includes
78e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
79e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "$echo_libs" = "yes"; then
80e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	echo -L$libdir -lusb
81e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
82