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
12prefix="@prefix@"
13exec_prefix="@exec_prefix@"
14version="@PACKAGE_VERSION@"
15api_version="@GPGME_CONFIG_API_VERSION@"
16my_host="@GPGME_CONFIG_HOST@"
17
18# Make sure that no weird locale setting messes up our sed regexps etc.
19LC_COLLATE=C
20LC_ALL=C
21LANG=C
22
23# GPGME's own cflags and libs
24cflags="-I@includedir@"
25libs="-L@libdir@"
26
27# Network libraries.
28assuan_cflags="@LIBASSUAN_CFLAGS@"
29assuan_libs="@LIBASSUAN_LIBS@"
30
31# Configure libgpg-error.
32gpg_error_cflags="@GPG_ERROR_CFLAGS@"
33gpg_error_libs="@GPG_ERROR_LIBS@"
34
35# Configure thread packages.
36thread_modules=""
37
38# For compatibility we keep proving the
39# thread modules variable.
40thread_modules="$thread_modules pthread"
41libs_pthread="-lpthread"
42cflags_pthread=""
43
44avail_lang='c @GPGME_CONFIG_AVAIL_LANG@'
45
46# Configure glib.
47libs_glib="@GLIB_LIBS@"
48cflags_glib="@GLIB_CFLAGS@"
49with_glib=
50
51output=""
52
53usage()
54{
55    cat <<EOF
56Usage: gpgme-config [OPTIONS]
57Options:
58	--prefix
59	--exec-prefix
60	--version
61        --api-version
62        --host
63	--libs
64	--cflags
65        --print-lang           Print available language bindings
66        --have-lang=LANG       Return success if LANG is available
67EOF
68    exit $1
69}
70
71if test $# -eq 0; then
72    usage 1 1>&2
73fi
74
75while test $# -gt 0; do
76    case "$1" in
77	-*=*)
78	    optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
79	    ;;
80	*)
81	    optarg=
82	    ;;
83    esac
84
85    case $1 in
86        --prefix=*)
87            # For compatibility reasons with old M4 macros, we ignore
88            # setting of prefix.
89            ;;
90        --prefix)
91	    output="$output $prefix"
92	    ;;
93        --exec-prefix=*)
94            ;;
95        --exec-prefix)
96	    output="$output $exec_prefix"
97	    ;;
98	--glib)
99	    with_glib=yes
100	    ;;
101        --version)
102            echo "$version"
103	    exit 0
104	    ;;
105        --api-version)
106	    echo "$api_version"
107	    exit 0
108	    ;;
109        --host)
110	    echo "$my_host"
111	    exit 0
112	    ;;
113        --cflags)
114            result=
115            tmp_c=
116            tmp_g=
117	    case "$thread_module" in
118	        pthread) tmp_c="$cflags_pthread" ;;
119	    esac
120	    test "x$with_glib" = "xyes" && tmp_g="$cflags_glib"
121            for i in $cflags $tmp_c $assuan_cflags $gpg_error_cflags $tmp_g ; do
122              skip=no
123              case $i in
124                  -I/usr/include|-I/include)
125                      skip=yes
126                      ;;
127                  -I*)
128                      for j in $result ; do
129                          if test x"$j" = x"$i" ; then
130                              skip=yes
131                              break;
132                          fi
133                      done
134                      ;;
135              esac
136              if test $skip = no ; then
137                  result="$result $i"
138              fi
139            done
140            output="$output $result"
141            ;;
142	--libs)
143            result=
144            tmp_x=
145	    case "$thread_module" in
146            # deprecated
147	        pthread) tmp_l="-lgpgme" ;;
148		*)
149		    if test "x$with_glib" = "xyes" ; then
150		         tmp_l="-lgpgme-glib"
151                         tmp_x="$libs_glib"
152		    else
153			 tmp_l="-lgpgme"
154		    fi
155		    ;;
156	    esac
157            for i in $libs $tmp_l $assuan_libs $gpg_error_libs $tmp_x; do
158              skip=no
159              case $i in
160                  -L/usr/lib|-L/lib)
161                      skip=yes
162                      ;;
163                  -L*|-l*)
164                      for j in $result ; do
165                          if test x"$j" = x"$i" ; then
166                              skip=yes
167                              break;
168                          fi
169                      done
170                      ;;
171              esac
172              if test $skip = no ; then
173                  result="$result $i"
174              fi
175            done
176            output="$output $result"
177	    ;;
178	--thread=*)
179            for thread_mod in $thread_modules; do
180	    if test "$thread_mod" = "$optarg"; then
181		thread_module="$optarg";
182	    fi
183	    done
184	    if test "x$thread_module" = "x"; then
185		usage 1 1>&2
186	    fi
187	    ;;
188	--print-lang)
189            output="$avail_lang"
190	    ;;
191	--have-lang=*)
192            for lang in $avail_lang; do
193                if test x"$lang" = x"$optarg"; then
194                    exit 0
195                fi
196            done
197            exit 1
198	    ;;
199        --get-gpg)
200            # Deprecated
201            output="$output @GPG@"
202            ;;
203        --get-gpgsm)
204            # Deprecated
205            output="$output @GPGSM@"
206            ;;
207	*)
208            usage 1 1>&2
209	    ;;
210    esac
211    shift
212done
213
214echo $output
215