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