1 # configure.ac for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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.3])
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=1
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 # XXX Assuan is not supported in this configuration.
127 #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
128 #component_system='COM+'
131 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
132 if test "$have_pth" = yes; then
133 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
135 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
136 if test "$have_pthread" = yes; then
137 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
140 # XXX: Probably use exec-prefix here?
141 # GPG_DEFAULT='/usr/bin/gpg'
142 # GPGSM_DEFAULT='/usr/bin/gpgsm'
146 if test "$have_dosish_system" = yes; then
147 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
148 [Defined if we run on some of the PCDOS like systems
149 (DOS, Windoze. OS/2) with special properties like
152 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
154 if test "$have_w32_system" = yes; then
155 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
157 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
161 AC_ARG_ENABLE(w32-glib,
162 AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
163 build_w32_glib=$withval)
164 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
166 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
167 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
170 # Checks for header files.
171 AC_CHECK_HEADERS(sys/select.h)
176 AC_CHECK_SIZEOF(unsigned int)
180 # Checks for compiler features.
181 if test "$GCC" = yes; then
182 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
183 if test "$have_w32_system" = yes; then
184 CFLAGS="$CFLAGS -mms-bitfields"
188 # Network library fun.
189 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
190 [NETLIBS="-lnsl $NETLIBS"]))
191 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
192 [NETLIBS="-lsocket $NETLIBS"]))
195 # Checks for library functions.
198 AC_REPLACE_FUNCS(vasprintf)
199 if test "$ac_cv_func_vasprintf" != yes; then
203 # Try to find a thread-safe version of ttyname().
204 AC_REPLACE_FUNCS(ttyname_r)
205 if test "$ac_cv_func_ttyname_r" != yes; then
208 *** ttyname() is not thread-safe and ttyname_r() does not exist
212 # Try to find a thread-safe version of getenv().
213 have_thread_safe_getenv=no
215 if test $GLIBC21 = yes; then
216 have_thread_safe_getenv=yes
218 if test $have_thread_safe_getenv = yes; then
219 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
222 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
223 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
226 *** getenv() is not thread-safe and getenv_r() does not exist
230 # For converting time strings to seconds since Epoch, we need the timegm
232 AC_CHECK_FUNCS(timegm)
233 if test "$ac_cv_func_timegm" != yes; then
236 *** timegm() not available - a non-thread-safe kludge will be used
237 *** and the TZ variable might be changed at runtime.
241 # Checking for libgpg-error.
242 AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
243 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
244 [The default error source for GPGME.])
248 # Checks for system services
249 NEED_GPG_VERSION_DEFAULT=1.3.0
250 NEED_GPGSM_VERSION_DEFAULT=1.9.6
251 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
252 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
253 AC_ARG_WITH(gpg-version,
254 AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
255 NEED_GPG_VERSION=$withval)
256 if test "$NEED_GPG_VERSION" = "yes"; then
257 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
259 if test "$NEED_GPG_VERSION" = "no"; then
260 NEED_GPG_VERSION=0.0.0
262 AC_ARG_WITH(gpgsm-version,
263 AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
264 NEED_GPGSM_VERSION=$withval)
265 if test "$NEED_GPGSM_VERSION" = "yes"; then
266 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
268 if test "$NEED_GPGSM_VERSION" = "no"; then
269 NEED_GPGSM_VERSION=0.0.0
272 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
273 [Min. needed GnuPG version.])
274 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
275 [Min. needed GPGSM version.])
280 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
281 GPG=$withval, NO_OVERRIDE=yes)
282 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
285 if test "$cross_compiling" != "yes"; then
286 AC_PATH_PROG(GPG, gpg)
288 if test -z "$GPG"; then
292 if test "$GPG" = no; then
293 if test "$NO_OVERRIDE" = "yes"; then
294 if test "$cross_compiling" != "yes"; then
297 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
302 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
307 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
310 dnl Check for GnuPG version requirement.
313 if test -z "$GPG" -o "x$GPG" = "xno"; then
316 if test "$cross_compiling" = "yes"; then
317 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
320 if test ! -x "$GPG"; then
321 AC_MSG_WARN([GnuPG not executable, version check disabled])
326 if test "$ok" = "maybe"; then
327 AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
328 req_major=`echo $NEED_GPG_VERSION | \
329 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
330 req_minor=`echo $NEED_GPG_VERSION | \
331 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
332 req_micro=`echo $NEED_GPG_VERSION | \
333 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
334 GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
335 major=`echo $GPG_VERSION | \
336 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
337 minor=`echo $GPG_VERSION | \
338 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
339 micro=`echo $GPG_VERSION | \
340 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
342 if test "$major" -gt "$req_major"; then
345 if test "$major" -eq "$req_major"; then
346 if test "$minor" -gt "$req_minor"; then
349 if test "$minor" -eq "$req_minor"; then
350 if test "$micro" -ge "$req_micro"; then
357 if test "$ok" = "yes"; then
361 AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
365 AC_ARG_ENABLE(gpg-test,
366 AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
367 run_gpg_test=$enableval)
368 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
373 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
374 GPGSM=$withval, NO_OVERRIDE=yes)
375 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
378 if test "$cross_compiling" != "yes"; then
379 AC_PATH_PROG(GPGSM, gpgsm)
381 if test -z "$GPGSM"; then
382 GPGSM="$GPGSM_DEFAULT"
385 if test "$GPGSM" = no; then
386 if test "$NO_OVERRIDE" = "yes"; then
387 if test "$cross_compiling" != "yes"; then
390 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
395 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
400 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
401 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
403 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
406 dnl Check for GPGSM version requirement.
407 GPGSM_VERSION=unknown
409 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
412 if test "$cross_compiling" = "yes"; then
413 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
416 if test ! -x "$GPGSM"; then
417 AC_MSG_WARN([GPGSM not executable, version check disabled])
422 if test "$ok" = "maybe"; then
423 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
424 req_major=`echo $NEED_GPGSM_VERSION | \
425 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
426 req_minor=`echo $NEED_GPGSM_VERSION | \
427 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
428 req_micro=`echo $NEED_GPGSM_VERSION | \
429 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
430 GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
431 major=`echo $GPGSM_VERSION | \
432 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
433 minor=`echo $GPGSM_VERSION | \
434 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
435 micro=`echo $GPGSM_VERSION | \
436 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
438 if test "$major" -gt "$req_major"; then
441 if test "$major" -eq "$req_major"; then
442 if test "$minor" -gt "$req_minor"; then
445 if test "$minor" -eq "$req_minor"; then
446 if test "$micro" -ge "$req_micro"; then
453 if test "$ok" = "yes"; then
457 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
461 AC_ARG_ENABLE(gpgsm-test,
462 AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
463 run_gpgsm_test=$enableval)
464 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
467 # FIXME: Only build if supported.
468 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
469 if test "$GPGSM" != "no"; then
470 AC_DEFINE(HAVE_ASSUAN_H, ,[Defined if we are building with assuan support.])
473 # The assuan code uses funopen but it will also build without it. So
474 # test for it. Frankly, this is not required in gpgme, but thats the
475 # way we handle it in libassuan.
476 AC_CHECK_FUNCS(funopen)
477 if test $ac_cv_func_funopen != yes; then
478 # No funopen but we can implement that in terms of fopencookie.
479 AC_CHECK_FUNCS(fopencookie)
480 if test $ac_cv_func_fopencookie = yes; then
485 *** No implementation of fopencookie or funopen available
490 # More assuan replacement functions.
491 AC_REPLACE_FUNCS(isascii)
492 AC_REPLACE_FUNCS(putc_unlocked)
493 AC_REPLACE_FUNCS(memrchr)
494 AC_REPLACE_FUNCS(stpcpy)
495 # Check for unistd.h for setenv replacement function.
496 AC_CHECK_HEADERS(unistd.h)
497 AC_REPLACE_FUNCS(setenv)
499 # More assuan checks.
500 AC_CHECK_HEADERS([sys/uio.h])
502 # Assuan check for descriptor passing.
503 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
504 [supports_descriptor_passing=yes],
505 [supports_descriptor_passing=no
508 *** Data structure for sending ancillary data missing.
509 *** Descriptor passing won't work.
514 #include <sys/types.h>
515 #include <sys/socket.h>
523 AC_ARG_ENABLE(fd-passing,
524 AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
525 use_descriptor_passing=$enableval)
527 if test "$supports_descriptor_passing" != "yes"; then
528 use_descriptor_passing=no
531 if test "$use_descriptor_passing" = "yes"; then
537 AC_DEFINE_UNQUOTED(USE_DESCRIPTOR_PASSING, $fd_passing,
538 [Defined if descriptor passing is enabled and supported])
539 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
541 # End of assuan checks.
543 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
545 # Make the version number in gpgme/gpgme.h the same as the one here.
546 # (this is easier than to have a *.in file just for one substitution)
547 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
549 # Generate values for the DLL version info
551 BUILD_REVISION="`echo '$Revision$' | sed 's/[^0-9]//g'`"
553 test -z "$BUILD_REVISION" && BUILD_REVISION="0"
554 if test "$have_w32_system" = yes; then
555 BUILD_TIMESTAMP=`date --iso-8601=minutes`
557 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
559 BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
561 AC_SUBST(BUILD_REVISION)
562 AC_SUBST(BUILD_TIMESTAMP)
563 AC_SUBST(BUILD_FILEVERSION)
565 # Add a few constants to help porting to W32
566 AH_VERBATIM([SEPCONSTANTS],
568 /* Separators as used in file names and $PATH. Please note that the
569 string version must not contain more than one character because
570 the using code assumes strlen()==1 */
571 #ifdef HAVE_DOSISH_SYSTEM
572 #define DIRSEP_C '\\\\'
574 #define DIRSEP_S "\\\\"
576 #define PATHSEP_C ';'
577 #define PATHSEP_S ";"
583 #define PATHSEP_C ':'
584 #define PATHSEP_S ":"
589 /* Definition of GCC specific attributes. */
591 # define GPGME_GCC_A_PURE __attribute__ ((__pure__))
593 # define GPGME_GCC_A_PURE
598 # Substitution used for gpgme-config
599 GPGME_CONFIG_LIBS="-lgpgme"
600 GPGME_CONFIG_CFLAGS=""
601 AC_SUBST(GPGME_CONFIG_API_VERSION)
602 AC_SUBST(GPGME_CONFIG_LIBS)
603 AC_SUBST(GPGME_CONFIG_CFLAGS)
606 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
607 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
611 # Create config files
613 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
614 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
615 doc/Makefile complus/Makefile
616 gpgme/versioninfo.rc)
617 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
618 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
622 GPGME v${VERSION} has been configured as follows:
625 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
628 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
630 GPGME Pthread: $have_pthread