Prepare for release.
[gpgme.git] / configure.ac
1 # configure.ac for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH
4
5 # This file is part of GPGME.
6
7 # GPGME is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as
9 # published by the Free Software Foundation; either version 2.1 of the
10 # License, or (at your option) any later version.
11
12 # GPGME is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
15 # Public License for more details.
16
17 # You should have received a copy of the GNU Lesser General Public
18 # License 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 AC_PREREQ(2.59)
23 min_automake_version="1.9.3"
24
25 # Version number: Remember to change it immediately *after* a release.
26 #                 Make sure to run  "svn up" and "./autogen.sh --force"
27 #                  before a "make dist".  See below for the LT versions.
28 #
29 # The SVN version is usually the next intended release version with
30 # the string "-svnNNN" appended.  The reason for this is that tests for a
31 # specific feature can already be done under the assumption that the
32 # SVN version is the most recent one in a branch.  To disable the SVN
33 # version for the real release, set the my_issvn macro to no.
34 m4_define(my_version, [1.1.6])
35 m4_define(my_issvn, [no])
36
37 m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
38             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
39 AC_INIT([gpgme], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]),
40         [bug-gpgme@gnupg.org])
41
42
43 # LT Version numbers, remember to change them just *before* a release.
44 #   (Code changed:                      REVISION++)
45 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
46 #   (Interfaces added:                  AGE++)
47 #   (Interfaces removed/changed:        AGE=0)
48 #
49 LIBGPGME_LT_CURRENT=17
50 # Subtract 2 from this value if you want to make the LFS transition an
51 # ABI break.  [Note to self: Remove this comment with the next regular break.]
52 LIBGPGME_LT_AGE=6
53 LIBGPGME_LT_REVISION=4
54
55 # If the API is changed in an incompatible way: increment the next counter.
56 GPGME_CONFIG_API_VERSION=1
57 ##############################################
58
59
60 BUILD_REVISION=svn_revision
61 PACKAGE=$PACKAGE_NAME
62 VERSION=$PACKAGE_VERSION
63
64 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
65 dnl FIXME: Enable this with autoconf 2.59.
66 dnl AC_CONFIG_MACRO_DIR(m4)
67 AM_CONFIG_HEADER(config.h)
68 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
69 AM_MAINTAINER_MODE
70 AC_CANONICAL_HOST
71
72 # Enable GNU extensions on systems that have them.
73 AC_GNU_SOURCE
74
75 AH_VERBATIM([_REENTRANT],
76 [/* To allow the use of GPGME in multithreaded programs we have to use
77   special features from the library.
78   IMPORTANT: gpgme is not yet fully reentrant and you should use it
79   only from one thread.  */
80 #ifndef _REENTRANT
81 # define _REENTRANT 1
82 #endif])
83
84 AC_PROG_CC
85 AC_PROG_CXX
86
87 AC_SUBST(LIBGPGME_LT_CURRENT)
88 AC_SUBST(LIBGPGME_LT_AGE)
89 AC_SUBST(LIBGPGME_LT_REVISION)
90
91 AC_SUBST(PACKAGE)
92 AC_SUBST(VERSION)
93 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
94 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
95
96 # Don't default to build static libs.
97 AC_DISABLE_STATIC
98 AC_LIBTOOL_WIN32_DLL
99 AC_LIBTOOL_RC
100 AC_PROG_LIBTOOL
101
102 # For now we hardcode the use of version scripts.  It would be better
103 # to write a test for this or even implement this within libtool.
104 have_ld_version_script=no
105 case "${host}" in
106     *-*-linux*)
107         have_ld_version_script=yes
108         ;;
109     *-*-gnu*)
110         have_ld_version_script=yes
111         ;;
112 esac
113 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
114
115 GPG_DEFAULT=no
116 GPGSM_DEFAULT=no
117 GPGCONF_DEFAULT=no
118 component_system=None
119 have_dosish_system=no
120 have_w32_system=no
121 build_w32_glib=no
122 build_w32_qt=no
123 case "${host}" in
124     *-mingw32*)
125         # special stuff for Windoze NT
126         have_dosish_system=yes
127         have_w32_system=yes
128         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
129         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
130         GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
131         #component_system='COM+'
132
133         AM_PATH_GLIB_2_0
134         AC_ARG_ENABLE(w32-glib,
135             AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
136                            build_w32_glib=$enableval)
137
138         # Check disabled, because the qt-dev packages in gpg4win do
139         # not provide any support for cross compilation.
140         # PKG_CHECK_MODULES(QT4_CORE, QtCore)
141
142         # Use it like this:
143         # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
144         AC_SUBST(QT4_CORE_CFLAGS)
145         AC_SUBST(QT4_CORE_LIBS)
146         AC_ARG_ENABLE(w32-qt,
147             AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
148                            build_w32_qt=$enableval)
149         ;;
150     *)
151         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
152         if test "$have_pth" = yes; then
153           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
154         fi
155         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
156         if test "$have_pthread" = yes; then
157           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
158         fi
159
160         # XXX: Probably use exec-prefix here?
161 #       GPG_DEFAULT='/usr/bin/gpg'
162 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
163 #       GPGCONF_DEFAULT='/usr/bin/gpgconf'
164         ;;
165 esac
166
167 if test "$have_dosish_system" = yes; then
168    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
169              [Defined if we run on some of the PCDOS like systems 
170               (DOS, Windoze. OS/2) with special properties like
171               no file modes])
172 fi
173 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
174
175 if test "$have_w32_system" = yes; then
176    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
177 fi
178 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
179 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
180 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
181
182 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
183 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
184
185
186 # Checks for header files.
187 AC_CHECK_HEADERS(sys/select.h)
188
189
190 # Type checks.
191 AC_C_INLINE
192 AC_CHECK_SIZEOF(unsigned int)
193 AC_SYS_LARGEFILE
194 AC_TYPE_OFF_T
195
196 # Checks for compiler features.
197 if test "$GCC" = yes; then
198     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
199     if test "$have_w32_system" = yes; then
200        CFLAGS="$CFLAGS -mms-bitfields"
201     fi
202 fi
203
204 # Network library fun.
205 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
206         [NETLIBS="-lnsl $NETLIBS"]))
207 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
208         [NETLIBS="-lsocket $NETLIBS"]))
209 AC_SUBST(NETLIBS)
210
211 # Checks for library functions.
212 AC_FUNC_FSEEKO
213
214 AC_REPLACE_FUNCS(vasprintf)
215 if test "$ac_cv_func_vasprintf" != yes; then
216   GNUPG_CHECK_VA_COPY
217 fi
218
219 # Try to find a thread-safe version of ttyname().
220 AC_REPLACE_FUNCS(ttyname_r)
221 if test "$ac_cv_func_ttyname_r" != yes; then
222   AC_MSG_WARN([
223 ***
224 *** ttyname() is not thread-safe and ttyname_r() does not exist
225 ***])
226 fi
227
228 # Try to find a thread-safe version of getenv().
229 have_thread_safe_getenv=no
230 jm_GLIBC21
231 if test $GLIBC21 = yes; then
232   have_thread_safe_getenv=yes
233 fi
234 if test $have_thread_safe_getenv = yes; then
235   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
236 fi
237 have_getenv_r=no
238 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
239 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
240   AC_MSG_WARN([
241 ***
242 *** getenv() is not thread-safe and getenv_r() does not exist
243 ***])
244 fi
245
246 # For converting time strings to seconds since Epoch, we need the timegm
247 # function.
248 AC_CHECK_FUNCS(timegm)
249 if test "$ac_cv_func_timegm" != yes; then
250   AC_MSG_WARN([
251 ***
252 *** timegm() not available - a non-thread-safe kludge will be used
253 *** and the TZ variable might be changed at runtime.
254 ***])
255 fi
256
257 # Checking for libgpg-error.
258 AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
259 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
260           [The default error source for GPGME.])
261
262
263
264 # Checks for system services
265 NEED_GPG_VERSION_DEFAULT=1.3.0
266 NEED_GPGSM_VERSION_DEFAULT=1.9.6
267 NEED_GPGCONF_VERSION_DEFAULT=2.0.4
268 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
269 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
270 NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
271 AC_ARG_WITH(gpg-version,
272             AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
273             NEED_GPG_VERSION=$withval)
274 if test "$NEED_GPG_VERSION" = "yes"; then
275   NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
276 fi
277 if test "$NEED_GPG_VERSION" = "no"; then
278   NEED_GPG_VERSION=0.0.0
279 fi
280 AC_ARG_WITH(gpgsm-version,
281             AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
282             NEED_GPGSM_VERSION=$withval)
283 if test "$NEED_GPGSM_VERSION" = "yes"; then
284   NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
285 fi
286 if test "$NEED_GPGSM_VERSION" = "no"; then
287   NEED_GPGSM_VERSION=0.0.0
288 fi
289 AC_ARG_WITH(gpgconf-version,
290             AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]),
291             NEED_GPGCONF_VERSION=$withval)
292 if test "$NEED_GPGCONF_VERSION" = "yes"; then
293   NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
294 fi
295 if test "$NEED_GPGCONF_VERSION" = "no"; then
296   NEED_GPGCONF_VERSION=0.0.0
297 fi
298
299 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
300                                      [Min. needed GnuPG version.])
301 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
302                                        [Min. needed GPGSM version.])
303 AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION",
304                                          [Min. needed GPGCONF version.])
305
306
307 NO_OVERRIDE=no
308 AC_ARG_WITH(gpg,
309             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
310             GPG=$withval, NO_OVERRIDE=yes)
311 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
312   GPG=
313   NO_OVERRIDE=yes
314   if test "$cross_compiling" != "yes"; then
315     AC_PATH_PROG(GPG, gpg)
316   fi
317   if test -z "$GPG"; then
318     GPG="$GPG_DEFAULT"
319   fi
320 fi
321 if test "$GPG" = no; then
322   if test "$NO_OVERRIDE" = "yes"; then
323     if test "$cross_compiling" != "yes"; then
324       AC_MSG_WARN([
325 ***
326 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
327 ***])
328     else
329       AC_MSG_ERROR([
330 ***
331 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
332 ***])
333     fi
334   fi
335 else
336   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
337   AC_SUBST(GPG)
338 fi
339 dnl Check for GnuPG version requirement.
340 GPG_VERSION=unknown
341 ok=maybe
342 if test -z "$GPG" -o "x$GPG" = "xno"; then
343   ok=no
344 else
345   if test "$cross_compiling" = "yes"; then
346     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
347     ok=no
348   else
349     if test ! -x "$GPG"; then
350       AC_MSG_WARN([GnuPG not executable, version check disabled])
351       ok=no
352     fi
353   fi
354 fi
355 if test "$ok" = "maybe"; then
356   AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
357   req_major=`echo $NEED_GPG_VERSION | \
358              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
359   req_minor=`echo $NEED_GPG_VERSION | \
360              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
361   req_micro=`echo $NEED_GPG_VERSION | \
362              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
363   GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
364   major=`echo $GPG_VERSION | \
365          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
366   minor=`echo $GPG_VERSION | \
367          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
368   micro=`echo $GPG_VERSION | \
369          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
370
371   if test "$major" -gt "$req_major"; then
372     ok=yes
373   else
374     if test "$major" -eq "$req_major"; then
375       if test "$minor" -gt "$req_minor"; then
376         ok=yes
377       else
378         if test "$minor" -eq "$req_minor"; then
379           if test "$micro" -ge "$req_micro"; then
380             ok=yes
381           fi
382         fi
383       fi
384     fi
385   fi
386   if test "$ok" = "yes"; then
387     AC_MSG_RESULT(yes)
388   else
389     AC_MSG_RESULT(no)
390     AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
391   fi
392 fi
393 run_gpg_test="$ok"
394 AC_ARG_ENABLE(gpg-test,
395   AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
396          run_gpg_test=$enableval)
397 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
398 AC_SUBST(GPG_PATH)
399
400 NO_OVERRIDE=no
401 AC_ARG_WITH(gpgsm,
402             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
403             GPGSM=$withval, NO_OVERRIDE=yes)
404 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
405   GPGSM=
406   NO_OVERRIDE=yes
407   if test "$cross_compiling" != "yes"; then
408     AC_PATH_PROG(GPGSM, gpgsm)
409   fi
410   if test -z "$GPGSM"; then
411     GPGSM="$GPGSM_DEFAULT"
412   fi
413 fi
414 if test "$GPGSM" = no; then
415   if test "$NO_OVERRIDE" = "yes"; then
416     if test "$cross_compiling" != "yes"; then
417       AC_MSG_WARN([
418 ***
419 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
420 ***])
421     else
422       AC_MSG_ERROR([
423 ***
424 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
425 ***])
426     fi
427   fi
428 else
429   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
430   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
431 fi
432 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
433
434
435 dnl Check for GPGSM version requirement.
436 GPGSM_VERSION=unknown
437 ok=maybe
438 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
439   ok=no
440 else
441   if test "$cross_compiling" = "yes"; then
442     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
443     ok=no
444   else
445     if test ! -x "$GPGSM"; then
446       AC_MSG_WARN([GPGSM not executable, version check disabled])
447       ok=no
448     fi
449   fi
450 fi
451 if test "$ok" = "maybe"; then
452   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
453   req_major=`echo $NEED_GPGSM_VERSION | \
454              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
455   req_minor=`echo $NEED_GPGSM_VERSION | \
456              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
457   req_micro=`echo $NEED_GPGSM_VERSION | \
458              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
459   GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
460   major=`echo $GPGSM_VERSION | \
461          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
462   minor=`echo $GPGSM_VERSION | \
463          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
464   micro=`echo $GPGSM_VERSION | \
465          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
466
467   if test "$major" -gt "$req_major"; then
468     ok=yes
469   else
470     if test "$major" -eq "$req_major"; then
471       if test "$minor" -gt "$req_minor"; then
472         ok=yes
473       else
474         if test "$minor" -eq "$req_minor"; then
475           if test "$micro" -ge "$req_micro"; then
476             ok=yes
477           fi
478         fi
479       fi
480     fi
481   fi
482   if test "$ok" = "yes"; then
483     AC_MSG_RESULT(yes)
484   else
485     AC_MSG_RESULT(no)
486     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
487   fi
488 fi
489 run_gpgsm_test="$ok"
490 AC_ARG_ENABLE(gpgsm-test,
491   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
492          run_gpgsm_test=$enableval)
493 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
494
495
496 NO_OVERRIDE=no
497 AC_ARG_WITH(gpgconf,
498             AC_HELP_STRING([--with-gpgconf=PATH],
499                            [use gpgconf binary at PATH]),
500             GPGCONF=$withval, NO_OVERRIDE=yes)
501 if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then
502   GPGCONF=
503   NO_OVERRIDE=yes
504   if test "$cross_compiling" != "yes"; then
505     AC_PATH_PROG(GPGCONF, gpgconf)
506   fi
507   if test -z "$GPGCONF"; then
508     GPGCONF="$GPGCONF_DEFAULT"
509   fi
510 fi
511 if test "$GPGCONF" = no; then
512   if test "$NO_OVERRIDE" = "yes"; then
513     if test "$cross_compiling" != "yes"; then
514       AC_MSG_WARN([
515 ***
516 *** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it
517 ***])
518     else
519       AC_MSG_ERROR([
520 ***
521 *** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH
522 ***])
523     fi
524   fi
525 else
526   AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.])
527   AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled])
528 fi
529 AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no")
530
531 dnl Check for GPGCONF version requirement.
532 GPGCONF_VERSION=unknown
533 ok=maybe
534 if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then
535   ok=no
536 else
537   if test "$cross_compiling" = "yes"; then
538     AC_MSG_WARN([GPGCONF version can not be checked when cross compiling])
539     ok=no
540   else
541     if test ! -x "$GPGCONF"; then
542       AC_MSG_WARN([GPGCONF not executable, version check disabled])
543       ok=no
544     fi
545   fi
546 fi
547 if test "$ok" = "maybe"; then
548   AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION)
549   req_major=`echo $NEED_GPGCONF_VERSION | \
550              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
551   req_minor=`echo $NEED_GPGCONF_VERSION | \
552              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
553   req_micro=`echo $NEED_GPGCONF_VERSION | \
554              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
555   GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
556   major=`echo $GPGCONF_VERSION | \
557          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
558   minor=`echo $GPGCONF_VERSION | \
559          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
560   micro=`echo $GPGCONF_VERSION | \
561          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
562
563   if test "$major" -gt "$req_major"; then
564     ok=yes
565   else
566     if test "$major" -eq "$req_major"; then
567       if test "$minor" -gt "$req_minor"; then
568         ok=yes
569       else
570         if test "$minor" -eq "$req_minor"; then
571           if test "$micro" -ge "$req_micro"; then
572             ok=yes
573           fi
574         fi
575       fi
576     fi
577   fi
578   if test "$ok" = "yes"; then
579     AC_MSG_RESULT(yes)
580   else
581     AC_MSG_RESULT(no)
582     AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION])
583   fi
584 fi
585 run_gpgconf_test="$ok"
586 AC_ARG_ENABLE(gpgconf-test,
587   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]),
588          run_gpgconf_test=$enableval)
589 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
590
591 # Only build if supported.
592 AM_CONDITIONAL(BUILD_GPGCONF, test "$GPGCONF" != "no")
593 if test "$GPGCONF" != "no"; then
594   AC_DEFINE(HAVE_GPGCONF, 1,
595             [Defined if we are building with gpgconf support.])
596 fi
597
598
599 # FIXME: Only build if supported.
600 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
601 if test "$GPGSM" != "no"; then
602   AC_DEFINE(HAVE_ASSUAN_H, 1,
603             [Defined if we are building with assuan support.])
604 fi
605
606 # Check for funopen
607 AC_CHECK_FUNCS(funopen)
608 if test $ac_cv_func_funopen != yes; then
609     # No funopen but we can implement that in terms of fopencookie.
610     AC_CHECK_FUNCS(fopencookie)
611     if test $ac_cv_func_fopencookie = yes; then
612         AC_REPLACE_FUNCS(funopen)
613     else
614         AC_MSG_WARN([
615 ***
616 *** No implementation of fopencookie or funopen available
617 ***])
618     fi
619 fi
620
621 # More assuan replacement functions.
622 AC_REPLACE_FUNCS(isascii)
623 AC_REPLACE_FUNCS(putc_unlocked)
624 AC_REPLACE_FUNCS(memrchr)
625 AC_REPLACE_FUNCS(stpcpy)
626 # Check for unistd.h for setenv replacement function.
627 AC_CHECK_HEADERS(unistd.h)
628 AC_REPLACE_FUNCS(setenv)
629
630 # More assuan checks.
631 AC_CHECK_HEADERS([sys/uio.h])
632
633 # Assuan check for descriptor passing.
634 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
635                 [supports_descriptor_passing=yes],
636                 [supports_descriptor_passing=no
637                  AC_MSG_WARN([
638 ***
639 *** Data structure for sending ancillary data missing.
640 *** Descriptor passing won't work.
641 ***])],[
642 #include <stdlib.h>
643 #include <stddef.h>
644 #include <stdio.h>
645 #include <sys/types.h>
646 #include <sys/socket.h>
647 #include <sys/un.h>
648 #if HAVE_SYS_UIO_H
649 #include <sys/uio.h>
650 #endif
651 #include <unistd.h>
652        ])
653
654 AC_ARG_ENABLE(fd-passing,
655   AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
656   use_descriptor_passing=$enableval)
657
658 if test "$supports_descriptor_passing" != "yes"; then
659   use_descriptor_passing=no
660 fi
661
662 if test "$use_descriptor_passing" = "yes"; then
663 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
664           [Defined if descriptor passing is enabled and supported])
665 fi
666
667 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
668
669 # Assuan check for the getsockopt SO_PEERCRED
670 AC_MSG_CHECKING(for SO_PEERCRED)
671 AC_CACHE_VAL(assuan_cv_sys_so_peercred,
672       [AC_TRY_COMPILE([#include <sys/socket.h>], 
673          [struct ucred cr; 
674           int cl = sizeof cr;
675           getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
676           assuan_cv_sys_so_peercred=yes,
677           assuan_cv_sys_so_peercred=no)
678        ])
679 AC_MSG_RESULT($assuan_cv_sys_so_peercred) 
680 if test $assuan_cv_sys_so_peercred = yes; then
681   AC_DEFINE(HAVE_SO_PEERCRED, 1,
682             [Defined if SO_PEERCRED is supported (Linux specific)])
683 fi
684
685 if test "$have_w32_system" = yes; then
686    NETLIBS="-lws2_32 $NETLIBS"
687 fi
688
689 # End of assuan checks.
690
691 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
692
693 # Make the version number in gpgme/gpgme.h the same as the one here.
694 # (this is easier than to have a *.in file just for one substitution)
695 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
696
697 # Generate values for the DLL version info
698 if test "$have_w32_system" = yes; then
699     BUILD_TIMESTAMP=`date --iso-8601=minutes`
700     changequote(,)dnl 
701     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
702     changequote([,])dnl
703     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
704 fi
705 AC_SUBST(BUILD_REVISION)
706 AC_SUBST(BUILD_TIMESTAMP)
707 AC_SUBST(BUILD_FILEVERSION)
708
709 # Add a few constants to help porting to W32
710 AH_VERBATIM([SEPCONSTANTS],
711 [
712 /* Separators as used in $PATH.  */
713 #ifdef HAVE_DOSISH_SYSTEM
714 #define PATHSEP_C ';'
715 #else
716 #define PATHSEP_C ':'
717 #endif
718 ])
719
720 AH_BOTTOM([
721 /* Definition of GCC specific attributes.  */
722 #if __GNUC__ > 2 
723 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
724 #else
725 # define GPGME_GCC_A_PURE
726 #endif
727 ])
728
729
730 # Substitution used for gpgme-config 
731 GPGME_CONFIG_LIBS="-lgpgme"
732 GPGME_CONFIG_CFLAGS=""
733 AC_SUBST(GPGME_CONFIG_API_VERSION)
734 AC_SUBST(GPGME_CONFIG_LIBS)
735 AC_SUBST(GPGME_CONFIG_CFLAGS)
736
737 # Frob'da Variables
738 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
739            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
740 AC_SUBST(LTLIBOBJS)
741
742 #
743 # Create config files 
744
745 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
746                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
747                 doc/Makefile complus/Makefile
748                 gpgme/versioninfo.rc)
749 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
750 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
751 AC_OUTPUT
752
753 echo "
754         GPGME v${VERSION} has been configured as follows:
755
756         GnuPG path:      $GPG
757         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
758
759         GpgSM path:      $GPGSM
760         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
761
762         GpgConf path:    $GPGCONF
763         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
764
765         GPGME Pthread:   $have_pthread
766         GPGME Pth:       $have_pth
767 "