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