2003-08-15 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 gpg_error_cflags="@GPG_ERROR_CFLAGS@"
26 gpg_error_libs="@GPG_ERROR_LIBS@"
27
28
29 usage()
30 {
31         cat <<EOF
32 Usage: $PGM [OPTIONS]
33 Options:
34         [--prefix[=DIR]]
35         [--exec-prefix[=DIR]]
36         [--version]
37         [--libs]
38         [--cflags]
39 EOF
40         exit $1
41 }
42
43 if test $# -eq 0; then
44         usage 1 1>&2
45 fi
46
47 while test $# -gt 0; do
48   case "$1" in
49   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
50   *) optarg= ;;
51   esac
52
53   case $1 in
54     --prefix=*)
55       prefix=$optarg
56       if test $exec_prefix_set = no ; then
57         exec_prefix=$optarg
58       fi
59       ;;
60     --prefix)
61       echo_prefix=yes
62       ;;
63     --exec-prefix=*)
64       exec_prefix=$optarg
65       exec_prefix_set=yes
66       ;;
67     --exec-prefix)
68       echo_exec_prefix=yes
69       ;;
70     --version)
71       echo "@VERSION@"
72       exit 0
73       ;;
74     --cflags)
75       echo_cflags=yes
76       ;;
77     --libs)
78       echo_libs=yes
79       ;;
80     *)
81       usage 1 1>&2
82       ;;
83   esac
84   shift
85 done
86
87 if test "$echo_prefix" = "yes"; then
88     echo $prefix
89 fi
90
91 if test "$echo_exec_prefix" = "yes"; then
92     echo $exec_prefix
93 fi
94
95 if test "$echo_cflags" = "yes"; then
96     if test "@includedir@" != "/usr/include" ; then
97       includes="-I@includedir@"
98       for i in $cflags ; do
99         if test "$i" = "-I@includedir@" ; then
100           includes=""
101         fi
102       done
103     fi
104     echo $includes $cflags $gpg_error_cflags
105 fi
106
107 if test "$echo_libs" = "yes"; then
108     if test "@libdir@" != "/usr/lib" ; then
109       libdirs="-L@libdir@"
110       for i in $libs ; do
111         if test "$i" = "-L@libdir@" ; then
112           libdirs=""
113         fi
114       done
115     fi
116     echo $libdirs $libs $gpg_error_libs
117 fi
118