4e428db038ba993772c87f38f90883c49a884c2b
[gpgme.git] / gpgme / gpgme-config.in
1 #!/bin/sh
2 #    Copyright (C) 1999, 2002 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         [--prefix]
40         [--exec-prefix]
41         [--version]
42         [--libs]
43         [--cflags]
44         [--thread={${thread_modules}}]
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             output="$output $prefix"
66             ;;
67         --exec-prefix)
68             output="$output $exec_prefix"
69             ;;
70         --version)
71             echo "@VERSION@"
72             exit 0
73             ;;
74         --cflags)
75             output="$output -I$includedir"
76             case "$thread_module" in
77                 pthread)
78                     output="$output $cflags_pthread"
79                     ;;
80                 pth)
81                     output="$output $cflags_pth"
82                     ;;
83             esac
84             output="$output $gpg_error_cflags"
85             ;;
86         --libs)
87             output="$output -L@libdir@"
88             case "$thread_module" in
89                 pthread)
90                     output="$output -lgpgme-pthread $libs_pthread"
91                     ;;
92                 pth)
93                     output="$output -lgpgme-pth $libs_pth"
94                     ;;
95                 *)
96                     output="$output -lgpgme"
97             esac
98             output="$output $gpg_error_libs"
99             ;;
100         --thread=*)
101             for thread_mod in $thread_modules; do
102             if test "$thread_mod" = "$optarg"; then
103                 thread_module="$optarg";
104             fi
105             done
106             if test "x$thread_module" = "x"; then
107                 usage 1 1>&2
108             fi
109             ;;
110         *)
111             usage 1 1>&2
112             ;;
113     esac
114     shift
115 done
116
117 echo $output