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