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