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