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