* configure.ac (LIBGCRYPT_CONFIG_SONAME_NUMBER): New.
[libgcrypt.git] / src / libgcrypt-config.in
1 #!/bin/sh
2 # Copyright (C) 1999, 2002, 2003, 2004 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 # General.
13 prefix="@prefix@"
14 exec_prefix="@exec_prefix@"
15 thread_module=""
16 version="@VERSION@"
17 gpg_error_libs="@GPG_ERROR_LIBS@"
18 gpg_error_cflags="@GPG_ERROR_CFLAGS@"
19
20 # LIBS values.
21 libs="@LIBGCRYPT_CONFIG_LIBS@"
22 libs_pthread="@LIBGCRYPT_CONFIG_LIBS_PTHREAD@"
23 libs_pth="@LIBGCRYPT_CONFIG_LIBS_PTH@"
24
25 # CFLAGS values.
26 cflags="@LIBGCRYPT_CONFIG_CFLAGS@"
27 cflags_pthread="@LIBGCRYPT_CONFIG_CFLAGS_PTHREAD@"
28 cflags_pth="@LIBGCRYPT_CONFIG_CFLAGS_PTH@"
29
30 # SONAME info
31 soname_number="@LIBGCRYPT_CONFIG_SONAME_NUMBER@"
32
33 # Misc information.
34 symmetric_ciphers="@LIBGCRYPT_CIPHERS@"
35 asymmetric_ciphers="@LIBGCRYPT_PUBKEY_CIPHERS@"
36 digests="@LIBGCRYPT_DIGESTS@"
37 thread_modules="@LIBGCRYPT_THREAD_MODULES@"
38
39 # State variables.
40 echo_libs=no
41 echo_cflags=no
42 echo_prefix=no
43 echo_algorithms=no
44 echo_exec_prefix=no
45 echo_version=no
46 echo_soname_number=no
47
48 # Prints usage information.
49 usage()
50 {
51     cat <<EOF
52 Usage: $0 [OPTIONS]
53 Options:
54         [--thread={${thread_modules}}]
55         [--prefix]
56         [--exec-prefix]
57         [--version]
58         [--soname-number]
59         [--libs]
60         [--cflags]
61         [--algorithms]
62 EOF
63     exit $1
64 }
65
66 if test $# -eq 0; then
67     # Nothing to do.
68     usage 1 1>&2
69 fi
70
71 while test $# -gt 0; do
72     case "$1" in
73         # Set up `optarg'.
74         --*=*)
75             optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
76             ;;
77         *)
78             optarg=""
79             ;;
80     esac
81
82     case $1 in
83         --thread=*)
84             for thread_mod in $thread_modules; do
85                 if test "$thread_mod" = "$optarg"; then
86                     thread_module="$optarg";
87                 fi
88             done
89             if test "x$thread_module" = "x"; then
90                 usage 1 1>&2
91             fi
92             ;;
93         --prefix=*)
94             # For compatibility reasons with old M4 macros, we ignore
95             # setting of prefix.
96             ;;
97         --prefix)
98             echo_prefix=yes
99             ;;
100         --exec-prefix=*)
101             ;;
102         --exec-prefix)
103             echo_exec_prefix=yes
104             ;;
105         --version)
106             echo_version=yes
107             ;;
108         --soname-number)
109             echo_soname_number=yes
110             ;;
111         --cflags)
112             echo_cflags=yes
113             ;;
114         --libs)
115             echo_libs=yes
116             ;;
117         --algorithms)
118             echo_algorithms=yes
119             ;;
120         *)
121             usage 1 1>&2
122             ;;
123     esac
124     shift
125 done
126
127 if test "$echo_prefix" = "yes"; then
128     echo "$prefix"
129 fi
130
131 if test "$echo_exec_prefix" = "yes"; then
132     echo "$exec_prefix"
133 fi
134
135 if test "$echo_cflags" = "yes"; then
136     includes=""
137     cflags_final="$cflags"
138
139     # Set up `includes'.
140     if test "@includedir@" != "/usr/include" ; then
141         includes="-I@includedir@"
142         for i in $cflags ; do
143             if test "$i" = "-I@includedir@" ; then
144                 includes=""
145             fi
146         done
147     fi
148
149     # Set up `cflags_final'.
150     case "$thread_module" in
151         pthread)
152             cflags_final=$cflags_pthread
153             ;;
154         pth)
155             cflags_final=$cflags_pth
156             ;;
157     esac
158     cflags_final="$cflags_final @GPG_ERROR_CFLAGS@"
159
160     echo "$includes $cflags_final"
161 fi
162
163 if test "$echo_libs" = "yes"; then
164     libdirs=""
165     libs_final="$libs"
166
167     # Set up `libdirs'.
168     if test "@libdir@" != "/usr/lib" ; then
169         libdirs="-L@libdir@"
170         for i in $libs ; do
171             if test "$i" = "-L@libdir@" ; then
172                 libdirs=""
173             fi
174         done
175     fi
176
177     # Set up `libs_final'.
178     case "$thread_module" in
179         pthread)
180             libs_final=$libs_pthread
181             ;;
182         pth)
183             libs_final=$libs_pth
184             ;;
185     esac
186     libs_final="$libs_final @GPG_ERROR_LIBS@"
187
188     echo "$libdirs $libs_final"
189 fi
190
191 if test "$echo_version" = "yes"; then
192     echo "$version"
193 fi
194
195 if test "$echo_soname_number" = "yes"; then
196     echo "$soname_number"
197 fi
198
199 if test "$echo_algorithms" = "yes"; then
200     echo "Symmetric cipher algorithms: $symmetric_ciphers"
201     echo "Public-key cipher algorithms: $asymmetric_ciphers"
202     echo "Message digest algorithms: $digests"
203 fi