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