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
5 # This file is part of GPGME.
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.
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.
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
21 # (Process this file with autoconf to produce a configure script.)
23 min_automake_version="1.9.3"
25 # Version number: Remember to change it immediately *after* a release.
26 # Make sure to run "svn up" before a "make dist".
27 # See below for the LT versions.
29 # The CVS version is usually the next intended release version with
30 # the string "-cvs" appended. The reason for this is that tests for a
31 # specific feature can already be done under the assumption that the
32 # CVS version is the most recent one in a branch. To disable the CVS
33 # version for the real release, just comment out the my_iscvs macro.
34 # Note, that we are now using Subversion instead of CVS and append the
35 # SVN revision number to the "cvs" suffix. To make this most useful
36 # for snapshot releases please do an "svn up" right before recreating
37 # the configure script, so that a proper revision number for all files
38 # is available when running a "make distcheck".
39 m4_define(my_version, [1.1.5])
40 m4_define(my_iscvs, yes)
41 AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit(
42 [$Revision$],[Ra-z $:])]),
43 [bug-gpgme@gnupg.org])
45 # LT Version numbers, remember to change them just *before* a release.
46 # (Code changed: REVISION++)
47 # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
48 # (Interfaces added: AGE++)
49 # (Interfaces removed/changed: AGE=0)
51 LIBGPGME_LT_CURRENT=17
52 # Subtract 2 from this value if you want to make the LFS transition an
53 # ABI break. [Note to self: Remove this comment with the next regular break.]
55 LIBGPGME_LT_REVISION=4
57 # If the API is changed in an incompatible way: increment the next counter.
58 GPGME_CONFIG_API_VERSION=1
59 ##############################################
63 VERSION=$PACKAGE_VERSION
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)
73 # Enable GNU extensions on systems that have them.
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. */
87 AC_SUBST(LIBGPGME_LT_CURRENT)
88 AC_SUBST(LIBGPGME_LT_AGE)
89 AC_SUBST(LIBGPGME_LT_REVISION)
93 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
94 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
96 # Don't default to build static libs.
102 # For now we hardcode the use of version scripts. It would be better
103 # to write a test for this or even implement this within libtool.
104 have_ld_version_script=no
107 have_ld_version_script=yes
110 have_ld_version_script=yes
113 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
117 component_system=None
118 have_dosish_system=no
122 # special stuff for Windoze NT
123 have_dosish_system=yes
125 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
126 GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
127 #component_system='COM+'
130 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
131 if test "$have_pth" = yes; then
132 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
134 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
135 if test "$have_pthread" = yes; then
136 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
139 # XXX: Probably use exec-prefix here?
140 # GPG_DEFAULT='/usr/bin/gpg'
141 # GPGSM_DEFAULT='/usr/bin/gpgsm'
145 if test "$have_dosish_system" = yes; then
146 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
147 [Defined if we run on some of the PCDOS like systems
148 (DOS, Windoze. OS/2) with special properties like
151 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
153 if test "$have_w32_system" = yes; then
154 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
156 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
160 AC_ARG_ENABLE(w32-glib,
161 AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
162 build_w32_glib=$withval)
163 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
165 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
166 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
169 # Checks for header files.
170 AC_CHECK_HEADERS(sys/select.h)
175 AC_CHECK_SIZEOF(unsigned int)
179 # Checks for compiler features.
180 if test "$GCC" = yes; then
181 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
182 if test "$have_w32_system" = yes; then
183 CFLAGS="$CFLAGS -mms-bitfields"
187 # Network library fun.
188 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
189 [NETLIBS="-lnsl $NETLIBS"]))
190 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
191 [NETLIBS="-lsocket $NETLIBS"]))
194 # Checks for library functions.
197 AC_REPLACE_FUNCS(vasprintf)
198 if test "$ac_cv_func_vasprintf" != yes; then
202 # Try to find a thread-safe version of ttyname().
203 AC_REPLACE_FUNCS(ttyname_r)
204 if test "$ac_cv_func_ttyname_r" != yes; then
207 *** ttyname() is not thread-safe and ttyname_r() does not exist
211 # Try to find a thread-safe version of getenv().
212 have_thread_safe_getenv=no
214 if test $GLIBC21 = yes; then
215 have_thread_safe_getenv=yes
217 if test $have_thread_safe_getenv = yes; then
218 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
221 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
222 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
225 *** getenv() is not thread-safe and getenv_r() does not exist
229 # For converting time strings to seconds since Epoch, we need the timegm
231 AC_CHECK_FUNCS(timegm)
232 if test "$ac_cv_func_timegm" != yes; then
235 *** timegm() not available - a non-thread-safe kludge will be used
236 *** and the TZ variable might be changed at runtime.
240 # Checking for libgpg-error.
241 AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
242 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
243 [The default error source for GPGME.])
247 # Checks for system services
248 NEED_GPG_VERSION_DEFAULT=1.3.0
249 NEED_GPGSM_VERSION_DEFAULT=1.9.6
250 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
251 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
252 AC_ARG_WITH(gpg-version,
253 AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
254 NEED_GPG_VERSION=$withval)
255 if test "$NEED_GPG_VERSION" = "yes"; then
256 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
258 if test "$NEED_GPG_VERSION" = "no"; then
259 NEED_GPG_VERSION=0.0.0
261 AC_ARG_WITH(gpgsm-version,
262 AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
263 NEED_GPGSM_VERSION=$withval)
264 if test "$NEED_GPGSM_VERSION" = "yes"; then
265 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
267 if test "$NEED_GPGSM_VERSION" = "no"; then
268 NEED_GPGSM_VERSION=0.0.0
271 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
272 [Min. needed GnuPG version.])
273 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
274 [Min. needed GPGSM version.])
279 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
280 GPG=$withval, NO_OVERRIDE=yes)
281 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
284 if test "$cross_compiling" != "yes"; then
285 AC_PATH_PROG(GPG, gpg)
287 if test -z "$GPG"; then
291 if test "$GPG" = no; then
292 if test "$NO_OVERRIDE" = "yes"; then
293 if test "$cross_compiling" != "yes"; then
296 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
301 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
306 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
309 dnl Check for GnuPG version requirement.
312 if test -z "$GPG" -o "x$GPG" = "xno"; then
315 if test "$cross_compiling" = "yes"; then
316 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
319 if test ! -x "$GPG"; then
320 AC_MSG_WARN([GnuPG not executable, version check disabled])
325 if test "$ok" = "maybe"; then
326 AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
327 req_major=`echo $NEED_GPG_VERSION | \
328 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
329 req_minor=`echo $NEED_GPG_VERSION | \
330 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
331 req_micro=`echo $NEED_GPG_VERSION | \
332 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
333 GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
334 major=`echo $GPG_VERSION | \
335 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
336 minor=`echo $GPG_VERSION | \
337 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
338 micro=`echo $GPG_VERSION | \
339 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
341 if test "$major" -gt "$req_major"; then
344 if test "$major" -eq "$req_major"; then
345 if test "$minor" -gt "$req_minor"; then
348 if test "$minor" -eq "$req_minor"; then
349 if test "$micro" -ge "$req_micro"; then
356 if test "$ok" = "yes"; then
360 AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
364 AC_ARG_ENABLE(gpg-test,
365 AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
366 run_gpg_test=$enableval)
367 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
372 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
373 GPGSM=$withval, NO_OVERRIDE=yes)
374 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
377 if test "$cross_compiling" != "yes"; then
378 AC_PATH_PROG(GPGSM, gpgsm)
380 if test -z "$GPGSM"; then
381 GPGSM="$GPGSM_DEFAULT"
384 if test "$GPGSM" = no; then
385 if test "$NO_OVERRIDE" = "yes"; then
386 if test "$cross_compiling" != "yes"; then
389 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
394 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
399 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
400 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
402 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
405 dnl Check for GPGSM version requirement.
406 GPGSM_VERSION=unknown
408 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
411 if test "$cross_compiling" = "yes"; then
412 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
415 if test ! -x "$GPGSM"; then
416 AC_MSG_WARN([GPGSM not executable, version check disabled])
421 if test "$ok" = "maybe"; then
422 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
423 req_major=`echo $NEED_GPGSM_VERSION | \
424 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
425 req_minor=`echo $NEED_GPGSM_VERSION | \
426 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
427 req_micro=`echo $NEED_GPGSM_VERSION | \
428 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
429 GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
430 major=`echo $GPGSM_VERSION | \
431 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
432 minor=`echo $GPGSM_VERSION | \
433 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
434 micro=`echo $GPGSM_VERSION | \
435 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
437 if test "$major" -gt "$req_major"; then
440 if test "$major" -eq "$req_major"; then
441 if test "$minor" -gt "$req_minor"; then
444 if test "$minor" -eq "$req_minor"; then
445 if test "$micro" -ge "$req_micro"; then
452 if test "$ok" = "yes"; then
456 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
460 AC_ARG_ENABLE(gpgsm-test,
461 AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
462 run_gpgsm_test=$enableval)
463 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
466 # FIXME: Only build if supported.
467 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
468 if test "$GPGSM" != "no"; then
469 AC_DEFINE(HAVE_ASSUAN_H, 1,
470 [Defined if we are building with assuan support.])
474 AC_CHECK_FUNCS(funopen)
475 if test $ac_cv_func_funopen != yes; then
476 # No funopen but we can implement that in terms of fopencookie.
477 AC_CHECK_FUNCS(fopencookie)
478 if test $ac_cv_func_fopencookie = yes; then
479 AC_REPLACE_FUNCS(funopen)
483 *** No implementation of fopencookie or funopen available
488 # More assuan replacement functions.
489 AC_REPLACE_FUNCS(isascii)
490 AC_REPLACE_FUNCS(putc_unlocked)
491 AC_REPLACE_FUNCS(memrchr)
492 AC_REPLACE_FUNCS(stpcpy)
493 # Check for unistd.h for setenv replacement function.
494 AC_CHECK_HEADERS(unistd.h)
495 AC_REPLACE_FUNCS(setenv)
497 # More assuan checks.
498 AC_CHECK_HEADERS([sys/uio.h])
500 # Assuan check for descriptor passing.
501 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
502 [supports_descriptor_passing=yes],
503 [supports_descriptor_passing=no
506 *** Data structure for sending ancillary data missing.
507 *** Descriptor passing won't work.
512 #include <sys/types.h>
513 #include <sys/socket.h>
521 AC_ARG_ENABLE(fd-passing,
522 AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
523 use_descriptor_passing=$enableval)
525 if test "$supports_descriptor_passing" != "yes"; then
526 use_descriptor_passing=no
529 if test "$use_descriptor_passing" = "yes"; then
530 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
531 [Defined if descriptor passing is enabled and supported])
534 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
536 # Assuan check for the getsockopt SO_PEERCRED
537 AC_MSG_CHECKING(for SO_PEERCRED)
538 AC_CACHE_VAL(assuan_cv_sys_so_peercred,
539 [AC_TRY_COMPILE([#include <sys/socket.h>],
542 getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
543 assuan_cv_sys_so_peercred=yes,
544 assuan_cv_sys_so_peercred=no)
546 AC_MSG_RESULT($assuan_cv_sys_so_peercred)
547 if test $assuan_cv_sys_so_peercred = yes; then
548 AC_DEFINE(HAVE_SO_PEERCRED, 1,
549 [Defined if SO_PEERCRED is supported (Linux specific)])
552 if test "$have_w32_system" = yes; then
553 NETLIBS="-lws2_32 $NETLIBS"
556 # End of assuan checks.
558 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
560 # Make the version number in gpgme/gpgme.h the same as the one here.
561 # (this is easier than to have a *.in file just for one substitution)
562 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
564 # Generate values for the DLL version info
566 BUILD_REVISION="`echo '$Revision$' | sed 's/[^0-9]//g'`"
568 test -z "$BUILD_REVISION" && BUILD_REVISION="0"
569 if test "$have_w32_system" = yes; then
570 BUILD_TIMESTAMP=`date --iso-8601=minutes`
572 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
574 BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
576 AC_SUBST(BUILD_REVISION)
577 AC_SUBST(BUILD_TIMESTAMP)
578 AC_SUBST(BUILD_FILEVERSION)
580 # Add a few constants to help porting to W32
581 AH_VERBATIM([SEPCONSTANTS],
583 /* Separators as used in $PATH. */
584 #ifdef HAVE_DOSISH_SYSTEM
585 #define PATHSEP_C ';'
587 #define PATHSEP_C ':'
592 /* Definition of GCC specific attributes. */
594 # define GPGME_GCC_A_PURE __attribute__ ((__pure__))
596 # define GPGME_GCC_A_PURE
601 # Substitution used for gpgme-config
602 GPGME_CONFIG_LIBS="-lgpgme"
603 GPGME_CONFIG_CFLAGS=""
604 AC_SUBST(GPGME_CONFIG_API_VERSION)
605 AC_SUBST(GPGME_CONFIG_LIBS)
606 AC_SUBST(GPGME_CONFIG_CFLAGS)
609 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
610 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
614 # Create config files
616 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
617 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
618 doc/Makefile complus/Makefile
619 gpgme/versioninfo.rc)
620 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
621 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
625 GPGME v${VERSION} has been configured as follows:
628 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
631 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
633 GPGME Pthread: $have_pthread