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