Disable fd-passing for Apple.
[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, [1])
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=20
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=9
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 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 if test "$have_w32_system" != yes; then
274   case "$ac_cv_sys_file_offset_bits" in
275     "" | no | unknown) ;;
276     *)
277     NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
278     ;;
279   esac
280 fi
281 AC_SUBST(NEED__FILE_OFFSET_BITS)
282
283 # Figure out platform dependent typedefs for gpgme.h
284 if test "$have_w32_system" = yes; then
285    if test "$have_w64_system" = yes; then
286       INSERT__TYPEDEFS_FOR_GPGME_H="/* Typedefs for the 64 bit W32 API.  */
287 #include <basetsd.h>
288 typedef long off_t;
289 typedef __int64 ssize_t;"
290    else
291       INSERT__TYPEDEFS_FOR_GPGME_H="/* Typedefs for the 32 bit W32 API.  */
292 #ifndef _OFF_T_DEFINED   /* Defined by newer mingw32 toolkits.  */
293 typedef long off_t;
294 #endif
295 #ifndef _SSIZE_T_DEFINED /* Defined by newer mingw32 toolkits.  */
296 typedef long ssize_t;
297 #endif"
298    fi
299 else
300    INSERT__TYPEDEFS_FOR_GPGME_H="#include <sys/types.h>"
301 fi
302 AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H)
303 AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H)
304
305 # Checks for compiler features.
306 if test "$GCC" = yes; then
307     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
308     if test "$have_w32_system" = yes; then
309        CFLAGS="$CFLAGS -mms-bitfields"
310     fi
311 fi
312
313 # Only used for debugging, so no serious test needed (for actual
314 # functionality you have to test libc as well, this only tests the
315 # compiler).
316 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
317    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([__thread int foo;])],
318                      gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
319 if test "$gpgme_cv_tls_works" = yes; then
320   AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
321 fi
322
323
324 # Checks for library functions.
325 AC_MSG_NOTICE([checking for libraries])
326
327 AC_FUNC_FSEEKO
328
329 AC_REPLACE_FUNCS(vasprintf)
330 if test "$ac_cv_func_vasprintf" != yes; then
331   GNUPG_CHECK_VA_COPY
332 fi
333
334 # Try to find a thread-safe version of ttyname().
335 gnupg_REPLACE_TTYNAME_R
336 if test "$ac_cv_func_ttyname_r" != yes; then
337   AC_MSG_WARN([
338 ***
339 *** ttyname() is not thread-safe and ttyname_r() does not exist
340 ***])
341 fi
342
343 # Try to find a thread-safe version of getenv().
344 have_thread_safe_getenv=no
345 jm_GLIBC21
346 if test $GLIBC21 = yes; then
347   have_thread_safe_getenv=yes
348 fi
349 if test $have_thread_safe_getenv = yes; then
350   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
351 fi
352 have_getenv_r=no
353 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
354 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
355   AC_MSG_WARN([
356 ***
357 *** getenv() is not thread-safe and getenv_r() does not exist
358 ***])
359 fi
360
361 # For converting time strings to seconds since Epoch, we need the timegm
362 # function.
363 AC_CHECK_FUNCS(timegm)
364 if test "$ac_cv_func_timegm" != yes; then
365   AC_MSG_WARN([
366 ***
367 *** timegm() not available - a non-thread-safe kludge will be used
368 *** and the TZ variable might be changed at runtime.
369 ***])
370 fi
371
372 AC_CHECK_FUNCS(setlocale)
373
374 # Checking for libgpg-error.
375 have_gpg_error=no
376 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
377                   have_gpg_error=yes, have_gpg_error=no)
378 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
379           [The default error source for GPGME.])
380
381 # And for libassuan.
382 have_libassuan=no
383 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
384                   have_libassuan=yes, have_libassuan=no)
385 if test "$have_libassuan" = "yes"; then
386   AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
387                      [version of the libassuan library])
388 fi
389 AM_CONDITIONAL(HAVE_ASSUAN, test "$have_libassuan" = "yes")
390 if test "$have_libassuan" = "yes"; then
391   AC_DEFINE(ENABLE_ASSUAN,1,[Whether Assuan support is enabled])
392 fi
393
394 # Checks for system services
395 NEED_GPG_VERSION_DEFAULT=1.4.0
396 NEED_GPGSM_VERSION_DEFAULT=1.9.6
397 NEED_GPGCONF_VERSION_DEFAULT=2.0.4
398 NEED_G13_VERSION_DEFAULT=2.1.0
399 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
400 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
401 NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
402 NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
403 AC_ARG_WITH(gpg-version,
404             AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
405             NEED_GPG_VERSION=$withval)
406 if test "$NEED_GPG_VERSION" = "yes"; then
407   NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
408 fi
409 if test "$NEED_GPG_VERSION" = "no"; then
410   NEED_GPG_VERSION=0.0.0
411 fi
412 AC_ARG_WITH(gpgsm-version,
413             AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
414             NEED_GPGSM_VERSION=$withval)
415 if test "$NEED_GPGSM_VERSION" = "yes"; then
416   NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
417 fi
418 if test "$NEED_GPGSM_VERSION" = "no"; then
419   NEED_GPGSM_VERSION=0.0.0
420 fi
421 AC_ARG_WITH(gpgconf-version,
422             AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]),
423             NEED_GPGCONF_VERSION=$withval)
424 if test "$NEED_GPGCONF_VERSION" = "yes"; then
425   NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
426 fi
427 if test "$NEED_GPGCONF_VERSION" = "no"; then
428   NEED_GPGCONF_VERSION=0.0.0
429 fi
430 AC_ARG_WITH(g13-version,
431             AC_HELP_STRING([--with-g13-version=VER], [require G13 version VER]),
432             NEED_G13_VERSION=$withval)
433 if test "$NEED_G13_VERSION" = "yes"; then
434   NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
435 fi
436 if test "$NEED_G13_VERSION" = "no"; then
437   NEED_G13_VERSION=0.0.0
438 fi
439
440 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
441                                      [Min. needed GnuPG version.])
442 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
443                                        [Min. needed GPGSM version.])
444 AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION",
445                                          [Min. needed GPGCONF version.])
446 AC_DEFINE_UNQUOTED(NEED_G13_VERSION, "$NEED_G13_VERSION",
447                                      [Min. needed G13 version.])
448
449
450 NO_OVERRIDE=no
451 AC_ARG_WITH(gpg,
452             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
453             GPG=$withval, NO_OVERRIDE=yes)
454 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
455   GPG=
456   NO_OVERRIDE=yes
457   if test "$cross_compiling" != "yes"; then
458     AC_PATH_PROG(GPG, gpg)
459   fi
460   if test -z "$GPG"; then
461     GPG="$GPG_DEFAULT"
462   fi
463 fi
464 if test "$GPG" = no; then
465   if test "$NO_OVERRIDE" = "yes"; then
466     if test "$cross_compiling" != "yes"; then
467       AC_MSG_WARN([
468 ***
469 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
470 ***])
471     else
472       AC_MSG_ERROR([
473 ***
474 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
475 ***])
476     fi
477   fi
478 else
479   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
480   AC_SUBST(GPG)
481 fi
482 dnl Check for GnuPG version requirement.
483 GPG_VERSION=unknown
484 ok=maybe
485 if test -z "$GPG" -o "x$GPG" = "xno"; then
486   ok=no
487 else
488   if test "$cross_compiling" = "yes"; then
489     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
490     ok=no
491   else
492     if test ! -x "$GPG"; then
493       AC_MSG_WARN([GnuPG not executable, version check disabled])
494       ok=no
495     fi
496   fi
497 fi
498 if test "$ok" = "maybe"; then
499   AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
500   req_major=`echo $NEED_GPG_VERSION | \
501              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
502   req_minor=`echo $NEED_GPG_VERSION | \
503              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
504   req_micro=`echo $NEED_GPG_VERSION | \
505              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
506   GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
507   major=`echo $GPG_VERSION | \
508          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
509   minor=`echo $GPG_VERSION | \
510          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
511   micro=`echo $GPG_VERSION | \
512          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
513
514   if test "$major" -gt "$req_major"; then
515     ok=yes
516   else
517     if test "$major" -eq "$req_major"; then
518       if test "$minor" -gt "$req_minor"; then
519         ok=yes
520       else
521         if test "$minor" -eq "$req_minor"; then
522           if test "$micro" -ge "$req_micro"; then
523             ok=yes
524           fi
525         fi
526       fi
527     fi
528   fi
529   if test "$ok" = "yes"; then
530     AC_MSG_RESULT(yes)
531   else
532     AC_MSG_RESULT(no)
533     AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
534   fi
535 fi
536 run_gpg_test="$ok"
537 AC_ARG_ENABLE(gpg-test,
538   AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
539          run_gpg_test=$enableval)
540 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
541 AC_SUBST(GPG_PATH)
542
543 NO_OVERRIDE=no
544 AC_ARG_WITH(gpgsm,
545             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
546             GPGSM=$withval, NO_OVERRIDE=yes)
547 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
548   GPGSM=
549   NO_OVERRIDE=yes
550   if test "$cross_compiling" != "yes"; then
551     AC_PATH_PROG(GPGSM, gpgsm)
552   fi
553   if test -z "$GPGSM"; then
554     GPGSM="$GPGSM_DEFAULT"
555   fi
556 fi
557 if test "$GPGSM" = no; then
558   if test "$NO_OVERRIDE" = "yes"; then
559     if test "$cross_compiling" != "yes"; then
560       AC_MSG_WARN([
561 ***
562 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
563 ***])
564     else
565       AC_MSG_ERROR([
566 ***
567 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
568 ***])
569     fi
570   fi
571 else
572   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
573   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
574 fi
575 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
576
577
578 dnl Check for GPGSM version requirement.
579 GPGSM_VERSION=unknown
580 ok=maybe
581 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
582   ok=no
583 else
584   if test "$cross_compiling" = "yes"; then
585     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
586     ok=no
587   else
588     if test ! -x "$GPGSM"; then
589       AC_MSG_WARN([GPGSM not executable, version check disabled])
590       ok=no
591     fi
592   fi
593 fi
594 if test "$ok" = "maybe"; then
595   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
596   req_major=`echo $NEED_GPGSM_VERSION | \
597              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
598   req_minor=`echo $NEED_GPGSM_VERSION | \
599              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
600   req_micro=`echo $NEED_GPGSM_VERSION | \
601              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
602   GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
603   major=`echo $GPGSM_VERSION | \
604          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
605   minor=`echo $GPGSM_VERSION | \
606          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
607   micro=`echo $GPGSM_VERSION | \
608          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
609
610   if test "$major" -gt "$req_major"; then
611     ok=yes
612   else
613     if test "$major" -eq "$req_major"; then
614       if test "$minor" -gt "$req_minor"; then
615         ok=yes
616       else
617         if test "$minor" -eq "$req_minor"; then
618           if test "$micro" -ge "$req_micro"; then
619             ok=yes
620           fi
621         fi
622       fi
623     fi
624   fi
625   if test "$ok" = "yes"; then
626     AC_MSG_RESULT(yes)
627   else
628     AC_MSG_RESULT(no)
629     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
630   fi
631 fi
632 run_gpgsm_test="$ok"
633 AC_ARG_ENABLE(gpgsm-test,
634   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
635          run_gpgsm_test=$enableval)
636 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
637
638
639 NO_OVERRIDE=no
640 AC_ARG_WITH(gpgconf,
641             AC_HELP_STRING([--with-gpgconf=PATH],
642                            [use gpgconf binary at PATH]),
643             GPGCONF=$withval, NO_OVERRIDE=yes)
644 if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then
645   GPGCONF=
646   NO_OVERRIDE=yes
647   if test "$cross_compiling" != "yes"; then
648     AC_PATH_PROG(GPGCONF, gpgconf)
649   fi
650   if test -z "$GPGCONF"; then
651     GPGCONF="$GPGCONF_DEFAULT"
652   fi
653 fi
654 if test "$GPGCONF" = no; then
655   if test "$NO_OVERRIDE" = "yes"; then
656     if test "$cross_compiling" != "yes"; then
657       AC_MSG_WARN([
658 ***
659 *** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it
660 ***])
661     else
662       AC_MSG_ERROR([
663 ***
664 *** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH
665 ***])
666     fi
667   fi
668 else
669   AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.])
670   AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled])
671 fi
672 AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no")
673
674 dnl Check for GPGCONF version requirement.
675 GPGCONF_VERSION=unknown
676 ok=maybe
677 if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then
678   ok=no
679 else
680   if test "$cross_compiling" = "yes"; then
681     AC_MSG_WARN([GPGCONF version can not be checked when cross compiling])
682     ok=no
683   else
684     if test ! -x "$GPGCONF"; then
685       AC_MSG_WARN([GPGCONF not executable, version check disabled])
686       ok=no
687     fi
688   fi
689 fi
690 if test "$ok" = "maybe"; then
691   AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION)
692   req_major=`echo $NEED_GPGCONF_VERSION | \
693              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
694   req_minor=`echo $NEED_GPGCONF_VERSION | \
695              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
696   req_micro=`echo $NEED_GPGCONF_VERSION | \
697              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
698   GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
699   major=`echo $GPGCONF_VERSION | \
700          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
701   minor=`echo $GPGCONF_VERSION | \
702          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
703   micro=`echo $GPGCONF_VERSION | \
704          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
705
706   if test "$major" -gt "$req_major"; then
707     ok=yes
708   else
709     if test "$major" -eq "$req_major"; then
710       if test "$minor" -gt "$req_minor"; then
711         ok=yes
712       else
713         if test "$minor" -eq "$req_minor"; then
714           if test "$micro" -ge "$req_micro"; then
715             ok=yes
716           fi
717         fi
718       fi
719     fi
720   fi
721   if test "$ok" = "yes"; then
722     AC_MSG_RESULT(yes)
723   else
724     AC_MSG_RESULT(no)
725     AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION])
726   fi
727 fi
728 run_gpgconf_test="$ok"
729 AC_ARG_ENABLE(gpgconf-test,
730   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]),
731          run_gpgconf_test=$enableval)
732 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
733
734
735 NO_OVERRIDE=no
736 AC_ARG_WITH(g13,
737             AC_HELP_STRING([--with-g13=PATH],
738                            [use g13 binary at PATH]),
739             G13=$withval, NO_OVERRIDE=yes)
740 if test "$NO_OVERRIDE" = "yes" || test "$G13" = "yes"; then
741   G13=
742   NO_OVERRIDE=yes
743   if test "$cross_compiling" != "yes"; then
744     AC_PATH_PROG(G13, g13)
745   fi
746   if test -z "$G13"; then
747     G13="$G13_DEFAULT"
748   fi
749 fi
750 if test "$G13" = no; then
751   if test "$NO_OVERRIDE" = "yes"; then
752     if test "$cross_compiling" != "yes"; then
753       AC_MSG_WARN([
754 ***
755 *** Could not find g13, install g13 or use --with-g13=PATH to enable it
756 ***])
757     else
758       AC_MSG_ERROR([
759 ***
760 *** Can not determine path to g13 when cross-compiling, use --with-g13=PATH
761 ***])
762     fi
763   fi
764 else
765   AC_DEFINE_UNQUOTED(G13_PATH, "$G13", [Path to the G13 binary.])
766   AC_DEFINE(ENABLE_G13,1,[Whether G13 support is enabled])
767 fi
768 AM_CONDITIONAL(HAVE_G13, test "$G13" != "no")
769
770 dnl Check for G13 version requirement.
771 G13_VERSION=unknown
772 ok=maybe
773 if test -z "$G13" -o "x$G13" = "xno"; then
774   ok=no
775 else
776   if test "$cross_compiling" = "yes"; then
777     AC_MSG_WARN([G13 version can not be checked when cross compiling])
778     ok=no
779   else
780     if test ! -x "$G13"; then
781       AC_MSG_WARN([G13 not executable, version check disabled])
782       ok=no
783     fi
784   fi
785 fi
786 if test "$ok" = "maybe"; then
787   AC_MSG_CHECKING(for G13 >= $NEED_G13_VERSION)
788   req_major=`echo $NEED_G13_VERSION | \
789              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
790   req_minor=`echo $NEED_G13_VERSION | \
791              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
792   req_micro=`echo $NEED_G13_VERSION | \
793              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
794   G13_VERSION=`$G13 --version | sed -n '1 s/.*\ \([[0-9]].*\)/\1/p'`
795   major=`echo $G13_VERSION | \
796          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
797   minor=`echo $G13_VERSION | \
798          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
799   micro=`echo $G13_VERSION | \
800          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
801
802   if test "$major" -gt "$req_major"; then
803     ok=yes
804   else
805     if test "$major" -eq "$req_major"; then
806       if test "$minor" -gt "$req_minor"; then
807         ok=yes
808       else
809         if test "$minor" -eq "$req_minor"; then
810           if test "$micro" -ge "$req_micro"; then
811             ok=yes
812           fi
813         fi
814       fi
815     fi
816   fi
817   if test "$ok" = "yes"; then
818     AC_MSG_RESULT(yes)
819   else
820     AC_MSG_RESULT(no)
821     AC_MSG_WARN([G13 must be at least version $NEED_G13_VERSION])
822   fi
823 fi
824 run_g13_test="$ok"
825 AC_ARG_ENABLE(g13-test,
826   AC_HELP_STRING([--disable-g13-test], [disable G13 run test]),
827          run_g13_test=$enableval)
828 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
829
830
831 # Check for funopen
832 AC_CHECK_FUNCS(funopen)
833 if test $ac_cv_func_funopen != yes; then
834     # No funopen but we can implement that in terms of fopencookie.
835     AC_CHECK_FUNCS(fopencookie)
836     if test $ac_cv_func_fopencookie = yes; then
837         AC_REPLACE_FUNCS(funopen)
838     else
839         AC_MSG_WARN([
840 ***
841 *** No implementation of fopencookie or funopen available
842 ***])
843     fi
844 fi
845
846 # Check for getgid etc
847 AC_CHECK_FUNCS(getgid getegid)
848
849
850 # Replacement functions.
851 AC_REPLACE_FUNCS(stpcpy)
852 AC_REPLACE_FUNCS(setenv)
853
854 # Assuan check for descriptor passing.
855 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
856                 [supports_descriptor_passing=yes],
857                 [supports_descriptor_passing=no
858                  AC_MSG_WARN([
859 ***
860 *** Data structure for sending ancillary data missing.
861 *** Descriptor passing won't work.
862 ***])],[
863 #include <stdlib.h>
864 #include <stddef.h>
865 #include <stdio.h>
866 #include <sys/types.h>
867 #include <sys/socket.h>
868 #include <sys/un.h>
869 #if HAVE_SYS_UIO_H
870 #include <sys/uio.h>
871 #endif
872 #include <unistd.h>
873        ])
874
875
876 dnl There seems to be a problem with Apple and decriptor passing.
877 dnl Until we found a solution we change the default to no.
878 dnl See bug 1483.
879 case "${host}" in
880     *-apple-darwin*)
881       use_descriptor_passing=no
882       ;;
883     *)
884       use_descriptor_passing=yes
885       ;;
886 esac
887 AC_ARG_ENABLE(fd-passing,
888   AC_HELP_STRING([--disable-fd-passing], [do not use FD passing]),
889   use_descriptor_passing=$enableval)
890
891 if test "$supports_descriptor_passing" != "yes"; then
892   use_descriptor_passing=no
893 fi
894
895 if test "$use_descriptor_passing" = "yes"; then
896 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
897           [Defined if descriptor passing is enabled and supported])
898 fi
899
900 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
901
902
903 uiserver=no
904 if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then
905   uiserver=yes
906 fi
907 if test "$uiserver" != "no"; then
908   AC_DEFINE(ENABLE_UISERVER, 1,
909             [Defined if we are building with uiserver support.])
910 fi
911 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
912
913
914 # Add a few constants to help porting to W32
915 AH_VERBATIM([SEPCONSTANTS],
916 [
917 /* Separators as used in $PATH.  */
918 #ifdef HAVE_DOSISH_SYSTEM
919 #define PATHSEP_C ';'
920 #else
921 #define PATHSEP_C ':'
922 #endif
923 ])
924
925 AH_BOTTOM([
926 /* Definition of GCC specific attributes.  */
927 #if __GNUC__ > 2
928 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
929 #else
930 # define GPGME_GCC_A_PURE
931 #endif
932
933 /* Under WindowsCE we need gpg-error's strerror macro.  */
934 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
935
936 #define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \
937                     "Copyright (C) 2001--2013 g10 Code GmbH\n"
938 ])
939
940
941 # Substitution used for gpgme-config
942 GPGME_CONFIG_LIBS="-lgpgme"
943 GPGME_CONFIG_CFLAGS=""
944 GPGME_CONFIG_HOST="$host"
945 AC_SUBST(GPGME_CONFIG_API_VERSION)
946 AC_SUBST(GPGME_CONFIG_LIBS)
947 AC_SUBST(GPGME_CONFIG_CFLAGS)
948 AC_SUBST(GPGME_CONFIG_HOST)
949
950 # Frob'da Variables
951 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
952            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
953 AC_SUBST(LTLIBOBJS)
954
955 # Some checks for gpgme-tool
956 # Done at top: AC_CHECK_HEADER([argp.h])
957 AC_CHECK_TYPES([error_t], [],
958    [AC_DEFINE([error_t], [int],
959    [Define to a type to use for `error_t' if it is not otherwise available.])],
960    [#include <errno.h>])
961
962
963 # A substitution to set generated files in a Emacs buffer to read-only.
964 AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
965 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
966 AC_SUBST(emacs_local_vars_end, ['End:'])
967
968
969 # Last check.
970 die=no
971 if test "$have_gpg_error" = "no"; then
972    die=yes
973    AC_MSG_NOTICE([[
974 ***
975 *** You need libgpg-error to build this program.
976 **  This library is for example available at
977 ***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
978 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
979 ***]])
980 fi
981 if test "$have_libassuan" = "no"; then
982    die=yes
983    AC_MSG_NOTICE([[
984 ***
985 *** You need libassuan to build this program with GPGSM support.
986 *** This library is for example available at
987 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
988 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
989 ***]])
990 fi
991
992 if test "$die" = "yes"; then
993     AC_MSG_ERROR([[
994 ***
995 *** Required libraries not found. Please consult the above messages
996 *** and install them before running configure again.
997 ***]])
998 fi
999
1000
1001 #
1002 # Create config files
1003
1004 AC_CONFIG_FILES(Makefile src/Makefile
1005                 tests/Makefile
1006                 tests/gpg/Makefile
1007                 tests/gpgsm/Makefile
1008                 tests/opassuan/Makefile
1009                 doc/Makefile
1010                 src/versioninfo.rc
1011                 src/gpgme.h)
1012 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
1013 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
1014 AC_OUTPUT
1015
1016 echo "
1017         GPGME v${VERSION} has been configured as follows:
1018
1019         Revision:        mym4_revision  (mym4_revision_dec)
1020         Platform:        $host
1021
1022         GnuPG path:      $GPG
1023         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
1024         GpgSM path:      $GPGSM
1025         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
1026         GpgConf path:    $GPGCONF
1027         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
1028         G13 path:        $G13
1029         G13 version:     $G13_VERSION, min. $NEED_G13_VERSION
1030
1031         Assuan version:  $libassuan_config_version, min. $NEED_LIBASSUAN_VERSION
1032
1033         UI Server:       $uiserver
1034         FD Passing:      $use_descriptor_passing
1035         GPGME Pthread:   $have_pthread
1036 "