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