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