Require autoconf 1.11
[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  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 Lesser General Public
19 # License along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21
22 # (Process this file with autoconf to produce a configure script.)
23 AC_PREREQ(2.59)
24 min_automake_version="1.11"
25
26 # Version number: Remember to change it immediately *after* a release.
27 #                 Make sure to run  "svn up" and "./autogen.sh --force"
28 #                  before a "make dist".  See below for the LT versions.
29 #
30 # The SVN version is usually the next intended release version with
31 # the string "-svnNNN" appended.  The reason for this is that tests for a
32 # specific feature can already be done under the assumption that the
33 # SVN version is the most recent one in a branch.  To disable the SVN
34 # version for the real release, set the my_issvn macro to no.
35 m4_define(my_version, [1.3.1])
36 m4_define(my_issvn, [yes])
37
38 m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \
39             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
40 m4_define([git_revision], m4_esyscmd([git branch -v 2>/dev/null \
41           | awk '/^\* / {printf "%s",$3}']))
42 AC_INIT([gpgme],
43         [my_version[]m4_if(my_issvn,[yes],
44         [m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])],
45         [bug-gpgme@gnupg.org])
46
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=18
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=7
58 LIBGPGME_LT_REVISION=0
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 dnl FIXME: Enable this with autoconf 2.59.
75 dnl AC_CONFIG_MACRO_DIR(m4)
76 AM_CONFIG_HEADER(config.h)
77 AC_CONFIG_MACRO_DIR([m4])
78 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
79 AM_MAINTAINER_MODE
80 AC_CANONICAL_HOST
81
82 # Enable GNU extensions on systems that have them.
83 AC_GNU_SOURCE
84
85 AH_VERBATIM([_REENTRANT],
86 [/* To allow the use of GPGME in multithreaded programs we have to use
87   special features from the library.
88   IMPORTANT: gpgme is not yet fully reentrant and you should use it
89   only from one thread.  */
90 #ifndef _REENTRANT
91 # define _REENTRANT 1
92 #endif])
93
94 AC_PROG_CC
95 AC_PROG_CXX
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_w32_system=no
135 have_w64_system=no
136 build_w32_glib=no
137 build_w32_qt=no
138 case "${host}" in
139     x86_64-*mingw32*)
140         have_w64_system=yes
141         ;;
142     *-mingw32ce*)
143         have_w32ce_system=yes
144         ;;
145 esac
146 case "${host}" in
147     *-mingw32ce*|*-mingw32*)
148         have_dosish_system=yes
149         have_w32_system=yes
150         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
151         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
152         GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
153         G13_DEFAULT='c:\\gnupg\\g13.exe'
154         #component_system='COM+'
155
156         AM_PATH_GLIB_2_0
157         AC_ARG_ENABLE(w32-glib,
158             AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
159                            build_w32_glib=$enableval)
160
161         # Check disabled, because the qt-dev packages in gpg4win do
162         # not provide any support for cross compilation.
163         # PKG_CHECK_MODULES(QT4_CORE, QtCore)
164
165         # Use it like this:
166         # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
167         AC_SUBST(QT4_CORE_CFLAGS)
168         AC_SUBST(QT4_CORE_LIBS)
169         AC_ARG_ENABLE(w32-qt,
170             AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
171                            build_w32_qt=$enableval)
172         ;;
173     *)
174         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
175         if test "$have_pth" = yes; then
176           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
177         fi
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    ACSUBST
203 fi
204 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
205
206 if test "$have_w64_system" = yes; then
207    AC_DEFINE(HAVE_W64_SYSTEM,1,
208              [Defined if we run on a 64 bit W32 API based system])
209 fi
210 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
211
212 if test "$have_w32ce_system" = yes; then
213    AC_DEFINE(HAVE_W32CE_SYSTEM,1,
214              [Defined if we run on a W32 CE API based system])
215 fi
216 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
217
218 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
219 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
220
221 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
222 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
223
224
225
226 # Checks for header files.
227 AC_CHECK_HEADERS([locale.h])
228 AC_CHECK_HEADERS(sys/select.h)
229 AC_CHECK_HEADERS([sys/uio.h])
230
231
232 # Type checks.
233 AC_C_INLINE
234 AC_CHECK_SIZEOF(unsigned int)
235 AC_SYS_LARGEFILE
236 AC_TYPE_OFF_T
237 AC_TYPE_UINTPTR_T
238
239 # A simple compile time check in gpgme.h for GNU/Linux systems that
240 # prevents a file offset bits mismatch between gpgme and the application.
241 NEED__FILE_OFFSET_BITS=0
242 case "$ac_cv_sys_file_offset_bits" in
243   "" | no | unknown) ;;
244   *)
245   NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
246   ;;
247 esac
248 AC_SUBST(NEED__FILE_OFFSET_BITS)
249
250 # Figure out platform dependent typedefs for gpgme.h
251 if test "$have_w32_system" = yes; then
252    if test "$have_w64_system" = yes; then
253       INSERT__TYPEDEFS_FOR_GPGME_H="/* Typedefs for the 64 bit W32 API.  */
254 #include <basetsd.h>
255 typedef long off_t;
256 typedef __int64 ssize_t;"
257    else
258       INSERT__TYPEDEFS_FOR_GPGME_H="/* Typedefs for the 32 bit W32 API.  */
259 typedef long off_t;
260 typedef long ssize_t;"
261    fi
262 else
263    INSERT__TYPEDEFS_FOR_GPGME_H="#include <sys/types.h>"
264 fi
265 AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H)
266 AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H)
267
268 # Checks for compiler features.
269 if test "$GCC" = yes; then
270     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
271     if test "$have_w32_system" = yes; then
272        CFLAGS="$CFLAGS -mms-bitfields"
273     fi
274 fi
275
276 # Only used for debugging, so no serious test needed (for actual
277 # functionality you have to test libc as well, this only tests the
278 # compiler).
279 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
280    AC_COMPILE_IFELSE([__thread int foo;],
281      gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
282 if test "$gpgme_cv_tls_works" = yes; then
283   AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
284 fi
285
286
287 # Checks for library functions.
288 AC_FUNC_FSEEKO
289
290 AC_REPLACE_FUNCS(vasprintf)
291 if test "$ac_cv_func_vasprintf" != yes; then
292   GNUPG_CHECK_VA_COPY
293 fi
294
295 # Try to find a thread-safe version of ttyname().
296 AC_REPLACE_FUNCS(ttyname_r)
297 if test "$ac_cv_func_ttyname_r" != yes; then
298   AC_MSG_WARN([
299 ***
300 *** ttyname() is not thread-safe and ttyname_r() does not exist
301 ***])
302 fi
303
304 # Try to find a thread-safe version of getenv().
305 have_thread_safe_getenv=no
306 jm_GLIBC21
307 if test $GLIBC21 = yes; then
308   have_thread_safe_getenv=yes
309 fi
310 if test $have_thread_safe_getenv = yes; then
311   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
312 fi
313 have_getenv_r=no
314 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
315 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
316   AC_MSG_WARN([
317 ***
318 *** getenv() is not thread-safe and getenv_r() does not exist
319 ***])
320 fi
321
322 # For converting time strings to seconds since Epoch, we need the timegm
323 # function.
324 AC_CHECK_FUNCS(timegm)
325 if test "$ac_cv_func_timegm" != yes; then
326   AC_MSG_WARN([
327 ***
328 *** timegm() not available - a non-thread-safe kludge will be used
329 *** and the TZ variable might be changed at runtime.
330 ***])
331 fi
332
333 AC_CHECK_FUNCS(setlocale)
334
335 # Checking for libgpg-error.
336 AM_PATH_GPG_ERROR(1.8,, AC_MSG_ERROR([libgpg-error was not found]))
337 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
338           [The default error source for GPGME.])
339
340 # And for libassuan.
341 have_libassuan=no
342 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
343                   have_libassuan=yes, have_libassuan=no)
344 if test "$have_libassuan" = "yes"; then
345   AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
346                      [version of the libassuan library])
347 fi
348 AM_CONDITIONAL(HAVE_ASSUAN, test "$have_libassuan" = "yes")
349 if test "$have_libassuan" = "yes"; then
350   AC_DEFINE(ENABLE_ASSUAN,1,[Whether Assuan support is enabled])
351 fi
352
353 # Checks for system services
354 NEED_GPG_VERSION_DEFAULT=1.4.0
355 NEED_GPGSM_VERSION_DEFAULT=1.9.6
356 NEED_GPGCONF_VERSION_DEFAULT=2.0.4
357 NEED_G13_VERSION_DEFAULT=2.1.0
358 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
359 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
360 NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
361 NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
362 AC_ARG_WITH(gpg-version,
363             AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
364             NEED_GPG_VERSION=$withval)
365 if test "$NEED_GPG_VERSION" = "yes"; then
366   NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
367 fi
368 if test "$NEED_GPG_VERSION" = "no"; then
369   NEED_GPG_VERSION=0.0.0
370 fi
371 AC_ARG_WITH(gpgsm-version,
372             AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
373             NEED_GPGSM_VERSION=$withval)
374 if test "$NEED_GPGSM_VERSION" = "yes"; then
375   NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
376 fi
377 if test "$NEED_GPGSM_VERSION" = "no"; then
378   NEED_GPGSM_VERSION=0.0.0
379 fi
380 AC_ARG_WITH(gpgconf-version,
381             AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]),
382             NEED_GPGCONF_VERSION=$withval)
383 if test "$NEED_GPGCONF_VERSION" = "yes"; then
384   NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
385 fi
386 if test "$NEED_GPGCONF_VERSION" = "no"; then
387   NEED_GPGCONF_VERSION=0.0.0
388 fi
389 AC_ARG_WITH(g13-version,
390             AC_HELP_STRING([--with-g13-version=VER], [require G13 version VER]),
391             NEED_G13_VERSION=$withval)
392 if test "$NEED_G13_VERSION" = "yes"; then
393   NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
394 fi
395 if test "$NEED_G13_VERSION" = "no"; then
396   NEED_G13_VERSION=0.0.0
397 fi
398
399 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
400                                      [Min. needed GnuPG version.])
401 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
402                                        [Min. needed GPGSM version.])
403 AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION",
404                                          [Min. needed GPGCONF version.])
405 AC_DEFINE_UNQUOTED(NEED_G13_VERSION, "$NEED_G13_VERSION",
406                                      [Min. needed G13 version.])
407
408
409 NO_OVERRIDE=no
410 AC_ARG_WITH(gpg,
411             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
412             GPG=$withval, NO_OVERRIDE=yes)
413 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
414   GPG=
415   NO_OVERRIDE=yes
416   if test "$cross_compiling" != "yes"; then
417     AC_PATH_PROG(GPG, gpg)
418   fi
419   if test -z "$GPG"; then
420     GPG="$GPG_DEFAULT"
421   fi
422 fi
423 if test "$GPG" = no; then
424   if test "$NO_OVERRIDE" = "yes"; then
425     if test "$cross_compiling" != "yes"; then
426       AC_MSG_WARN([
427 ***
428 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
429 ***])
430     else
431       AC_MSG_ERROR([
432 ***
433 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
434 ***])
435     fi
436   fi
437 else
438   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
439   AC_SUBST(GPG)
440 fi
441 dnl Check for GnuPG version requirement.
442 GPG_VERSION=unknown
443 ok=maybe
444 if test -z "$GPG" -o "x$GPG" = "xno"; then
445   ok=no
446 else
447   if test "$cross_compiling" = "yes"; then
448     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
449     ok=no
450   else
451     if test ! -x "$GPG"; then
452       AC_MSG_WARN([GnuPG not executable, version check disabled])
453       ok=no
454     fi
455   fi
456 fi
457 if test "$ok" = "maybe"; then
458   AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
459   req_major=`echo $NEED_GPG_VERSION | \
460              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
461   req_minor=`echo $NEED_GPG_VERSION | \
462              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
463   req_micro=`echo $NEED_GPG_VERSION | \
464              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
465   GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
466   major=`echo $GPG_VERSION | \
467          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
468   minor=`echo $GPG_VERSION | \
469          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
470   micro=`echo $GPG_VERSION | \
471          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
472
473   if test "$major" -gt "$req_major"; then
474     ok=yes
475   else
476     if test "$major" -eq "$req_major"; then
477       if test "$minor" -gt "$req_minor"; then
478         ok=yes
479       else
480         if test "$minor" -eq "$req_minor"; then
481           if test "$micro" -ge "$req_micro"; then
482             ok=yes
483           fi
484         fi
485       fi
486     fi
487   fi
488   if test "$ok" = "yes"; then
489     AC_MSG_RESULT(yes)
490   else
491     AC_MSG_RESULT(no)
492     AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
493   fi
494 fi
495 run_gpg_test="$ok"
496 AC_ARG_ENABLE(gpg-test,
497   AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
498          run_gpg_test=$enableval)
499 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
500 AC_SUBST(GPG_PATH)
501
502 NO_OVERRIDE=no
503 AC_ARG_WITH(gpgsm,
504             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
505             GPGSM=$withval, NO_OVERRIDE=yes)
506 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
507   GPGSM=
508   NO_OVERRIDE=yes
509   if test "$cross_compiling" != "yes"; then
510     AC_PATH_PROG(GPGSM, gpgsm)
511   fi
512   if test -z "$GPGSM"; then
513     GPGSM="$GPGSM_DEFAULT"
514   fi
515 fi
516 if test "$GPGSM" = no; then
517   if test "$NO_OVERRIDE" = "yes"; then
518     if test "$cross_compiling" != "yes"; then
519       AC_MSG_WARN([
520 ***
521 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
522 ***])
523     else
524       AC_MSG_ERROR([
525 ***
526 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
527 ***])
528     fi
529   fi
530 else
531   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
532   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
533 fi
534 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
535
536
537 dnl Check for GPGSM version requirement.
538 GPGSM_VERSION=unknown
539 ok=maybe
540 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
541   ok=no
542 else
543   if test "$cross_compiling" = "yes"; then
544     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
545     ok=no
546   else
547     if test ! -x "$GPGSM"; then
548       AC_MSG_WARN([GPGSM not executable, version check disabled])
549       ok=no
550     fi
551   fi
552 fi
553 if test "$ok" = "maybe"; then
554   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
555   req_major=`echo $NEED_GPGSM_VERSION | \
556              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
557   req_minor=`echo $NEED_GPGSM_VERSION | \
558              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
559   req_micro=`echo $NEED_GPGSM_VERSION | \
560              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
561   GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
562   major=`echo $GPGSM_VERSION | \
563          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
564   minor=`echo $GPGSM_VERSION | \
565          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
566   micro=`echo $GPGSM_VERSION | \
567          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
568
569   if test "$major" -gt "$req_major"; then
570     ok=yes
571   else
572     if test "$major" -eq "$req_major"; then
573       if test "$minor" -gt "$req_minor"; then
574         ok=yes
575       else
576         if test "$minor" -eq "$req_minor"; then
577           if test "$micro" -ge "$req_micro"; then
578             ok=yes
579           fi
580         fi
581       fi
582     fi
583   fi
584   if test "$ok" = "yes"; then
585     AC_MSG_RESULT(yes)
586   else
587     AC_MSG_RESULT(no)
588     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
589   fi
590 fi
591 run_gpgsm_test="$ok"
592 AC_ARG_ENABLE(gpgsm-test,
593   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
594          run_gpgsm_test=$enableval)
595 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
596
597
598 NO_OVERRIDE=no
599 AC_ARG_WITH(gpgconf,
600             AC_HELP_STRING([--with-gpgconf=PATH],
601                            [use gpgconf binary at PATH]),
602             GPGCONF=$withval, NO_OVERRIDE=yes)
603 if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then
604   GPGCONF=
605   NO_OVERRIDE=yes
606   if test "$cross_compiling" != "yes"; then
607     AC_PATH_PROG(GPGCONF, gpgconf)
608   fi
609   if test -z "$GPGCONF"; then
610     GPGCONF="$GPGCONF_DEFAULT"
611   fi
612 fi
613 if test "$GPGCONF" = no; then
614   if test "$NO_OVERRIDE" = "yes"; then
615     if test "$cross_compiling" != "yes"; then
616       AC_MSG_WARN([
617 ***
618 *** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it
619 ***])
620     else
621       AC_MSG_ERROR([
622 ***
623 *** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH
624 ***])
625     fi
626   fi
627 else
628   AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.])
629   AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled])
630 fi
631 AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no")
632
633 dnl Check for GPGCONF version requirement.
634 GPGCONF_VERSION=unknown
635 ok=maybe
636 if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then
637   ok=no
638 else
639   if test "$cross_compiling" = "yes"; then
640     AC_MSG_WARN([GPGCONF version can not be checked when cross compiling])
641     ok=no
642   else
643     if test ! -x "$GPGCONF"; then
644       AC_MSG_WARN([GPGCONF not executable, version check disabled])
645       ok=no
646     fi
647   fi
648 fi
649 if test "$ok" = "maybe"; then
650   AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION)
651   req_major=`echo $NEED_GPGCONF_VERSION | \
652              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
653   req_minor=`echo $NEED_GPGCONF_VERSION | \
654              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
655   req_micro=`echo $NEED_GPGCONF_VERSION | \
656              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
657   GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
658   major=`echo $GPGCONF_VERSION | \
659          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
660   minor=`echo $GPGCONF_VERSION | \
661          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
662   micro=`echo $GPGCONF_VERSION | \
663          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
664
665   if test "$major" -gt "$req_major"; then
666     ok=yes
667   else
668     if test "$major" -eq "$req_major"; then
669       if test "$minor" -gt "$req_minor"; then
670         ok=yes
671       else
672         if test "$minor" -eq "$req_minor"; then
673           if test "$micro" -ge "$req_micro"; then
674             ok=yes
675           fi
676         fi
677       fi
678     fi
679   fi
680   if test "$ok" = "yes"; then
681     AC_MSG_RESULT(yes)
682   else
683     AC_MSG_RESULT(no)
684     AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION])
685   fi
686 fi
687 run_gpgconf_test="$ok"
688 AC_ARG_ENABLE(gpgconf-test,
689   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]),
690          run_gpgconf_test=$enableval)
691 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
692
693
694 NO_OVERRIDE=no
695 AC_ARG_WITH(g13,
696             AC_HELP_STRING([--with-g13=PATH],
697                            [use g13 binary at PATH]),
698             G13=$withval, NO_OVERRIDE=yes)
699 if test "$NO_OVERRIDE" = "yes" || test "$G13" = "yes"; then
700   G13=
701   NO_OVERRIDE=yes
702   if test "$cross_compiling" != "yes"; then
703     AC_PATH_PROG(G13, g13)
704   fi
705   if test -z "$G13"; then
706     G13="$G13_DEFAULT"
707   fi
708 fi
709 if test "$G13" = no; then
710   if test "$NO_OVERRIDE" = "yes"; then
711     if test "$cross_compiling" != "yes"; then
712       AC_MSG_WARN([
713 ***
714 *** Could not find g13, install g13 or use --with-g13=PATH to enable it
715 ***])
716     else
717       AC_MSG_ERROR([
718 ***
719 *** Can not determine path to g13 when cross-compiling, use --with-g13=PATH
720 ***])
721     fi
722   fi
723 else
724   AC_DEFINE_UNQUOTED(G13_PATH, "$G13", [Path to the G13 binary.])
725   AC_DEFINE(ENABLE_G13,1,[Whether G13 support is enabled])
726 fi
727 AM_CONDITIONAL(HAVE_G13, test "$G13" != "no")
728
729 dnl Check for G13 version requirement.
730 G13_VERSION=unknown
731 ok=maybe
732 if test -z "$G13" -o "x$G13" = "xno"; then
733   ok=no
734 else
735   if test "$cross_compiling" = "yes"; then
736     AC_MSG_WARN([G13 version can not be checked when cross compiling])
737     ok=no
738   else
739     if test ! -x "$G13"; then
740       AC_MSG_WARN([G13 not executable, version check disabled])
741       ok=no
742     fi
743   fi
744 fi
745 if test "$ok" = "maybe"; then
746   AC_MSG_CHECKING(for G13 >= $NEED_G13_VERSION)
747   req_major=`echo $NEED_G13_VERSION | \
748              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
749   req_minor=`echo $NEED_G13_VERSION | \
750              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
751   req_micro=`echo $NEED_G13_VERSION | \
752              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
753   G13_VERSION=`$G13 --version | sed -n '1 s/.*\ \([[0-9]].*\)/\1/p'`
754   major=`echo $G13_VERSION | \
755          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
756   minor=`echo $G13_VERSION | \
757          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
758   micro=`echo $G13_VERSION | \
759          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
760
761   if test "$major" -gt "$req_major"; then
762     ok=yes
763   else
764     if test "$major" -eq "$req_major"; then
765       if test "$minor" -gt "$req_minor"; then
766         ok=yes
767       else
768         if test "$minor" -eq "$req_minor"; then
769           if test "$micro" -ge "$req_micro"; then
770             ok=yes
771           fi
772         fi
773       fi
774     fi
775   fi
776   if test "$ok" = "yes"; then
777     AC_MSG_RESULT(yes)
778   else
779     AC_MSG_RESULT(no)
780     AC_MSG_WARN([G13 must be at least version $NEED_G13_VERSION])
781   fi
782 fi
783 run_g13_test="$ok"
784 AC_ARG_ENABLE(g13-test,
785   AC_HELP_STRING([--disable-g13-test], [disable G13 run test]),
786          run_g13_test=$enableval)
787 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
788
789
790 # Check for funopen
791 AC_CHECK_FUNCS(funopen)
792 if test $ac_cv_func_funopen != yes; then
793     # No funopen but we can implement that in terms of fopencookie.
794     AC_CHECK_FUNCS(fopencookie)
795     if test $ac_cv_func_fopencookie = yes; then
796         AC_REPLACE_FUNCS(funopen)
797     else
798         AC_MSG_WARN([
799 ***
800 *** No implementation of fopencookie or funopen available
801 ***])
802     fi
803 fi
804
805 # Check for getgid etc
806 AC_CHECK_FUNCS(getgid getegid)
807
808
809 # Replacement functions.
810 AC_REPLACE_FUNCS(stpcpy)
811 # Check for unistd.h for setenv replacement function.
812 AC_CHECK_HEADERS([unistd.h sys/time.h sys/types.h sys/stat.h])
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 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
865
866 # Generate values for the DLL version info
867 if test "$have_w32_system" = yes; then
868     BUILD_TIMESTAMP=`date --iso-8601=minutes`
869     changequote(,)dnl
870     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
871     changequote([,])dnl
872     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
873 fi
874 AC_SUBST(BUILD_REVISION)
875 AC_SUBST(BUILD_TIMESTAMP)
876 AC_SUBST(BUILD_FILEVERSION)
877
878 # Add a few constants to help porting to W32
879 AH_VERBATIM([SEPCONSTANTS],
880 [
881 /* Separators as used in $PATH.  */
882 #ifdef HAVE_DOSISH_SYSTEM
883 #define PATHSEP_C ';'
884 #else
885 #define PATHSEP_C ':'
886 #endif
887 ])
888
889 AH_BOTTOM([
890 /* Definition of GCC specific attributes.  */
891 #if __GNUC__ > 2
892 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
893 #else
894 # define GPGME_GCC_A_PURE
895 #endif
896
897 /* Under WindowsCE we need gpg-error's strerror macro.  */
898 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
899 ])
900
901
902 # Substitution used for gpgme-config
903 GPGME_CONFIG_LIBS="-lgpgme"
904 GPGME_CONFIG_CFLAGS=""
905 GPGME_CONFIG_HOST="$host"
906 AC_SUBST(GPGME_CONFIG_API_VERSION)
907 AC_SUBST(GPGME_CONFIG_LIBS)
908 AC_SUBST(GPGME_CONFIG_CFLAGS)
909 AC_SUBST(GPGME_CONFIG_HOST)
910
911 # Frob'da Variables
912 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
913            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
914 AC_SUBST(LTLIBOBJS)
915
916 # Some checks for gpgme-tool
917 AC_CHECK_HEADER([argp.h])
918 AC_CHECK_TYPES([error_t], [],
919    [AC_DEFINE([error_t], [int],
920    [Define to a type to use for `error_t' if it is not otherwise available.])],
921    [#include <errno.h>])
922
923
924 # A substitution to set generated files in a Emacs buffer to read-only.
925 AC_SUBST(emacs_local_vars_begin, ['Local Variables:'])
926 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
927 AC_SUBST(emacs_local_vars_end, ['End:'])
928
929
930 # Last check.
931 die=no
932 if test "$have_libassuan" = "no"; then
933    die=yes
934    AC_MSG_NOTICE([[
935 ***
936 *** You need libassuan to build this program with GPGSM support.
937 *** This library is for example available at
938 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
939 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
940 ***]])
941 fi
942
943 if test "$die" = "yes"; then
944     AC_MSG_ERROR([[
945 ***
946 *** Required libraries not found. Please consult the above messages
947 *** and install them before running configure again.
948 ***]])
949 fi
950
951
952 #
953 # Create config files
954
955 AC_CONFIG_FILES(Makefile src/Makefile
956                 tests/Makefile
957                 tests/gpg/Makefile
958                 tests/gpgsm/Makefile
959                 tests/opassuan/Makefile
960                 doc/Makefile complus/Makefile
961                 src/versioninfo.rc
962                 src/gpgme.h)
963 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
964 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
965 AC_OUTPUT
966
967 echo "
968         GPGME v${VERSION} has been configured as follows:
969
970         GnuPG path:      $GPG
971         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
972
973         GpgSM path:      $GPGSM
974         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
975
976         GpgConf path:    $GPGCONF
977         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
978
979         G13 path:        $G13
980         G13 version:     $G13_VERSION, min. $NEED_G13_VERSION
981
982         Assuan version:  $libassuan_version, min. $NEED_LIBASSUAN_VERSION
983
984         UI Server:       $uiserver
985         FD Passing:      $use_descriptor_passing
986
987         GPGME Pthread:   $have_pthread
988         GPGME Pth:       $have_pth
989 "