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