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