5d49c08f043b766a02732ef91104bb865d279e58
[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.1.9])
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=17
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=6
54 LIBGPGME_LT_REVISION=6
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 component_system=None
124 have_dosish_system=no
125 have_w32_system=no
126 build_w32_glib=no
127 build_w32_qt=no
128 case "${host}" in
129     *-mingw32*)
130         # special stuff for Windoze NT
131         have_dosish_system=yes
132         have_w32_system=yes
133         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
134         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
135         GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
136         #component_system='COM+'
137
138         AM_PATH_GLIB_2_0
139         AC_ARG_ENABLE(w32-glib,
140             AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
141                            build_w32_glib=$enableval)
142
143         # Check disabled, because the qt-dev packages in gpg4win do
144         # not provide any support for cross compilation.
145         # PKG_CHECK_MODULES(QT4_CORE, QtCore)
146
147         # Use it like this:
148         # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
149         AC_SUBST(QT4_CORE_CFLAGS)
150         AC_SUBST(QT4_CORE_LIBS)
151         AC_ARG_ENABLE(w32-qt,
152             AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
153                            build_w32_qt=$enableval)
154         ;;
155     *)
156         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
157         if test "$have_pth" = yes; then
158           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
159         fi
160         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
161         if test "$have_pthread" = yes; then
162           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
163         fi
164
165         # XXX: Probably use exec-prefix here?
166 #       GPG_DEFAULT='/usr/bin/gpg'
167 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
168 #       GPGCONF_DEFAULT='/usr/bin/gpgconf'
169         ;;
170 esac
171
172 if test "$have_dosish_system" = yes; then
173    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
174              [Defined if we run on some of the PCDOS like systems 
175               (DOS, Windoze. OS/2) with special properties like
176               no file modes])
177 fi
178 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
179
180 if test "$have_w32_system" = yes; then
181    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
182 fi
183 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
184 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
185 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
186
187 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
188 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
189
190
191 # Checks for header files.
192 AC_CHECK_HEADERS(sys/select.h)
193
194
195 # Type checks.
196 AC_C_INLINE
197 AC_CHECK_SIZEOF(unsigned int)
198 AC_SYS_LARGEFILE
199 AC_TYPE_OFF_T
200
201 # Checks for compiler features.
202 if test "$GCC" = yes; then
203     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
204     if test "$have_w32_system" = yes; then
205        CFLAGS="$CFLAGS -mms-bitfields"
206     fi
207 fi
208
209 # Network library fun.
210 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
211         [NETLIBS="-lnsl $NETLIBS"]))
212 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
213         [NETLIBS="-lsocket $NETLIBS"]))
214 AC_SUBST(NETLIBS)
215
216 # Checks for library functions.
217 AC_FUNC_FSEEKO
218
219 AC_REPLACE_FUNCS(vasprintf)
220 if test "$ac_cv_func_vasprintf" != yes; then
221   GNUPG_CHECK_VA_COPY
222 fi
223
224 # Try to find a thread-safe version of ttyname().
225 AC_REPLACE_FUNCS(ttyname_r)
226 if test "$ac_cv_func_ttyname_r" != yes; then
227   AC_MSG_WARN([
228 ***
229 *** ttyname() is not thread-safe and ttyname_r() does not exist
230 ***])
231 fi
232
233 # Try to find a thread-safe version of getenv().
234 have_thread_safe_getenv=no
235 jm_GLIBC21
236 if test $GLIBC21 = yes; then
237   have_thread_safe_getenv=yes
238 fi
239 if test $have_thread_safe_getenv = yes; then
240   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
241 fi
242 have_getenv_r=no
243 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
244 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
245   AC_MSG_WARN([
246 ***
247 *** getenv() is not thread-safe and getenv_r() does not exist
248 ***])
249 fi
250
251 # For converting time strings to seconds since Epoch, we need the timegm
252 # function.
253 AC_CHECK_FUNCS(timegm)
254 if test "$ac_cv_func_timegm" != yes; then
255   AC_MSG_WARN([
256 ***
257 *** timegm() not available - a non-thread-safe kludge will be used
258 *** and the TZ variable might be changed at runtime.
259 ***])
260 fi
261
262 # Checking for libgpg-error.
263 AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
264 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
265           [The default error source for GPGME.])
266
267
268
269 # Checks for system services
270 NEED_GPG_VERSION_DEFAULT=1.3.0
271 NEED_GPGSM_VERSION_DEFAULT=1.9.6
272 NEED_GPGCONF_VERSION_DEFAULT=2.0.4
273 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
274 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
275 NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
276 AC_ARG_WITH(gpg-version,
277             AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
278             NEED_GPG_VERSION=$withval)
279 if test "$NEED_GPG_VERSION" = "yes"; then
280   NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
281 fi
282 if test "$NEED_GPG_VERSION" = "no"; then
283   NEED_GPG_VERSION=0.0.0
284 fi
285 AC_ARG_WITH(gpgsm-version,
286             AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
287             NEED_GPGSM_VERSION=$withval)
288 if test "$NEED_GPGSM_VERSION" = "yes"; then
289   NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
290 fi
291 if test "$NEED_GPGSM_VERSION" = "no"; then
292   NEED_GPGSM_VERSION=0.0.0
293 fi
294 AC_ARG_WITH(gpgconf-version,
295             AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]),
296             NEED_GPGCONF_VERSION=$withval)
297 if test "$NEED_GPGCONF_VERSION" = "yes"; then
298   NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
299 fi
300 if test "$NEED_GPGCONF_VERSION" = "no"; then
301   NEED_GPGCONF_VERSION=0.0.0
302 fi
303
304 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
305                                      [Min. needed GnuPG version.])
306 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
307                                        [Min. needed GPGSM version.])
308 AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION",
309                                          [Min. needed GPGCONF version.])
310
311
312 NO_OVERRIDE=no
313 AC_ARG_WITH(gpg,
314             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
315             GPG=$withval, NO_OVERRIDE=yes)
316 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
317   GPG=
318   NO_OVERRIDE=yes
319   if test "$cross_compiling" != "yes"; then
320     AC_PATH_PROG(GPG, gpg)
321   fi
322   if test -z "$GPG"; then
323     GPG="$GPG_DEFAULT"
324   fi
325 fi
326 if test "$GPG" = no; then
327   if test "$NO_OVERRIDE" = "yes"; then
328     if test "$cross_compiling" != "yes"; then
329       AC_MSG_WARN([
330 ***
331 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
332 ***])
333     else
334       AC_MSG_ERROR([
335 ***
336 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
337 ***])
338     fi
339   fi
340 else
341   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
342   AC_SUBST(GPG)
343 fi
344 dnl Check for GnuPG version requirement.
345 GPG_VERSION=unknown
346 ok=maybe
347 if test -z "$GPG" -o "x$GPG" = "xno"; then
348   ok=no
349 else
350   if test "$cross_compiling" = "yes"; then
351     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
352     ok=no
353   else
354     if test ! -x "$GPG"; then
355       AC_MSG_WARN([GnuPG not executable, version check disabled])
356       ok=no
357     fi
358   fi
359 fi
360 if test "$ok" = "maybe"; then
361   AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
362   req_major=`echo $NEED_GPG_VERSION | \
363              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
364   req_minor=`echo $NEED_GPG_VERSION | \
365              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
366   req_micro=`echo $NEED_GPG_VERSION | \
367              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
368   GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
369   major=`echo $GPG_VERSION | \
370          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
371   minor=`echo $GPG_VERSION | \
372          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
373   micro=`echo $GPG_VERSION | \
374          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
375
376   if test "$major" -gt "$req_major"; then
377     ok=yes
378   else
379     if test "$major" -eq "$req_major"; then
380       if test "$minor" -gt "$req_minor"; then
381         ok=yes
382       else
383         if test "$minor" -eq "$req_minor"; then
384           if test "$micro" -ge "$req_micro"; then
385             ok=yes
386           fi
387         fi
388       fi
389     fi
390   fi
391   if test "$ok" = "yes"; then
392     AC_MSG_RESULT(yes)
393   else
394     AC_MSG_RESULT(no)
395     AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
396   fi
397 fi
398 run_gpg_test="$ok"
399 AC_ARG_ENABLE(gpg-test,
400   AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
401          run_gpg_test=$enableval)
402 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
403 AC_SUBST(GPG_PATH)
404
405 NO_OVERRIDE=no
406 AC_ARG_WITH(gpgsm,
407             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
408             GPGSM=$withval, NO_OVERRIDE=yes)
409 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
410   GPGSM=
411   NO_OVERRIDE=yes
412   if test "$cross_compiling" != "yes"; then
413     AC_PATH_PROG(GPGSM, gpgsm)
414   fi
415   if test -z "$GPGSM"; then
416     GPGSM="$GPGSM_DEFAULT"
417   fi
418 fi
419 if test "$GPGSM" = no; then
420   if test "$NO_OVERRIDE" = "yes"; then
421     if test "$cross_compiling" != "yes"; then
422       AC_MSG_WARN([
423 ***
424 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
425 ***])
426     else
427       AC_MSG_ERROR([
428 ***
429 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
430 ***])
431     fi
432   fi
433 else
434   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
435   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
436 fi
437 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
438
439
440 dnl Check for GPGSM version requirement.
441 GPGSM_VERSION=unknown
442 ok=maybe
443 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
444   ok=no
445 else
446   if test "$cross_compiling" = "yes"; then
447     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
448     ok=no
449   else
450     if test ! -x "$GPGSM"; then
451       AC_MSG_WARN([GPGSM not executable, version check disabled])
452       ok=no
453     fi
454   fi
455 fi
456 if test "$ok" = "maybe"; then
457   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
458   req_major=`echo $NEED_GPGSM_VERSION | \
459              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
460   req_minor=`echo $NEED_GPGSM_VERSION | \
461              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
462   req_micro=`echo $NEED_GPGSM_VERSION | \
463              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
464   GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
465   major=`echo $GPGSM_VERSION | \
466          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
467   minor=`echo $GPGSM_VERSION | \
468          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
469   micro=`echo $GPGSM_VERSION | \
470          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
471
472   if test "$major" -gt "$req_major"; then
473     ok=yes
474   else
475     if test "$major" -eq "$req_major"; then
476       if test "$minor" -gt "$req_minor"; then
477         ok=yes
478       else
479         if test "$minor" -eq "$req_minor"; then
480           if test "$micro" -ge "$req_micro"; then
481             ok=yes
482           fi
483         fi
484       fi
485     fi
486   fi
487   if test "$ok" = "yes"; then
488     AC_MSG_RESULT(yes)
489   else
490     AC_MSG_RESULT(no)
491     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
492   fi
493 fi
494 run_gpgsm_test="$ok"
495 AC_ARG_ENABLE(gpgsm-test,
496   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
497          run_gpgsm_test=$enableval)
498 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
499
500
501 NO_OVERRIDE=no
502 AC_ARG_WITH(gpgconf,
503             AC_HELP_STRING([--with-gpgconf=PATH],
504                            [use gpgconf binary at PATH]),
505             GPGCONF=$withval, NO_OVERRIDE=yes)
506 if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then
507   GPGCONF=
508   NO_OVERRIDE=yes
509   if test "$cross_compiling" != "yes"; then
510     AC_PATH_PROG(GPGCONF, gpgconf)
511   fi
512   if test -z "$GPGCONF"; then
513     GPGCONF="$GPGCONF_DEFAULT"
514   fi
515 fi
516 if test "$GPGCONF" = no; then
517   if test "$NO_OVERRIDE" = "yes"; then
518     if test "$cross_compiling" != "yes"; then
519       AC_MSG_WARN([
520 ***
521 *** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it
522 ***])
523     else
524       AC_MSG_ERROR([
525 ***
526 *** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH
527 ***])
528     fi
529   fi
530 else
531   AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.])
532   AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled])
533 fi
534 AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no")
535
536 dnl Check for GPGCONF version requirement.
537 GPGCONF_VERSION=unknown
538 ok=maybe
539 if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then
540   ok=no
541 else
542   if test "$cross_compiling" = "yes"; then
543     AC_MSG_WARN([GPGCONF version can not be checked when cross compiling])
544     ok=no
545   else
546     if test ! -x "$GPGCONF"; then
547       AC_MSG_WARN([GPGCONF not executable, version check disabled])
548       ok=no
549     fi
550   fi
551 fi
552 if test "$ok" = "maybe"; then
553   AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION)
554   req_major=`echo $NEED_GPGCONF_VERSION | \
555              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
556   req_minor=`echo $NEED_GPGCONF_VERSION | \
557              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
558   req_micro=`echo $NEED_GPGCONF_VERSION | \
559              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
560   GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
561   major=`echo $GPGCONF_VERSION | \
562          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
563   minor=`echo $GPGCONF_VERSION | \
564          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
565   micro=`echo $GPGCONF_VERSION | \
566          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
567
568   if test "$major" -gt "$req_major"; then
569     ok=yes
570   else
571     if test "$major" -eq "$req_major"; then
572       if test "$minor" -gt "$req_minor"; then
573         ok=yes
574       else
575         if test "$minor" -eq "$req_minor"; then
576           if test "$micro" -ge "$req_micro"; then
577             ok=yes
578           fi
579         fi
580       fi
581     fi
582   fi
583   if test "$ok" = "yes"; then
584     AC_MSG_RESULT(yes)
585   else
586     AC_MSG_RESULT(no)
587     AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION])
588   fi
589 fi
590 run_gpgconf_test="$ok"
591 AC_ARG_ENABLE(gpgconf-test,
592   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]),
593          run_gpgconf_test=$enableval)
594 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
595
596 # Only build if supported.
597 AM_CONDITIONAL(BUILD_GPGCONF, test "$GPGCONF" != "no")
598 if test "$GPGCONF" != "no"; then
599   AC_DEFINE(HAVE_GPGCONF, 1,
600             [Defined if we are building with gpgconf support.])
601 fi
602
603
604 # FIXME: Only build if supported.
605 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
606 if test "$GPGSM" != "no"; then
607   AC_DEFINE(HAVE_ASSUAN_H, 1,
608             [Defined if we are building with assuan support.])
609 fi
610
611 # Check for funopen
612 AC_CHECK_FUNCS(funopen)
613 if test $ac_cv_func_funopen != yes; then
614     # No funopen but we can implement that in terms of fopencookie.
615     AC_CHECK_FUNCS(fopencookie)
616     if test $ac_cv_func_fopencookie = yes; then
617         AC_REPLACE_FUNCS(funopen)
618     else
619         AC_MSG_WARN([
620 ***
621 *** No implementation of fopencookie or funopen available
622 ***])
623     fi
624 fi
625
626 # More assuan replacement functions.
627 AC_REPLACE_FUNCS(isascii)
628 AC_REPLACE_FUNCS(putc_unlocked)
629 AC_REPLACE_FUNCS(memrchr)
630 AC_REPLACE_FUNCS(stpcpy)
631 # Check for unistd.h for setenv replacement function.
632 AC_CHECK_HEADERS(unistd.h)
633 AC_REPLACE_FUNCS(setenv)
634
635 # More assuan checks.
636 AC_CHECK_HEADERS([sys/uio.h])
637
638 # Assuan check for descriptor passing.
639 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
640                 [supports_descriptor_passing=yes],
641                 [supports_descriptor_passing=no
642                  AC_MSG_WARN([
643 ***
644 *** Data structure for sending ancillary data missing.
645 *** Descriptor passing won't work.
646 ***])],[
647 #include <stdlib.h>
648 #include <stddef.h>
649 #include <stdio.h>
650 #include <sys/types.h>
651 #include <sys/socket.h>
652 #include <sys/un.h>
653 #if HAVE_SYS_UIO_H
654 #include <sys/uio.h>
655 #endif
656 #include <unistd.h>
657        ])
658
659 AC_ARG_ENABLE(fd-passing,
660   AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
661   use_descriptor_passing=$enableval)
662
663 if test "$supports_descriptor_passing" != "yes"; then
664   use_descriptor_passing=no
665 fi
666
667 if test "$use_descriptor_passing" = "yes"; then
668 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
669           [Defined if descriptor passing is enabled and supported])
670 fi
671
672 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
673
674 # Assuan check for the getsockopt SO_PEERCRED
675 AC_MSG_CHECKING(for SO_PEERCRED)
676 AC_CACHE_VAL(assuan_cv_sys_so_peercred,
677       [AC_TRY_COMPILE([#include <sys/socket.h>], 
678          [struct ucred cr; 
679           int cl = sizeof cr;
680           getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
681           assuan_cv_sys_so_peercred=yes,
682           assuan_cv_sys_so_peercred=no)
683        ])
684 AC_MSG_RESULT($assuan_cv_sys_so_peercred) 
685 if test $assuan_cv_sys_so_peercred = yes; then
686   AC_DEFINE(HAVE_SO_PEERCRED, 1,
687             [Defined if SO_PEERCRED is supported (Linux specific)])
688 fi
689
690 if test "$have_w32_system" = yes; then
691    NETLIBS="-lws2_32 $NETLIBS"
692 fi
693
694 # End of assuan checks.
695
696 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
697
698 # Generate values for the DLL version info
699 if test "$have_w32_system" = yes; then
700     BUILD_TIMESTAMP=`date --iso-8601=minutes`
701     changequote(,)dnl 
702     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
703     changequote([,])dnl
704     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
705 fi
706 AC_SUBST(BUILD_REVISION)
707 AC_SUBST(BUILD_TIMESTAMP)
708 AC_SUBST(BUILD_FILEVERSION)
709
710 # Add a few constants to help porting to W32
711 AH_VERBATIM([SEPCONSTANTS],
712 [
713 /* Separators as used in $PATH.  */
714 #ifdef HAVE_DOSISH_SYSTEM
715 #define PATHSEP_C ';'
716 #else
717 #define PATHSEP_C ':'
718 #endif
719 ])
720
721 AH_BOTTOM([
722 /* Definition of GCC specific attributes.  */
723 #if __GNUC__ > 2 
724 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
725 #else
726 # define GPGME_GCC_A_PURE
727 #endif
728 ])
729
730
731 # Substitution used for gpgme-config 
732 GPGME_CONFIG_LIBS="-lgpgme"
733 GPGME_CONFIG_CFLAGS=""
734 AC_SUBST(GPGME_CONFIG_API_VERSION)
735 AC_SUBST(GPGME_CONFIG_LIBS)
736 AC_SUBST(GPGME_CONFIG_CFLAGS)
737
738 # Frob'da Variables
739 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
740            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
741 AC_SUBST(LTLIBOBJS)
742
743 #
744 # Create config files 
745
746 AC_CONFIG_FILES(Makefile assuan/Makefile src/Makefile
747                 tests/Makefile 
748                 tests/gpg/Makefile
749                 tests/gpgsm/Makefile
750                 tests/opassuan/Makefile
751                 doc/Makefile complus/Makefile
752                 src/versioninfo.rc
753                 src/gpgme.h)
754 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
755 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
756 AC_OUTPUT
757
758 echo "
759         GPGME v${VERSION} has been configured as follows:
760
761         GnuPG path:      $GPG
762         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
763
764         GpgSM path:      $GPGSM
765         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
766
767         GpgConf path:    $GPGCONF
768         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
769
770         GPGME Pthread:   $have_pthread
771         GPGME Pth:       $have_pth
772 "