Updated the CVS build stuff
[gpgme.git] / configure.ac
1 # configure.in for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003 g10 Code GmbH
4
5 # This file is part of GPGME.
6
7 # GPGME is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # GPGME is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20  
21 # (Process this file with autoconf to produce a configure script.)
22
23 AC_PREREQ(2.57)
24 min_automake_version="1.7.6"
25
26 # Version number: Remember to change it immediately *after* a release.
27 AC_INIT(gpgme, 0.4.4, [bug-gpgme@gnupg.org])
28 # LT Version numbers, remember to change them just *before* a release.
29 #   (Code changed:                      REVISION++)
30 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
31 #   (Interfaces added:                  AGE++)
32 #   (Interfaces removed:                AGE=0)
33 #
34 LIBGPGME_LT_CURRENT=12
35 LIBGPGME_LT_AGE=1
36 LIBGPGME_LT_REVISION=1
37 NEED_GPG_VERSION=1.2.2
38 NEED_GPGSM_VERSION=1.9.3
39 ##############################################
40 AC_PREREQ(2.52)
41 AC_REVISION($Revision$)
42
43 PACKAGE=$PACKAGE_NAME
44 VERSION=$PACKAGE_VERSION
45
46 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
47 AM_CONFIG_HEADER(config.h)
48 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
49 AM_MAINTAINER_MODE
50 AC_CANONICAL_HOST
51
52 AH_VERBATIM([_GNU_SOURCE],
53 [/* Enable GNU extensions on systems that have them.  */
54 #ifndef _GNU_SOURCE
55 # define _GNU_SOURCE
56 #endif])
57
58 AH_VERBATIM([_REENTRANT],
59 [/* To allow the use of GPGME in multithreaded programs we have to use
60   special features from the library.
61   IMPORTANT: gpgme is not yet fully reentrant and you should use it
62   only from one thread.  */
63 #ifndef _REENTRANT
64 # define _REENTRANT 1
65 #endif])
66
67
68 AC_PROG_CC
69
70
71 AC_SUBST(LIBGPGME_LT_CURRENT)
72 AC_SUBST(LIBGPGME_LT_AGE)
73 AC_SUBST(LIBGPGME_LT_REVISION)
74 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
75                                      [Min. needed GnuPG version.])
76 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
77                                        [Min. needed GPGSM version.])
78
79 AC_SUBST(PACKAGE)
80 AC_SUBST(VERSION)
81 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
82 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
83
84 # Don't default to build static libs.
85 AC_DISABLE_STATIC
86 AC_PROG_LIBTOOL
87
88 # For now we hardcode the use of version scripts.  It would be better
89 # to write a test for this or even implement this within libtool.
90 have_ld_version_script=no
91 case "${host}" in
92     *-*-linux*)
93         have_ld_version_script=yes
94         ;;
95     *-*-gnu*)
96         have_ld_version_script=yes
97         ;;
98 esac
99 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
100
101 GPG_DEFAULT=no
102 GPGSM_DEFAULT=no
103 component_system=None
104 case "${host}" in
105     *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* )
106         # special stuff for Windoze NT
107         # OS/2 with the EMX environment
108         # DOS with the DJGPP environment
109         AC_DEFINE(HAVE_DRIVE_LETTERS, ,
110                   [Defined if we run on some of the PCDOS like systems (DOS,
111                    Windoze, OS/2) with special properties like no file modes.])
112         AC_DEFINE(HAVE_DOSISH_SYSTEM, ,
113                   [Defined if the filesystem uses driver letters.])
114         have_dosish_system=yes
115         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
116         # XXX Assuan is not supported in this configuration.
117         #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
118         #component_system='COM+'
119         ;;
120     *)
121         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
122         if test "$have_pth" = yes; then
123           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
124           CFLAGS="$CFLAGS $PTH_CFLAGS"
125         fi
126         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
127         if test "$have_pthread" = yes; then
128           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
129         fi
130
131         # XXX: Probably use exec-prefix here?
132 #       GPG_DEFAULT='/usr/bin/gpg'
133 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
134         ;;
135 esac
136 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes")
137 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
138 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
139
140
141 # Checks for header files.
142 AC_CHECK_HEADERS(sys/select.h)
143
144
145 # Type checks.
146 AC_CHECK_SIZEOF(unsigned int)
147
148
149 # Checks for compiler features.
150 if test "$GCC" = yes; then
151     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
152 fi
153
154
155 # Checks for library functions.
156 AC_REPLACE_FUNCS(stpcpy)
157
158 AC_REPLACE_FUNCS(vasprintf)
159 if test "$ac_cv_func_vasprintf" != yes; then
160   GNUPG_CHECK_VA_COPY
161 fi
162
163 # Try to find a thread-safe version of getenv().
164 have_thread_safe_getenv=no
165 jm_GLIBC21
166 if test $GLIBC21 = yes; then
167   have_thread_safe_getenv=yes
168 fi
169 if test $have_thread_safe_getenv = yes; then
170   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
171 fi
172 have_getenv_r=no
173 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
174 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
175   AC_MSG_WARN([
176 ***
177 *** getenv() is not thread-safe and getenv_r() does not exist
178 ***])
179 fi
180
181 # For converting time strings to seconds since Epoch, we need the timegm
182 # function.
183 AC_CHECK_FUNCS(timegm)
184 if test "$ac_cv_func_timegm" != yes; then
185   AC_MSG_WARN([
186 ***
187 *** timegm() not available - a non-thread-safe kludge will be used
188 *** and the TZ variable might be changed at runtime.
189 ***])
190 fi
191
192 # Checking for libgpg-error.
193 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
194 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
195           [The default error source for GPGME.])
196
197
198
199 # Checks for system services
200 NO_OVERRIDE=no
201 AC_ARG_WITH(gpg,
202             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
203             GPG=$withval, NO_OVERRIDE=yes)
204 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
205   GPG=
206   NO_OVERRIDE=yes
207   if test "$cross_compiling" != "yes"; then
208     AC_PATH_PROG(GPG, gpg)
209   fi
210   if test -z "$GPG"; then
211     GPG="$GPG_DEFAULT"
212   fi
213 fi
214 if test "$GPG" = no; then
215   if test "$NO_OVERRIDE" = "yes"; then
216     if test "$cross_compiling" != "yes"; then
217       AC_MSG_WARN([
218 ***
219 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
220 ***])
221     else
222       AC_MSG_ERROR([
223 ***
224 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
225 ***])
226     fi
227   fi
228 else
229   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
230   AC_SUBST(GPG)
231 fi
232 AM_CONDITIONAL(RUN_GPG_TESTS,
233   [test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"])
234 AC_SUBST(GPG_PATH)
235
236 NO_OVERRIDE=no
237 AC_ARG_WITH(gpgsm,
238             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
239             GPGSM=$withval, NO_OVERRIDE=yes)
240 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
241   GPGSM=
242   NO_OVERRIDE=yes
243   if test "$cross_compiling" != "yes"; then
244     AC_PATH_PROG(GPGSM, gpgsm)
245   fi
246   if test -z "$GPGSM"; then
247     GPGSM="$GPGSM_DEFAULT"
248   fi
249 fi
250 if test "$GPGSM" = no; then
251   if test "$NO_OVERRIDE" = "yes"; then
252     if test "$cross_compiling" != "yes"; then
253       AC_MSG_WARN([
254 ***
255 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
256 ***])
257     else
258       AC_MSG_ERROR([
259 ***
260 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
261 ***])
262     fi
263   fi
264 else
265   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
266   AC_SUBST(GPGSM)
267 fi
268 AM_CONDITIONAL(HAVE_GPGSM, [test -n "$GPGSM" && test -r "$GPGSM"])
269 AM_CONDITIONAL(RUN_GPGSM_TESTS,
270   [test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"])
271
272 # FIXME: Only build if supported.
273 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
274
275 if test "$GPGSM" != "no"; then
276   AC_CHECK_FUNCS(funopen)
277   if test $ac_cv_func_funopen != yes; then
278     # No funopen but we can implement that in terms of fopencookie.
279     AC_CHECK_FUNCS(fopencookie, AC_LIBOBJ(funopen),
280                    AC_MSG_ERROR([[
281 No implementation of fopencookie or funopen available.
282 ]]))
283   fi
284
285   AC_REPLACE_FUNCS(isascii)
286   AC_REPLACE_FUNCS(putc_unlocked)
287   AC_REPLACE_FUNCS(memrchr)
288 fi
289
290
291 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
292
293 # Make the version number in gpgme/gpgme.h the same as the one here.
294 # (this is easier than to have a *.in file just for one substitution)
295 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
296
297 # Substitution used for gpgme-config 
298 GPGME_CONFIG_LIBS="-lgpgme"
299 GPGME_CONFIG_CFLAGS=""
300 AC_SUBST(GPGME_CONFIG_LIBS)
301 AC_SUBST(GPGME_CONFIG_CFLAGS)
302
303 # Frob'da Variables
304 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
305            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
306 AC_SUBST(LTLIBOBJS)
307
308 #
309 # Create config files 
310
311 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
312                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
313                 doc/Makefile complus/Makefile)
314 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
315 AC_OUTPUT
316
317 echo "
318         GPGME v${VERSION} has been configured as follows:
319
320         GnuPG version: min. $NEED_GPG_VERSION
321         GnuPG path:    $GPG
322
323         GpgSM version: min. $NEED_GPGSM_VERSION
324         GpgSM path:    $GPGSM
325 "