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