Better detection of a missing libassuan
[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, 2008,
4 #               2009, 2010  g10 Code GmbH
5
6 # This file is part of GPGME.
7
8 # GPGME is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as
10 # published by the Free Software Foundation; either version 2.1 of the
11 # License, or (at your option) any later version.
12
13 # GPGME is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16 # Public License for more details.
17
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21  
22 # (Process this file with autoconf to produce a configure script.)
23 AC_PREREQ(2.59)
24 min_automake_version="1.10"
25
26 # Version number: Remember to change it immediately *after* a release.
27 #                 Make sure to run  "svn up" and "./autogen.sh --force"
28 #                  before a "make dist".  See below for the LT versions.
29 #
30 # The SVN version is usually the next intended release version with
31 # the string "-svnNNN" appended.  The reason for this is that tests for a
32 # specific feature can already be done under the assumption that the
33 # SVN version is the most recent one in a branch.  To disable the SVN
34 # version for the real release, set the my_issvn macro to no.
35 m4_define(my_version, [1.3.1])
36 m4_define(my_issvn, [yes])
37
38 m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \
39             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
40 AC_INIT([gpgme], 
41         [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])],
42         [bug-gpgme@gnupg.org])
43
44
45 # LT Version numbers, remember to change them just *before* a release.
46 #   (Code changed:                      REVISION++)
47 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
48 #   (Interfaces added:                  AGE++)
49 #   (Interfaces removed/changed:        AGE=0)
50 #
51 LIBGPGME_LT_CURRENT=18
52 # Subtract 2 from this value if you want to make the LFS transition an
53 # ABI break.  [Note to self: Remove this comment with the next regular break.]
54 LIBGPGME_LT_AGE=7
55 LIBGPGME_LT_REVISION=0
56
57 # If the API is changed in an incompatible way: increment the next counter.
58 GPGME_CONFIG_API_VERSION=1
59 ##############################################
60
61 NEED_LIBASSUAN_API=2
62 NEED_LIBASSUAN_VERSION=2.0.0
63
64
65 BUILD_REVISION=svn_revision
66 PACKAGE=$PACKAGE_NAME
67 VERSION=$PACKAGE_VERSION
68
69 AC_CONFIG_SRCDIR(src/gpgme.h.in)
70 dnl FIXME: Enable this with autoconf 2.59.
71 dnl AC_CONFIG_MACRO_DIR(m4)
72 AM_CONFIG_HEADER(config.h)
73 AC_CONFIG_MACRO_DIR([m4])
74 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
75 AM_MAINTAINER_MODE
76 AC_CANONICAL_HOST
77
78 # Enable GNU extensions on systems that have them.
79 AC_GNU_SOURCE
80
81 AH_VERBATIM([_REENTRANT],
82 [/* To allow the use of GPGME in multithreaded programs we have to use
83   special features from the library.
84   IMPORTANT: gpgme is not yet fully reentrant and you should use it
85   only from one thread.  */
86 #ifndef _REENTRANT
87 # define _REENTRANT 1
88 #endif])
89
90 AC_PROG_CC
91 AC_PROG_CXX
92
93 AC_SUBST(LIBGPGME_LT_CURRENT)
94 AC_SUBST(LIBGPGME_LT_AGE)
95 AC_SUBST(LIBGPGME_LT_REVISION)
96
97 AC_SUBST(PACKAGE)
98 AC_SUBST(VERSION)
99 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
100 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
101
102 # Don't default to build static libs.
103 LT_PREREQ([2.2.6])
104 LT_INIT([win32-dll disable-static])
105 LT_LANG([Windows Resource])
106
107 # For now we hardcode the use of version scripts.  It would be better
108 # to write a test for this or even implement this within libtool.
109 have_ld_version_script=no
110 case "${host}" in
111     *-*-linux*)
112         have_ld_version_script=yes
113         ;;
114     *-*-gnu*)
115         have_ld_version_script=yes
116         ;;
117     *-apple-darwin*)
118         AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X)
119         ;;
120 esac
121
122 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
123
124 GPG_DEFAULT=no
125 GPGSM_DEFAULT=no
126 GPGCONF_DEFAULT=no
127 G13_DEFAULT=no
128 component_system=None
129 have_dosish_system=no
130 have_w32_system=no
131 build_w32_glib=no
132 build_w32_qt=no
133 case "${host}" in
134     *-mingw32ce*)
135         have_w32ce_system=yes
136         ;;
137 esac
138 case "${host}" in
139     *-mingw32ce*|*-mingw32*)
140         # special stuff for Windoze NT
141         have_dosish_system=yes
142         have_w32_system=yes
143         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
144         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
145         GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
146         G13_DEFAULT='c:\\gnupg\\g13.exe'
147         #component_system='COM+'
148
149         AM_PATH_GLIB_2_0
150         AC_ARG_ENABLE(w32-glib,
151             AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
152                            build_w32_glib=$enableval)
153
154         # Check disabled, because the qt-dev packages in gpg4win do
155         # not provide any support for cross compilation.
156         # PKG_CHECK_MODULES(QT4_CORE, QtCore)
157
158         # Use it like this:
159         # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
160         AC_SUBST(QT4_CORE_CFLAGS)
161         AC_SUBST(QT4_CORE_LIBS)
162         AC_ARG_ENABLE(w32-qt,
163             AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
164                            build_w32_qt=$enableval)
165         ;;
166     *)
167         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
168         if test "$have_pth" = yes; then
169           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
170         fi
171         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
172         if test "$have_pthread" = yes; then
173           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
174         fi
175
176         # XXX: Probably use exec-prefix here?
177 #       GPG_DEFAULT='/usr/bin/gpg'
178 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
179 #       GPGCONF_DEFAULT='/usr/bin/gpgconf'
180 #       G13_DEFAULT='/usr/bin/g13'
181         ;;
182 esac
183
184 if test "$have_dosish_system" = yes; then
185    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
186              [Defined if we run on some of the PCDOS like systems 
187               (DOS, Windoze. OS/2) with special properties like
188               no file modes])
189 fi
190 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
191
192 if test "$have_w32_system" = yes; then
193    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
194 fi
195 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
196 if test "$have_w32ce_system" = yes; then
197    AC_DEFINE(HAVE_W32CE_SYSTEM,1, [Defined if we run on a W32 CE API based system])
198 fi
199 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
200 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
201 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
202
203 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
204 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
205
206
207
208 # Checks for header files.
209 AC_CHECK_HEADERS([locale.h])
210 AC_CHECK_HEADERS(sys/select.h)
211 AC_CHECK_HEADERS([sys/uio.h])
212
213
214 # Type checks.
215 AC_C_INLINE
216 AC_CHECK_SIZEOF(unsigned int)
217 AC_SYS_LARGEFILE
218 AC_TYPE_OFF_T
219 AC_TYPE_UINTPTR_T
220
221 # A simple compile time check in gpgme.h for GNU/Linux systems that
222 # prevents a file offset bits mismatch between gpgme and the application.
223 NEED__FILE_OFFSET_BITS=0
224 case "$ac_cv_sys_file_offset_bits" in
225   "" | no | unknown) ;;
226   *)
227   NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
228   ;;
229 esac
230 AC_SUBST(NEED__FILE_OFFSET_BITS)
231
232
233 # Checks for compiler features.
234 if test "$GCC" = yes; then
235     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
236     if test "$have_w32_system" = yes; then
237        CFLAGS="$CFLAGS -mms-bitfields"
238     fi
239 fi
240
241 # Only used for debugging, so no serious test needed (for actual
242 # functionality you have to test libc as well, this only tests the
243 # compiler).
244 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
245    AC_COMPILE_IFELSE([__thread int foo;],
246      gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
247 if test "$gpgme_cv_tls_works" = yes; then
248   AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
249 fi
250
251
252 # Checks for library functions.
253 AC_FUNC_FSEEKO
254
255 AC_REPLACE_FUNCS(vasprintf)
256 if test "$ac_cv_func_vasprintf" != yes; then
257   GNUPG_CHECK_VA_COPY
258 fi
259
260 # Try to find a thread-safe version of ttyname().
261 AC_REPLACE_FUNCS(ttyname_r)
262 if test "$ac_cv_func_ttyname_r" != yes; then
263   AC_MSG_WARN([
264 ***
265 *** ttyname() is not thread-safe and ttyname_r() does not exist
266 ***])
267 fi
268
269 # Try to find a thread-safe version of getenv().
270 have_thread_safe_getenv=no
271 jm_GLIBC21
272 if test $GLIBC21 = yes; then
273   have_thread_safe_getenv=yes
274 fi
275 if test $have_thread_safe_getenv = yes; then
276   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
277 fi
278 have_getenv_r=no
279 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
280 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
281   AC_MSG_WARN([
282 ***
283 *** getenv() is not thread-safe and getenv_r() does not exist
284 ***])
285 fi
286
287 # For converting time strings to seconds since Epoch, we need the timegm
288 # function.
289 AC_CHECK_FUNCS(timegm)
290 if test "$ac_cv_func_timegm" != yes; then
291   AC_MSG_WARN([
292 ***
293 *** timegm() not available - a non-thread-safe kludge will be used
294 *** and the TZ variable might be changed at runtime.
295 ***])
296 fi
297
298 # Checking for libgpg-error.
299 AM_PATH_GPG_ERROR(1.8,, AC_MSG_ERROR([libgpg-error was not found]))
300 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
301           [The default error source for GPGME.])
302
303 # And for libassuan.
304 have_libassuan=no
305 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
306                   have_libassuan=yes, have_libassuan=no)
307 if test "$have_libassuan" = "yes"; then
308   AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
309                      [version of the libassuan library])
310 fi
311 AM_CONDITIONAL(HAVE_ASSUAN, test "$have_libassuan" = "yes")
312 if test "$have_libassuan" = "yes"; then
313   AC_DEFINE(ENABLE_ASSUAN,1,[Whether Assuan support is enabled])
314 fi
315
316 # Checks for system services
317 NEED_GPG_VERSION_DEFAULT=1.4.0
318 NEED_GPGSM_VERSION_DEFAULT=1.9.6
319 NEED_GPGCONF_VERSION_DEFAULT=2.0.4
320 NEED_G13_VERSION_DEFAULT=2.1.0
321 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
322 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
323 NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
324 NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
325 AC_ARG_WITH(gpg-version,
326             AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
327             NEED_GPG_VERSION=$withval)
328 if test "$NEED_GPG_VERSION" = "yes"; then
329   NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
330 fi
331 if test "$NEED_GPG_VERSION" = "no"; then
332   NEED_GPG_VERSION=0.0.0
333 fi
334 AC_ARG_WITH(gpgsm-version,
335             AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
336             NEED_GPGSM_VERSION=$withval)
337 if test "$NEED_GPGSM_VERSION" = "yes"; then
338   NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
339 fi
340 if test "$NEED_GPGSM_VERSION" = "no"; then
341   NEED_GPGSM_VERSION=0.0.0
342 fi
343 AC_ARG_WITH(gpgconf-version,
344             AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]),
345             NEED_GPGCONF_VERSION=$withval)
346 if test "$NEED_GPGCONF_VERSION" = "yes"; then
347   NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
348 fi
349 if test "$NEED_GPGCONF_VERSION" = "no"; then
350   NEED_GPGCONF_VERSION=0.0.0
351 fi
352 AC_ARG_WITH(g13-version,
353             AC_HELP_STRING([--with-g13-version=VER], [require G13 version VER]),
354             NEED_G13_VERSION=$withval)
355 if test "$NEED_G13_VERSION" = "yes"; then
356   NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
357 fi
358 if test "$NEED_G13_VERSION" = "no"; then
359   NEED_G13_VERSION=0.0.0
360 fi
361
362 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
363                                      [Min. needed GnuPG version.])
364 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
365                                        [Min. needed GPGSM version.])
366 AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION",
367                                          [Min. needed GPGCONF version.])
368 AC_DEFINE_UNQUOTED(NEED_G13_VERSION, "$NEED_G13_VERSION",
369                                      [Min. needed G13 version.])
370
371
372 NO_OVERRIDE=no
373 AC_ARG_WITH(gpg,
374             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
375             GPG=$withval, NO_OVERRIDE=yes)
376 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
377   GPG=
378   NO_OVERRIDE=yes
379   if test "$cross_compiling" != "yes"; then
380     AC_PATH_PROG(GPG, gpg)
381   fi
382   if test -z "$GPG"; then
383     GPG="$GPG_DEFAULT"
384   fi
385 fi
386 if test "$GPG" = no; then
387   if test "$NO_OVERRIDE" = "yes"; then
388     if test "$cross_compiling" != "yes"; then
389       AC_MSG_WARN([
390 ***
391 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
392 ***])
393     else
394       AC_MSG_ERROR([
395 ***
396 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
397 ***])
398     fi
399   fi
400 else
401   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
402   AC_SUBST(GPG)
403 fi
404 dnl Check for GnuPG version requirement.
405 GPG_VERSION=unknown
406 ok=maybe
407 if test -z "$GPG" -o "x$GPG" = "xno"; then
408   ok=no
409 else
410   if test "$cross_compiling" = "yes"; then
411     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
412     ok=no
413   else
414     if test ! -x "$GPG"; then
415       AC_MSG_WARN([GnuPG not executable, version check disabled])
416       ok=no
417     fi
418   fi
419 fi
420 if test "$ok" = "maybe"; then
421   AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
422   req_major=`echo $NEED_GPG_VERSION | \
423              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
424   req_minor=`echo $NEED_GPG_VERSION | \
425              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
426   req_micro=`echo $NEED_GPG_VERSION | \
427              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
428   GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
429   major=`echo $GPG_VERSION | \
430          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
431   minor=`echo $GPG_VERSION | \
432          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
433   micro=`echo $GPG_VERSION | \
434          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
435
436   if test "$major" -gt "$req_major"; then
437     ok=yes
438   else
439     if test "$major" -eq "$req_major"; then
440       if test "$minor" -gt "$req_minor"; then
441         ok=yes
442       else
443         if test "$minor" -eq "$req_minor"; then
444           if test "$micro" -ge "$req_micro"; then
445             ok=yes
446           fi
447         fi
448       fi
449     fi
450   fi
451   if test "$ok" = "yes"; then
452     AC_MSG_RESULT(yes)
453   else
454     AC_MSG_RESULT(no)
455     AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
456   fi
457 fi
458 run_gpg_test="$ok"
459 AC_ARG_ENABLE(gpg-test,
460   AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
461          run_gpg_test=$enableval)
462 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
463 AC_SUBST(GPG_PATH)
464
465 NO_OVERRIDE=no
466 AC_ARG_WITH(gpgsm,
467             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
468             GPGSM=$withval, NO_OVERRIDE=yes)
469 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
470   GPGSM=
471   NO_OVERRIDE=yes
472   if test "$cross_compiling" != "yes"; then
473     AC_PATH_PROG(GPGSM, gpgsm)
474   fi
475   if test -z "$GPGSM"; then
476     GPGSM="$GPGSM_DEFAULT"
477   fi
478 fi
479 if test "$GPGSM" = no; then
480   if test "$NO_OVERRIDE" = "yes"; then
481     if test "$cross_compiling" != "yes"; then
482       AC_MSG_WARN([
483 ***
484 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
485 ***])
486     else
487       AC_MSG_ERROR([
488 ***
489 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
490 ***])
491     fi
492   fi
493 else
494   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
495   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
496 fi
497 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
498
499
500 dnl Check for GPGSM version requirement.
501 GPGSM_VERSION=unknown
502 ok=maybe
503 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
504   ok=no
505 else
506   if test "$cross_compiling" = "yes"; then
507     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
508     ok=no
509   else
510     if test ! -x "$GPGSM"; then
511       AC_MSG_WARN([GPGSM not executable, version check disabled])
512       ok=no
513     fi
514   fi
515 fi
516 if test "$ok" = "maybe"; then
517   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
518   req_major=`echo $NEED_GPGSM_VERSION | \
519              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
520   req_minor=`echo $NEED_GPGSM_VERSION | \
521              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
522   req_micro=`echo $NEED_GPGSM_VERSION | \
523              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
524   GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
525   major=`echo $GPGSM_VERSION | \
526          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
527   minor=`echo $GPGSM_VERSION | \
528          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
529   micro=`echo $GPGSM_VERSION | \
530          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
531
532   if test "$major" -gt "$req_major"; then
533     ok=yes
534   else
535     if test "$major" -eq "$req_major"; then
536       if test "$minor" -gt "$req_minor"; then
537         ok=yes
538       else
539         if test "$minor" -eq "$req_minor"; then
540           if test "$micro" -ge "$req_micro"; then
541             ok=yes
542           fi
543         fi
544       fi
545     fi
546   fi
547   if test "$ok" = "yes"; then
548     AC_MSG_RESULT(yes)
549   else
550     AC_MSG_RESULT(no)
551     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
552   fi
553 fi
554 run_gpgsm_test="$ok"
555 AC_ARG_ENABLE(gpgsm-test,
556   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
557          run_gpgsm_test=$enableval)
558 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
559
560
561 NO_OVERRIDE=no
562 AC_ARG_WITH(gpgconf,
563             AC_HELP_STRING([--with-gpgconf=PATH],
564                            [use gpgconf binary at PATH]),
565             GPGCONF=$withval, NO_OVERRIDE=yes)
566 if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then
567   GPGCONF=
568   NO_OVERRIDE=yes
569   if test "$cross_compiling" != "yes"; then
570     AC_PATH_PROG(GPGCONF, gpgconf)
571   fi
572   if test -z "$GPGCONF"; then
573     GPGCONF="$GPGCONF_DEFAULT"
574   fi
575 fi
576 if test "$GPGCONF" = no; then
577   if test "$NO_OVERRIDE" = "yes"; then
578     if test "$cross_compiling" != "yes"; then
579       AC_MSG_WARN([
580 ***
581 *** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it
582 ***])
583     else
584       AC_MSG_ERROR([
585 ***
586 *** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH
587 ***])
588     fi
589   fi
590 else
591   AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.])
592   AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled])
593 fi
594 AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no")
595
596 dnl Check for GPGCONF version requirement.
597 GPGCONF_VERSION=unknown
598 ok=maybe
599 if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then
600   ok=no
601 else
602   if test "$cross_compiling" = "yes"; then
603     AC_MSG_WARN([GPGCONF version can not be checked when cross compiling])
604     ok=no
605   else
606     if test ! -x "$GPGCONF"; then
607       AC_MSG_WARN([GPGCONF not executable, version check disabled])
608       ok=no
609     fi
610   fi
611 fi
612 if test "$ok" = "maybe"; then
613   AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION)
614   req_major=`echo $NEED_GPGCONF_VERSION | \
615              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
616   req_minor=`echo $NEED_GPGCONF_VERSION | \
617              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
618   req_micro=`echo $NEED_GPGCONF_VERSION | \
619              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
620   GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
621   major=`echo $GPGCONF_VERSION | \
622          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
623   minor=`echo $GPGCONF_VERSION | \
624          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
625   micro=`echo $GPGCONF_VERSION | \
626          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
627
628   if test "$major" -gt "$req_major"; then
629     ok=yes
630   else
631     if test "$major" -eq "$req_major"; then
632       if test "$minor" -gt "$req_minor"; then
633         ok=yes
634       else
635         if test "$minor" -eq "$req_minor"; then
636           if test "$micro" -ge "$req_micro"; then
637             ok=yes
638           fi
639         fi
640       fi
641     fi
642   fi
643   if test "$ok" = "yes"; then
644     AC_MSG_RESULT(yes)
645   else
646     AC_MSG_RESULT(no)
647     AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION])
648   fi
649 fi
650 run_gpgconf_test="$ok"
651 AC_ARG_ENABLE(gpgconf-test,
652   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]),
653          run_gpgconf_test=$enableval)
654 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
655
656
657 NO_OVERRIDE=no
658 AC_ARG_WITH(g13,
659             AC_HELP_STRING([--with-g13=PATH],
660                            [use g13 binary at PATH]),
661             G13=$withval, NO_OVERRIDE=yes)
662 if test "$NO_OVERRIDE" = "yes" || test "$G13" = "yes"; then
663   G13=
664   NO_OVERRIDE=yes
665   if test "$cross_compiling" != "yes"; then
666     AC_PATH_PROG(G13, g13)
667   fi
668   if test -z "$G13"; then
669     G13="$G13_DEFAULT"
670   fi
671 fi
672 if test "$G13" = no; then
673   if test "$NO_OVERRIDE" = "yes"; then
674     if test "$cross_compiling" != "yes"; then
675       AC_MSG_WARN([
676 ***
677 *** Could not find g13, install g13 or use --with-g13=PATH to enable it
678 ***])
679     else
680       AC_MSG_ERROR([
681 ***
682 *** Can not determine path to g13 when cross-compiling, use --with-g13=PATH
683 ***])
684     fi
685   fi
686 else
687   AC_DEFINE_UNQUOTED(G13_PATH, "$G13", [Path to the G13 binary.])
688   AC_DEFINE(ENABLE_G13,1,[Whether G13 support is enabled])
689 fi
690 AM_CONDITIONAL(HAVE_G13, test "$G13" != "no")
691
692 dnl Check for G13 version requirement.
693 G13_VERSION=unknown
694 ok=maybe
695 if test -z "$G13" -o "x$G13" = "xno"; then
696   ok=no
697 else
698   if test "$cross_compiling" = "yes"; then
699     AC_MSG_WARN([G13 version can not be checked when cross compiling])
700     ok=no
701   else
702     if test ! -x "$G13"; then
703       AC_MSG_WARN([G13 not executable, version check disabled])
704       ok=no
705     fi
706   fi
707 fi
708 if test "$ok" = "maybe"; then
709   AC_MSG_CHECKING(for G13 >= $NEED_G13_VERSION)
710   req_major=`echo $NEED_G13_VERSION | \
711              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
712   req_minor=`echo $NEED_G13_VERSION | \
713              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
714   req_micro=`echo $NEED_G13_VERSION | \
715              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
716   G13_VERSION=`$G13 --version | sed -n '1 s/.*\ \([[0-9]].*\)/\1/p'`
717   major=`echo $G13_VERSION | \
718          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
719   minor=`echo $G13_VERSION | \
720          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
721   micro=`echo $G13_VERSION | \
722          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
723
724   if test "$major" -gt "$req_major"; then
725     ok=yes
726   else
727     if test "$major" -eq "$req_major"; then
728       if test "$minor" -gt "$req_minor"; then
729         ok=yes
730       else
731         if test "$minor" -eq "$req_minor"; then
732           if test "$micro" -ge "$req_micro"; then
733             ok=yes
734           fi
735         fi
736       fi
737     fi
738   fi
739   if test "$ok" = "yes"; then
740     AC_MSG_RESULT(yes)
741   else
742     AC_MSG_RESULT(no)
743     AC_MSG_WARN([G13 must be at least version $NEED_G13_VERSION])
744   fi
745 fi
746 run_g13_test="$ok"
747 AC_ARG_ENABLE(g13-test,
748   AC_HELP_STRING([--disable-g13-test], [disable G13 run test]),
749          run_g13_test=$enableval)
750 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
751
752
753 # Check for funopen
754 AC_CHECK_FUNCS(funopen)
755 if test $ac_cv_func_funopen != yes; then
756     # No funopen but we can implement that in terms of fopencookie.
757     AC_CHECK_FUNCS(fopencookie)
758     if test $ac_cv_func_fopencookie = yes; then
759         AC_REPLACE_FUNCS(funopen)
760     else
761         AC_MSG_WARN([
762 ***
763 *** No implementation of fopencookie or funopen available
764 ***])
765     fi
766 fi
767
768 # Check for getgid etc
769 AC_CHECK_FUNCS(getgid getegid)
770
771
772 # Replacement functions.
773 AC_REPLACE_FUNCS(stpcpy)
774 # Check for unistd.h for setenv replacement function.
775 AC_CHECK_HEADERS(unistd.h)
776 AC_REPLACE_FUNCS(setenv)
777
778 # Assuan check for descriptor passing.
779 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
780                 [supports_descriptor_passing=yes],
781                 [supports_descriptor_passing=no
782                  AC_MSG_WARN([
783 ***
784 *** Data structure for sending ancillary data missing.
785 *** Descriptor passing won't work.
786 ***])],[
787 #include <stdlib.h>
788 #include <stddef.h>
789 #include <stdio.h>
790 #include <sys/types.h>
791 #include <sys/socket.h>
792 #include <sys/un.h>
793 #if HAVE_SYS_UIO_H
794 #include <sys/uio.h>
795 #endif
796 #include <unistd.h>
797        ])
798
799 use_descriptor_passing=no
800 AC_ARG_ENABLE(fd-passing,
801   AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
802   use_descriptor_passing=$enableval)
803
804 if test "$supports_descriptor_passing" != "yes"; then
805   use_descriptor_passing=no
806 fi
807
808 if test "$use_descriptor_passing" = "yes"; then
809 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
810           [Defined if descriptor passing is enabled and supported])
811 fi
812
813 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
814
815
816 uiserver=no
817 if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then
818   uiserver=yes
819 fi
820 if test "$uiserver" != "no"; then
821   AC_DEFINE(ENABLE_UISERVER, 1,
822             [Defined if we are building with uiserver support.])
823 fi
824 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
825
826
827 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
828
829 # Generate values for the DLL version info
830 if test "$have_w32_system" = yes; then
831     BUILD_TIMESTAMP=`date --iso-8601=minutes`
832     changequote(,)dnl 
833     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
834     changequote([,])dnl
835     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
836 fi
837 AC_SUBST(BUILD_REVISION)
838 AC_SUBST(BUILD_TIMESTAMP)
839 AC_SUBST(BUILD_FILEVERSION)
840
841 # Add a few constants to help porting to W32
842 AH_VERBATIM([SEPCONSTANTS],
843 [
844 /* Separators as used in $PATH.  */
845 #ifdef HAVE_DOSISH_SYSTEM
846 #define PATHSEP_C ';'
847 #else
848 #define PATHSEP_C ':'
849 #endif
850 ])
851
852 AH_BOTTOM([
853 /* Definition of GCC specific attributes.  */
854 #if __GNUC__ > 2 
855 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
856 #else
857 # define GPGME_GCC_A_PURE
858 #endif
859 ])
860
861
862 # Substitution used for gpgme-config 
863 GPGME_CONFIG_LIBS="-lgpgme"
864 GPGME_CONFIG_CFLAGS=""
865 AC_SUBST(GPGME_CONFIG_API_VERSION)
866 AC_SUBST(GPGME_CONFIG_LIBS)
867 AC_SUBST(GPGME_CONFIG_CFLAGS)
868
869 # Frob'da Variables
870 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
871            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
872 AC_SUBST(LTLIBOBJS)
873
874 # Some checks for gpgme-tool
875 AC_CHECK_HEADER([argp.h])
876 AC_CHECK_TYPES([error_t], [],
877    [AC_DEFINE([error_t], [int],
878    [Define to a type to use for `error_t' if it is not otherwise available.])],
879    [#include <errno.h>])
880
881
882 # A substitution to set generated files in a Emacs buffer to read-only.
883 AC_SUBST(emacs_local_vars_begin, ['Local Variables:'])
884 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
885 AC_SUBST(emacs_local_vars_end, ['End:'])
886
887
888 # Last check.
889 die=no
890 if test "$have_libassuan" = "no"; then
891    die=yes
892    AC_MSG_NOTICE([[
893 ***
894 *** You need libassuan to build this program with GPGSM support.
895 *** This library is for example available at
896 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
897 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
898 ***]])
899 fi
900
901 if test "$die" = "yes"; then
902     AC_MSG_ERROR([[
903 ***
904 *** Required libraries not found. Please consult the above messages
905 *** and install them before running configure again.
906 ***]])
907 fi
908
909
910 #
911 # Create config files 
912
913 AC_CONFIG_FILES(Makefile src/Makefile
914                 tests/Makefile 
915                 tests/gpg/Makefile
916                 tests/gpgsm/Makefile
917                 tests/opassuan/Makefile
918                 doc/Makefile complus/Makefile
919                 src/versioninfo.rc
920                 src/gpgme.h)
921 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
922 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
923 AC_OUTPUT
924
925 echo "
926         GPGME v${VERSION} has been configured as follows:
927
928         GnuPG path:      $GPG
929         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
930
931         GpgSM path:      $GPGSM
932         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
933
934         GpgConf path:    $GPGCONF
935         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
936
937         G13 path:        $G13
938         G13 version:     $G13_VERSION, min. $NEED_G13_VERSION
939
940         Assuan version:  $libassuan_version, min. $NEED_LIBASSUAN_VERSION
941
942         UI Server:       $uiserver
943         FD Passing:      $use_descriptor_passing
944
945         GPGME Pthread:   $have_pthread
946         GPGME Pth:       $have_pth
947 "