2003-05-04 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / gpgme / gpgme-config.in
1 #!/bin/sh
2 #    Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3 #
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
7 #
8 # This file is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12 PGM=gpgme-config
13 libs="@GPGME_CONFIG_LIBS@"
14 cflags="@GPGME_CONFIG_CFLAGS@"
15 prefix=@prefix@
16 exec_prefix=@exec_prefix@
17 includes=""
18 libdirs=""
19 exec_prefix_set=no
20 echo_libs=no
21 echo_cflags=no
22 echo_prefix=no
23 echo_exec_prefix=no
24
25
26 usage()
27 {
28         cat <<EOF
29 Usage: $PGM [OPTIONS]
30 Options:
31         [--prefix[=DIR]]
32         [--exec-prefix[=DIR]]
33         [--version]
34         [--libs]
35         [--cflags]
36 EOF
37         exit $1
38 }
39
40 if test $# -eq 0; then
41         usage 1 1>&2
42 fi
43
44 while test $# -gt 0; do
45   case "$1" in
46   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
47   *) optarg= ;;
48   esac
49
50   case $1 in
51     --prefix=*)
52       prefix=$optarg
53       if test $exec_prefix_set = no ; then
54         exec_prefix=$optarg
55       fi
56       ;;
57     --prefix)
58       echo_prefix=yes
59       ;;
60     --exec-prefix=*)
61       exec_prefix=$optarg
62       exec_prefix_set=yes
63       ;;
64     --exec-prefix)
65       echo_exec_prefix=yes
66       ;;
67     --version)
68       echo "@VERSION@"
69       exit 0
70       ;;
71     --cflags)
72       echo_cflags=yes
73       ;;
74     --libs)
75       echo_libs=yes
76       ;;
77     *)
78       usage 1 1>&2
79       ;;
80   esac
81   shift
82 done
83
84 if test "$echo_prefix" = "yes"; then
85     echo $prefix
86 fi
87
88 if test "$echo_exec_prefix" = "yes"; then
89     echo $exec_prefix
90 fi
91
92 if test "$echo_cflags" = "yes"; then
93     if test "@includedir@" != "/usr/include" ; then
94       includes="-I@includedir@"
95       for i in $cflags ; do
96         if test "$i" = "-I@includedir@" ; then
97           includes=""
98         fi
99       done
100     fi
101     echo $includes $cflags
102 fi
103
104 if test "$echo_libs" = "yes"; then
105     if test "@libdir@" != "/usr/lib" ; then
106       libdirs="-L@libdir@"
107       for i in $libs ; do
108         if test "$i" = "-L@libdir@" ; then
109           libdirs=""
110         fi
111       done
112     fi
113     echo $libdirs $libs
114 fi
115