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