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