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