2004-09-30 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 @HAVE_PTHREAD_TRUE@thread_modules="$thread_modules pthread"
29 libs_pthread="-lpthread"
30 cflags_pthread=""
31
32 output=""
33
34 usage()
35 {
36     cat <<EOF
37 Usage: gpgme-config [OPTIONS]
38 Options:
39         [--thread={${thread_modules}}]
40         [--prefix]
41         [--exec-prefix]
42         [--version]
43         [--api-version]
44         [--libs]
45         [--cflags]
46 EOF
47     exit $1
48 }
49
50 if test $# -eq 0; then
51     usage 1 1>&2
52 fi
53
54 while test $# -gt 0; do
55     case "$1" in
56         -*=*)
57             optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
58             ;;
59         *)
60             optarg=
61             ;;
62     esac
63
64     case $1 in
65         --prefix=*)
66             # For compatibility reasons with old M4 macros, we ignore
67             # setting of prefix.
68             ;;
69         --prefix)
70             output="$output $prefix"
71             ;;
72         --exec-prefix=*)
73             ;;
74         --exec-prefix)
75             output="$output $exec_prefix"
76             ;;
77         --version)
78             echo "@VERSION@"
79             exit 0
80             ;;
81         --api-version)
82             echo "@GPGME_CONFIG_API_VERSION@"
83             exit 0
84             ;;
85         --cflags)
86             if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then
87                 output="$output -I$includedir"
88             fi
89             case "$thread_module" in
90                 pthread)
91                     output="$output $cflags_pthread"
92                     ;;
93                 pth)
94                     output="$output $cflags_pth"
95                     ;;
96             esac
97             output="$output $gpg_error_cflags"
98             ;;
99         --libs)
100             if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/lib"; then
101                 output="$output -L$libdir"
102             fi
103             case "$thread_module" in
104                 pthread)
105                     output="$output -lgpgme-pthread $libs_pthread"
106                     ;;
107                 pth)
108                     output="$output -lgpgme-pth $libs_pth"
109                     ;;
110                 *)
111                     output="$output -lgpgme"
112             esac
113             output="$output $gpg_error_libs"
114             ;;
115         --thread=*)
116             for thread_mod in $thread_modules; do
117             if test "$thread_mod" = "$optarg"; then
118                 thread_module="$optarg";
119             fi
120             done
121             if test "x$thread_module" = "x"; then
122                 usage 1 1>&2
123             fi
124             ;;
125         *)
126             usage 1 1>&2
127             ;;
128     esac
129     shift
130 done
131
132 echo $output