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