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" and "./autogen.sh --force"
27 # before a "make dist". See below for the LT versions.
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.6])
35 m4_define(my_issvn, [yes])
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], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]),
40 [bug-gpgme@gnupg.org])
43 # LT Version numbers, remember to change them just *before* a release.
44 # (Code changed: REVISION++)
45 # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
46 # (Interfaces added: AGE++)
47 # (Interfaces removed/changed: AGE=0)
49 LIBGPGME_LT_CURRENT=17
50 # Subtract 2 from this value if you want to make the LFS transition an
51 # ABI break. [Note to self: Remove this comment with the next regular break.]
53 LIBGPGME_LT_REVISION=4
55 # If the API is changed in an incompatible way: increment the next counter.
56 GPGME_CONFIG_API_VERSION=1
57 ##############################################
60 BUILD_REVISION=svn_revision
62 VERSION=$PACKAGE_VERSION
64 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
65 dnl FIXME: Enable this with autoconf 2.59.
66 dnl AC_CONFIG_MACRO_DIR(m4)
67 AM_CONFIG_HEADER(config.h)
68 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
72 # Enable GNU extensions on systems that have them.
75 AH_VERBATIM([_REENTRANT],
76 [/* To allow the use of GPGME in multithreaded programs we have to use
77 special features from the library.
78 IMPORTANT: gpgme is not yet fully reentrant and you should use it
79 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
124 # special stuff for Windoze NT
125 have_dosish_system=yes
127 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
128 GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
129 #component_system='COM+'
132 AC_ARG_ENABLE(w32-glib,
133 AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
134 build_w32_glib=$enableval)
136 # Check disabled, because the qt-dev packages in gpg4win do
137 # not provide any support for cross compilation.
138 # PKG_CHECK_MODULES(QT4_CORE, QtCore)
141 # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
142 AC_SUBST(QT4_CORE_CFLAGS)
143 AC_SUBST(QT4_CORE_LIBS)
144 AC_ARG_ENABLE(w32-qt,
145 AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
146 build_w32_qt=$enableval)
149 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
150 if test "$have_pth" = yes; then
151 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
153 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
154 if test "$have_pthread" = yes; then
155 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
158 # XXX: Probably use exec-prefix here?
159 # GPG_DEFAULT='/usr/bin/gpg'
160 # GPGSM_DEFAULT='/usr/bin/gpgsm'
164 if test "$have_dosish_system" = yes; then
165 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
166 [Defined if we run on some of the PCDOS like systems
167 (DOS, Windoze. OS/2) with special properties like
170 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
172 if test "$have_w32_system" = yes; then
173 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
175 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
176 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
177 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
179 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
180 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
183 # Checks for header files.
184 AC_CHECK_HEADERS(sys/select.h)
189 AC_CHECK_SIZEOF(unsigned int)
193 # Checks for compiler features.
194 if test "$GCC" = yes; then
195 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
196 if test "$have_w32_system" = yes; then
197 CFLAGS="$CFLAGS -mms-bitfields"
201 # Network library fun.
202 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
203 [NETLIBS="-lnsl $NETLIBS"]))
204 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
205 [NETLIBS="-lsocket $NETLIBS"]))
208 # Checks for library functions.
211 AC_REPLACE_FUNCS(vasprintf)
212 if test "$ac_cv_func_vasprintf" != yes; then
216 # Try to find a thread-safe version of ttyname().
217 AC_REPLACE_FUNCS(ttyname_r)
218 if test "$ac_cv_func_ttyname_r" != yes; then
221 *** ttyname() is not thread-safe and ttyname_r() does not exist
225 # Try to find a thread-safe version of getenv().
226 have_thread_safe_getenv=no
228 if test $GLIBC21 = yes; then
229 have_thread_safe_getenv=yes
231 if test $have_thread_safe_getenv = yes; then
232 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
235 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
236 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
239 *** getenv() is not thread-safe and getenv_r() does not exist
243 # For converting time strings to seconds since Epoch, we need the timegm
245 AC_CHECK_FUNCS(timegm)
246 if test "$ac_cv_func_timegm" != yes; then
249 *** timegm() not available - a non-thread-safe kludge will be used
250 *** and the TZ variable might be changed at runtime.
254 # Checking for libgpg-error.
255 AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
256 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
257 [The default error source for GPGME.])
261 # Checks for system services
262 NEED_GPG_VERSION_DEFAULT=1.3.0
263 NEED_GPGSM_VERSION_DEFAULT=1.9.6
264 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
265 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
266 AC_ARG_WITH(gpg-version,
267 AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
268 NEED_GPG_VERSION=$withval)
269 if test "$NEED_GPG_VERSION" = "yes"; then
270 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
272 if test "$NEED_GPG_VERSION" = "no"; then
273 NEED_GPG_VERSION=0.0.0
275 AC_ARG_WITH(gpgsm-version,
276 AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
277 NEED_GPGSM_VERSION=$withval)
278 if test "$NEED_GPGSM_VERSION" = "yes"; then
279 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
281 if test "$NEED_GPGSM_VERSION" = "no"; then
282 NEED_GPGSM_VERSION=0.0.0
285 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
286 [Min. needed GnuPG version.])
287 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
288 [Min. needed GPGSM version.])
293 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
294 GPG=$withval, NO_OVERRIDE=yes)
295 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
298 if test "$cross_compiling" != "yes"; then
299 AC_PATH_PROG(GPG, gpg)
301 if test -z "$GPG"; then
305 if test "$GPG" = no; then
306 if test "$NO_OVERRIDE" = "yes"; then
307 if test "$cross_compiling" != "yes"; then
310 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
315 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
320 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
323 dnl Check for GnuPG version requirement.
326 if test -z "$GPG" -o "x$GPG" = "xno"; then
329 if test "$cross_compiling" = "yes"; then
330 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
333 if test ! -x "$GPG"; then
334 AC_MSG_WARN([GnuPG not executable, version check disabled])
339 if test "$ok" = "maybe"; then
340 AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
341 req_major=`echo $NEED_GPG_VERSION | \
342 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
343 req_minor=`echo $NEED_GPG_VERSION | \
344 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
345 req_micro=`echo $NEED_GPG_VERSION | \
346 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
347 GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
348 major=`echo $GPG_VERSION | \
349 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
350 minor=`echo $GPG_VERSION | \
351 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
352 micro=`echo $GPG_VERSION | \
353 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
355 if test "$major" -gt "$req_major"; then
358 if test "$major" -eq "$req_major"; then
359 if test "$minor" -gt "$req_minor"; then
362 if test "$minor" -eq "$req_minor"; then
363 if test "$micro" -ge "$req_micro"; then
370 if test "$ok" = "yes"; then
374 AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
378 AC_ARG_ENABLE(gpg-test,
379 AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
380 run_gpg_test=$enableval)
381 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
386 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
387 GPGSM=$withval, NO_OVERRIDE=yes)
388 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
391 if test "$cross_compiling" != "yes"; then
392 AC_PATH_PROG(GPGSM, gpgsm)
394 if test -z "$GPGSM"; then
395 GPGSM="$GPGSM_DEFAULT"
398 if test "$GPGSM" = no; then
399 if test "$NO_OVERRIDE" = "yes"; then
400 if test "$cross_compiling" != "yes"; then
403 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
408 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
413 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
414 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
416 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
419 dnl Check for GPGSM version requirement.
420 GPGSM_VERSION=unknown
422 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
425 if test "$cross_compiling" = "yes"; then
426 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
429 if test ! -x "$GPGSM"; then
430 AC_MSG_WARN([GPGSM not executable, version check disabled])
435 if test "$ok" = "maybe"; then
436 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
437 req_major=`echo $NEED_GPGSM_VERSION | \
438 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
439 req_minor=`echo $NEED_GPGSM_VERSION | \
440 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
441 req_micro=`echo $NEED_GPGSM_VERSION | \
442 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
443 GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
444 major=`echo $GPGSM_VERSION | \
445 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
446 minor=`echo $GPGSM_VERSION | \
447 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
448 micro=`echo $GPGSM_VERSION | \
449 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
451 if test "$major" -gt "$req_major"; then
454 if test "$major" -eq "$req_major"; then
455 if test "$minor" -gt "$req_minor"; then
458 if test "$minor" -eq "$req_minor"; then
459 if test "$micro" -ge "$req_micro"; then
466 if test "$ok" = "yes"; then
470 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
474 AC_ARG_ENABLE(gpgsm-test,
475 AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
476 run_gpgsm_test=$enableval)
477 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
480 # FIXME: Only build if supported.
481 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
482 if test "$GPGSM" != "no"; then
483 AC_DEFINE(HAVE_ASSUAN_H, 1,
484 [Defined if we are building with assuan support.])
488 AC_CHECK_FUNCS(funopen)
489 if test $ac_cv_func_funopen != yes; then
490 # No funopen but we can implement that in terms of fopencookie.
491 AC_CHECK_FUNCS(fopencookie)
492 if test $ac_cv_func_fopencookie = yes; then
493 AC_REPLACE_FUNCS(funopen)
497 *** No implementation of fopencookie or funopen available
502 # More assuan replacement functions.
503 AC_REPLACE_FUNCS(isascii)
504 AC_REPLACE_FUNCS(putc_unlocked)
505 AC_REPLACE_FUNCS(memrchr)
506 AC_REPLACE_FUNCS(stpcpy)
507 # Check for unistd.h for setenv replacement function.
508 AC_CHECK_HEADERS(unistd.h)
509 AC_REPLACE_FUNCS(setenv)
511 # More assuan checks.
512 AC_CHECK_HEADERS([sys/uio.h])
514 # Assuan check for descriptor passing.
515 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
516 [supports_descriptor_passing=yes],
517 [supports_descriptor_passing=no
520 *** Data structure for sending ancillary data missing.
521 *** Descriptor passing won't work.
526 #include <sys/types.h>
527 #include <sys/socket.h>
535 AC_ARG_ENABLE(fd-passing,
536 AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
537 use_descriptor_passing=$enableval)
539 if test "$supports_descriptor_passing" != "yes"; then
540 use_descriptor_passing=no
543 if test "$use_descriptor_passing" = "yes"; then
544 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
545 [Defined if descriptor passing is enabled and supported])
548 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
550 # Assuan check for the getsockopt SO_PEERCRED
551 AC_MSG_CHECKING(for SO_PEERCRED)
552 AC_CACHE_VAL(assuan_cv_sys_so_peercred,
553 [AC_TRY_COMPILE([#include <sys/socket.h>],
556 getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
557 assuan_cv_sys_so_peercred=yes,
558 assuan_cv_sys_so_peercred=no)
560 AC_MSG_RESULT($assuan_cv_sys_so_peercred)
561 if test $assuan_cv_sys_so_peercred = yes; then
562 AC_DEFINE(HAVE_SO_PEERCRED, 1,
563 [Defined if SO_PEERCRED is supported (Linux specific)])
566 if test "$have_w32_system" = yes; then
567 NETLIBS="-lws2_32 $NETLIBS"
570 # End of assuan checks.
572 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
574 # Make the version number in gpgme/gpgme.h the same as the one here.
575 # (this is easier than to have a *.in file just for one substitution)
576 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
578 # Generate values for the DLL version info
579 if test "$have_w32_system" = yes; then
580 BUILD_TIMESTAMP=`date --iso-8601=minutes`
582 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
584 BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
586 AC_SUBST(BUILD_REVISION)
587 AC_SUBST(BUILD_TIMESTAMP)
588 AC_SUBST(BUILD_FILEVERSION)
590 # Add a few constants to help porting to W32
591 AH_VERBATIM([SEPCONSTANTS],
593 /* Separators as used in $PATH. */
594 #ifdef HAVE_DOSISH_SYSTEM
595 #define PATHSEP_C ';'
597 #define PATHSEP_C ':'
602 /* Definition of GCC specific attributes. */
604 # define GPGME_GCC_A_PURE __attribute__ ((__pure__))
606 # define GPGME_GCC_A_PURE
611 # Substitution used for gpgme-config
612 GPGME_CONFIG_LIBS="-lgpgme"
613 GPGME_CONFIG_CFLAGS=""
614 AC_SUBST(GPGME_CONFIG_API_VERSION)
615 AC_SUBST(GPGME_CONFIG_LIBS)
616 AC_SUBST(GPGME_CONFIG_CFLAGS)
619 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
620 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
624 # Create config files
626 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
627 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
628 doc/Makefile complus/Makefile
629 gpgme/versioninfo.rc)
630 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
631 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
635 GPGME v${VERSION} has been configured as follows:
638 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
641 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
643 GPGME Pthread: $have_pthread