2007-09-27 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / gpgme / gpgme-config.in
1 #!/bin/sh
2 # Copyright (C) 1999, 2002, 2003 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 prefix=@prefix@
13 exec_prefix=@exec_prefix@
14 includedir=@includedir@
15 libdir=@libdir@
16
17 # Network libraries.
18 netlibs="@NETLIBS@"
19
20 # Configure libgpg-error.
21 gpg_error_cflags="@GPG_ERROR_CFLAGS@"
22 gpg_error_libs="@GPG_ERROR_LIBS@"
23
24 # Configure thread packages.
25 thread_modules=""
26
27 @HAVE_PTH_TRUE@thread_modules="$thread_modules pth"
28 libs_pth="@PTH_LDFLAGS@ @PTH_LIBS@"
29 cflags_pth="@PTH_CFLAGS@"
30
31 @HAVE_PTHREAD_TRUE@thread_modules="$thread_modules pthread"
32 libs_pthread="-lpthread"
33 cflags_pthread=""
34
35 # Configure glib.
36 libs_glib="@GLIB_LIBS@"
37 cflags_glib="@GLIB_CFLAGS@"
38 with_glib=
39
40 output=""
41
42 usage()
43 {
44     cat <<EOF
45 Usage: gpgme-config [OPTIONS]
46 Options:
47         [--thread={${thread_modules}}]
48         [--prefix]
49         [--exec-prefix]
50         [--version]
51         [--api-version]
52         [--libs]
53         [--cflags]
54         [--get-gpg]
55         [--get-gpgsm]
56 EOF
57     exit $1
58 }
59
60 if test $# -eq 0; then
61     usage 1 1>&2
62 fi
63
64 while test $# -gt 0; do
65     case "$1" in
66         -*=*)
67             optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
68             ;;
69         *)
70             optarg=
71             ;;
72     esac
73
74     case $1 in
75         --prefix=*)
76             # For compatibility reasons with old M4 macros, we ignore
77             # setting of prefix.
78             ;;
79         --prefix)
80             output="$output $prefix"
81             ;;
82         --exec-prefix=*)
83             ;;
84         --exec-prefix)
85             output="$output $exec_prefix"
86             ;;
87         --glib)
88             with_glib=yes
89             ;;
90         --version)
91             echo "@VERSION@"
92             exit 0
93             ;;
94         --api-version)
95             echo "@GPGME_CONFIG_API_VERSION@"
96             exit 0
97             ;;
98         --cflags)
99             if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then
100                 output="$output -I$includedir"
101             fi
102             case "$thread_module" in
103                 pthread)
104                     output="$output $cflags_pthread"
105                     ;;
106                 pth)
107                     output="$output $cflags_pth"
108                     ;;
109             esac
110             output="$output $gpg_error_cflags"
111             if test "x$with_glib" = "xyes"; then
112                 output="$output $glib_cflags"
113             fi
114             ;;
115         --libs)
116             if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/lib"; then
117                 output="$output -L$libdir"
118             fi
119             case "$thread_module" in
120                 pthread)
121                     output="$output -lgpgme-pthread $libs_pthread"
122                     ;;
123                 pth)
124                     output="$output -lgpgme-pth $libs_pth"
125                     ;;
126                 *)
127                     if test "x$with_glib" = "xyes"; then
128                         output="$output -lgpgme-glib"
129                     else
130                         output="$output -lgpgme"
131                     fi
132                     ;;
133             esac
134             output="$output $gpg_error_libs $netlibs"
135             if test "x$with_glib" = "xyes"; then
136                 output="$output $glib_cflags"
137             fi
138             ;;
139         --thread=*)
140             for thread_mod in $thread_modules; do
141             if test "$thread_mod" = "$optarg"; then
142                 thread_module="$optarg";
143             fi
144             done
145             if test "x$thread_module" = "x"; then
146                 usage 1 1>&2
147             fi
148             ;;
149         --get-gpg)
150             output="$output @GPG@"
151             ;;
152         --get-gpgsm)
153             output="$output @GPGSM@"
154             ;;
155         *)
156             usage 1 1>&2
157             ;;
158     esac
159     shift
160 done
161
162 echo $output