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