2009-10-30 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 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
70 AM_MAINTAINER_MODE
71 AC_CANONICAL_HOST
72
73 # Enable GNU extensions on systems that have them.
74 AC_GNU_SOURCE
75
76 AH_VERBATIM([_REENTRANT],
77 [/* To allow the use of GPGME in multithreaded programs we have to use
78   special features from the library.
79   IMPORTANT: gpgme is not yet fully reentrant and you should use it
80   only from one thread.  */
81 #ifndef _REENTRANT
82 # define _REENTRANT 1
83 #endif])
84
85 AC_PROG_CC
86 AC_PROG_CXX
87
88 AC_SUBST(LIBGPGME_LT_CURRENT)
89 AC_SUBST(LIBGPGME_LT_AGE)
90 AC_SUBST(LIBGPGME_LT_REVISION)
91
92 AC_SUBST(PACKAGE)
93 AC_SUBST(VERSION)
94 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
95 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
96
97 # Don't default to build static libs.
98 AC_DISABLE_STATIC
99 AC_LIBTOOL_WIN32_DLL
100 AC_LIBTOOL_RC
101 AC_PROG_LIBTOOL
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 # Only build if supported.
638 AM_CONDITIONAL(BUILD_GPGCONF, test "$GPGCONF" != "no")
639 if test "$GPGCONF" != "no"; then
640   AC_DEFINE(HAVE_GPGCONF, 1,
641             [Defined if we are building with gpgconf support.])
642 fi
643
644
645 NO_OVERRIDE=no
646 AC_ARG_WITH(g13,
647             AC_HELP_STRING([--with-g13=PATH],
648                            [use g13 binary at PATH]),
649             G13=$withval, NO_OVERRIDE=yes)
650 if test "$NO_OVERRIDE" = "yes" || test "$G13" = "yes"; then
651   G13=
652   NO_OVERRIDE=yes
653   if test "$cross_compiling" != "yes"; then
654     AC_PATH_PROG(G13, g13)
655   fi
656   if test -z "$G13"; then
657     G13="$G13_DEFAULT"
658   fi
659 fi
660 if test "$G13" = no; then
661   if test "$NO_OVERRIDE" = "yes"; then
662     if test "$cross_compiling" != "yes"; then
663       AC_MSG_WARN([
664 ***
665 *** Could not find g13, install g13 or use --with-g13=PATH to enable it
666 ***])
667     else
668       AC_MSG_ERROR([
669 ***
670 *** Can not determine path to g13 when cross-compiling, use --with-g13=PATH
671 ***])
672     fi
673   fi
674 else
675   AC_DEFINE_UNQUOTED(G13_PATH, "$G13", [Path to the G13 binary.])
676   AC_DEFINE(ENABLE_G13,1,[Whether G13 support is enabled])
677 fi
678 AM_CONDITIONAL(HAVE_G13, test "$G13" != "no")
679
680 dnl Check for G13 version requirement.
681 G13_VERSION=unknown
682 ok=maybe
683 if test -z "$G13" -o "x$G13" = "xno"; then
684   ok=no
685 else
686   if test "$cross_compiling" = "yes"; then
687     AC_MSG_WARN([G13 version can not be checked when cross compiling])
688     ok=no
689   else
690     if test ! -x "$G13"; then
691       AC_MSG_WARN([G13 not executable, version check disabled])
692       ok=no
693     fi
694   fi
695 fi
696 if test "$ok" = "maybe"; then
697   AC_MSG_CHECKING(for G13 >= $NEED_G13_VERSION)
698   req_major=`echo $NEED_G13_VERSION | \
699              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
700   req_minor=`echo $NEED_G13_VERSION | \
701              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
702   req_micro=`echo $NEED_G13_VERSION | \
703              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
704   G13_VERSION=`$G13 --version | sed -n '1 s/.*\ \([[0-9]].*\)/\1/p'`
705   major=`echo $G13_VERSION | \
706          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
707   minor=`echo $G13_VERSION | \
708          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
709   micro=`echo $G13_VERSION | \
710          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
711
712   if test "$major" -gt "$req_major"; then
713     ok=yes
714   else
715     if test "$major" -eq "$req_major"; then
716       if test "$minor" -gt "$req_minor"; then
717         ok=yes
718       else
719         if test "$minor" -eq "$req_minor"; then
720           if test "$micro" -ge "$req_micro"; then
721             ok=yes
722           fi
723         fi
724       fi
725     fi
726   fi
727   if test "$ok" = "yes"; then
728     AC_MSG_RESULT(yes)
729   else
730     AC_MSG_RESULT(no)
731     AC_MSG_WARN([G13 must be at least version $NEED_G13_VERSION])
732   fi
733 fi
734 run_g13_test="$ok"
735 AC_ARG_ENABLE(g13-test,
736   AC_HELP_STRING([--disable-g13-test], [disable G13 run test]),
737          run_g13_test=$enableval)
738 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
739
740 # Only build if supported.
741 AM_CONDITIONAL(BUILD_G13, test "$G13" != "no")
742 if test "$G13" != "no"; then
743   AC_DEFINE(HAVE_G13, 1,
744             [Defined if we are building with g13 support.])
745 fi
746
747
748 # Check for funopen
749 AC_CHECK_FUNCS(funopen)
750 if test $ac_cv_func_funopen != yes; then
751     # No funopen but we can implement that in terms of fopencookie.
752     AC_CHECK_FUNCS(fopencookie)
753     if test $ac_cv_func_fopencookie = yes; then
754         AC_REPLACE_FUNCS(funopen)
755     else
756         AC_MSG_WARN([
757 ***
758 *** No implementation of fopencookie or funopen available
759 ***])
760     fi
761 fi
762
763 # Replacement functions.
764 AC_REPLACE_FUNCS(stpcpy)
765 # Check for unistd.h for setenv replacement function.
766 AC_CHECK_HEADERS(unistd.h)
767 AC_REPLACE_FUNCS(setenv)
768
769 # Assuan check for descriptor passing.
770 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
771                 [supports_descriptor_passing=yes],
772                 [supports_descriptor_passing=no
773                  AC_MSG_WARN([
774 ***
775 *** Data structure for sending ancillary data missing.
776 *** Descriptor passing won't work.
777 ***])],[
778 #include <stdlib.h>
779 #include <stddef.h>
780 #include <stdio.h>
781 #include <sys/types.h>
782 #include <sys/socket.h>
783 #include <sys/un.h>
784 #if HAVE_SYS_UIO_H
785 #include <sys/uio.h>
786 #endif
787 #include <unistd.h>
788        ])
789
790 AC_ARG_ENABLE(fd-passing,
791   AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
792   use_descriptor_passing=$enableval)
793
794 if test "$supports_descriptor_passing" != "yes"; then
795   use_descriptor_passing=no
796 fi
797
798 if test "$use_descriptor_passing" = "yes"; then
799 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
800           [Defined if descriptor passing is enabled and supported])
801 fi
802
803 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
804
805
806 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
807
808 # Generate values for the DLL version info
809 if test "$have_w32_system" = yes; then
810     BUILD_TIMESTAMP=`date --iso-8601=minutes`
811     changequote(,)dnl 
812     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
813     changequote([,])dnl
814     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
815 fi
816 AC_SUBST(BUILD_REVISION)
817 AC_SUBST(BUILD_TIMESTAMP)
818 AC_SUBST(BUILD_FILEVERSION)
819
820 # Add a few constants to help porting to W32
821 AH_VERBATIM([SEPCONSTANTS],
822 [
823 /* Separators as used in $PATH.  */
824 #ifdef HAVE_DOSISH_SYSTEM
825 #define PATHSEP_C ';'
826 #else
827 #define PATHSEP_C ':'
828 #endif
829 ])
830
831 AH_BOTTOM([
832 /* Definition of GCC specific attributes.  */
833 #if __GNUC__ > 2 
834 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
835 #else
836 # define GPGME_GCC_A_PURE
837 #endif
838 ])
839
840
841 # Substitution used for gpgme-config 
842 GPGME_CONFIG_LIBS="-lgpgme"
843 GPGME_CONFIG_CFLAGS=""
844 AC_SUBST(GPGME_CONFIG_API_VERSION)
845 AC_SUBST(GPGME_CONFIG_LIBS)
846 AC_SUBST(GPGME_CONFIG_CFLAGS)
847
848 # Frob'da Variables
849 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
850            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
851 AC_SUBST(LTLIBOBJS)
852
853 # Some checks for gpgme-tool
854 AC_CHECK_HEADER([argp.h])
855 AC_CHECK_TYPES([error_t], [],
856    [AC_DEFINE([error_t], [int],
857    [Define to a type to use for `error_t' if it is not otherwise available.])],
858    [#include <errno.h>])
859
860
861 # Last check.
862 die=no
863 if test "$require_libassuan" = "no"; then
864    die=yes
865    AC_MSG_NOTICE([[
866 ***
867 *** You need libassuan to build this program with GPGSM support.
868 *** This library is for example available at
869 ***   ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
870 *** (at least version $NEED_LIBASSUAN_VERSION is required).
871 ***]])
872 fi
873
874 if test "$die" = "yes"; then
875     AC_MSG_ERROR([[
876 ***
877 *** Required libraries not found. Please consult the above messages
878 *** and install them before running configure again.
879 ***]])
880 fi
881
882
883 #
884 # Create config files 
885
886 AC_CONFIG_FILES(Makefile src/Makefile
887                 tests/Makefile 
888                 tests/gpg/Makefile
889                 tests/gpgsm/Makefile
890                 tests/opassuan/Makefile
891                 doc/Makefile complus/Makefile
892                 src/versioninfo.rc
893                 src/gpgme.h)
894 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
895 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
896 AC_OUTPUT
897
898 echo "
899         GPGME v${VERSION} has been configured as follows:
900
901         GnuPG path:      $GPG
902         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
903
904         GpgSM path:      $GPGSM
905         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
906
907         GpgConf path:    $GPGCONF
908         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
909
910         G13 path:        $G13
911         G13 version:     $G13_VERSION, min. $NEED_G13_VERSION
912
913         Assuan version:  $LIBASSUAN_VERSION
914
915         GPGME Pthread:   $have_pthread
916         GPGME Pth:       $have_pth
917 "