2003-08-27 Moritz Schulte <mo@g10code.com>
[libgcrypt.git] / src / libgcrypt-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 # 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 # Misc information.
31 symmetric_ciphers="@LIBGCRYPT_CIPHERS@"
32 asymmetric_ciphers="@LIBGCRYPT_PUBKEY_CIPHERS@"
33 digests="@LIBGCRYPT_DIGESTS@"
34 thread_modules="@LIBGCRYPT_THREAD_MODULES@"
35
36 # State variables.
37 exec_prefix_set=no
38 echo_libs=no
39 echo_cflags=no
40 echo_prefix=no
41 echo_algorithms=no
42 echo_exec_prefix=no
43 echo_version=no
44
45 # Prints usage information.
46 usage()
47 {
48     cat <<EOF
49 Usage: $0 [OPTIONS]
50 Options:
51         [--thread={${thread_modules}}]
52         [--prefix[=DIR]]
53         [--exec-prefix[=DIR]]
54         [--version]
55         [--libs]
56         [--cflags]
57         [--algorithms]
58 EOF
59     exit $1
60 }
61
62 if test $# -eq 0; then
63     # Nothing to do.
64     usage 1 1>&2
65 fi
66
67 while test $# -gt 0; do
68     case "$1" in
69         # Set up `optarg'.
70         --*=*)
71             optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
72             ;;
73         *)
74             optarg=""
75             ;;
76     esac
77
78     case $1 in
79         --thread=*)
80             for thread_mod in $thread_modules; do
81                 if test "$thread_mod" = "$optarg"; then
82                     thread_module="$optarg";
83                 fi
84             done
85             if test "x$thread_module" = "x"; then
86                 usage 1 1>&2
87             fi
88             ;;
89         --prefix=*)
90             prefix=$optarg
91             if test $exec_prefix_set = no ; then
92                 exec_prefix=$optarg
93             fi
94             ;;
95         --prefix)
96             echo_prefix=yes
97             ;;
98         --exec-prefix=*)
99             exec_prefix=$optarg
100             exec_prefix_set=yes
101             ;;
102         --exec-prefix)
103             echo_exec_prefix=yes
104             ;;
105         --version)
106             echo_version=yes
107             ;;
108         --cflags)
109             echo_cflags=yes
110             ;;
111         --libs)
112             echo_libs=yes
113             ;;
114         --algorithms)
115             echo_algorithms=yes
116             ;;
117         *)
118             usage 1 1>&2
119             ;;
120     esac
121     shift
122 done
123
124 if test "$echo_prefix" = "yes"; then
125     echo $prefix
126 fi
127
128 if test "$echo_exec_prefix" = "yes"; then
129     echo $exec_prefix
130 fi
131
132 if test "$echo_cflags" = "yes"; then
133     includes=""
134     cflags_final="$cflags"
135
136     # Set up `includes'.
137     if test "@includedir@" != "/usr/include" ; then
138         includes="-I@includedir@"
139         for i in $cflags ; do
140             if test "$i" = "-I@includedir@" ; then
141                 includes=""
142             fi
143         done
144     fi
145
146     # Set up `cflags_final'.
147     case "$thread_module" in
148         pthread)
149             cflags_final=$cflags_pthread
150             ;;
151         pth)
152             cflags_final=$cflags_pth
153             ;;
154     esac
155
156     echo "$includes" "$cflags_final"
157 fi
158
159 if test "$echo_libs" = "yes"; then
160     libdirs=""
161     libs_final="$libs"
162
163     # Set up `libdirs'.
164     if test "@libdir@" != "/usr/lib" ; then
165         libdirs="-L@libdir@"
166         for i in $libs ; do
167             if test "$i" = "-L@libdir@" ; then
168                 libdirs=""
169             fi
170         done
171     fi
172
173     # Set up `libs_final'.
174     case "$thread_module" in
175         pthread)
176             libs_final=$libs_pthread
177             ;;
178         pth)
179             libs_final=$libs_pth
180             ;;
181     esac
182
183     echo $libdirs $libs_final
184 fi
185
186 if test "$echo_version" = "yes"; then
187     echo $version
188 fi
189
190 if test "$echo_algorithms" = "yes"; then
191     echo "Symmetric cipher algorithms: $ciphers"
192     echo "Public-key cipher algorithms: $pubkey_ciphers"
193     echo "Message digest algorithms: $digests"
194 fi