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
60 NEED_GPG_VERSION=1.2.2
61 NEED_GPGSM_VERSION=1.9.6
62 ##############################################
66 VERSION=$PACKAGE_VERSION
68 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
69 dnl FIXME: Enable this with autoconf 2.59.
70 dnl AC_CONFIG_MACRO_DIR(m4)
71 AM_CONFIG_HEADER(config.h)
72 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
76 # Enable GNU extensions on systems that have them.
79 AH_VERBATIM([_REENTRANT],
80 [/* To allow the use of GPGME in multithreaded programs we have to use
81 special features from the library.
82 IMPORTANT: gpgme is not yet fully reentrant and you should use it
83 only from one thread. */
90 AC_SUBST(LIBGPGME_LT_CURRENT)
91 AC_SUBST(LIBGPGME_LT_AGE)
92 AC_SUBST(LIBGPGME_LT_REVISION)
93 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
94 [Min. needed GnuPG version.])
95 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
96 [Min. needed GPGSM version.])
100 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
101 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
103 # Don't default to build static libs.
109 # For now we hardcode the use of version scripts. It would be better
110 # to write a test for this or even implement this within libtool.
111 have_ld_version_script=no
114 have_ld_version_script=yes
117 have_ld_version_script=yes
120 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
124 component_system=None
125 have_dosish_system=no
129 # special stuff for Windoze NT
130 have_dosish_system=yes
132 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
133 # XXX Assuan is not supported in this configuration.
134 #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
135 #component_system='COM+'
138 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
139 if test "$have_pth" = yes; then
140 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
142 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
143 if test "$have_pthread" = yes; then
144 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
147 # XXX: Probably use exec-prefix here?
148 # GPG_DEFAULT='/usr/bin/gpg'
149 # GPGSM_DEFAULT='/usr/bin/gpgsm'
153 if test "$have_dosish_system" = yes; then
154 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
155 [Defined if we run on some of the PCDOS like systems
156 (DOS, Windoze. OS/2) with special properties like
159 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
161 if test "$have_w32_system" = yes; then
162 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
164 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
168 AC_ARG_ENABLE(w32-glib,
169 AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
170 build_w32_glib=$withval)
171 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
173 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
174 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
177 # Checks for header files.
178 AC_CHECK_HEADERS(sys/select.h)
183 AC_CHECK_SIZEOF(unsigned int)
187 # Checks for compiler features.
188 if test "$GCC" = yes; then
189 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
190 if test "$have_w32_system" = yes; then
191 CFLAGS="$CFLAGS -mms-bitfields"
195 # Network library fun.
196 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
197 [NETLIBS="-lnsl $NETLIBS"]))
198 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
199 [NETLIBS="-lsocket $NETLIBS"]))
202 # Checks for library functions.
205 AC_CHECK_FUNCS(stpcpy)
207 AC_REPLACE_FUNCS(vasprintf)
208 if test "$ac_cv_func_vasprintf" != yes; then
212 # Try to find a thread-safe version of ttyname().
213 AC_REPLACE_FUNCS(ttyname_r)
214 if test "$ac_cv_func_ttyname_r" != yes; then
217 *** ttyname() is not thread-safe and ttyname_r() does not exist
221 # Try to find a thread-safe version of getenv().
222 have_thread_safe_getenv=no
224 if test $GLIBC21 = yes; then
225 have_thread_safe_getenv=yes
227 if test $have_thread_safe_getenv = yes; then
228 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
231 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
232 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
235 *** getenv() is not thread-safe and getenv_r() does not exist
239 # For converting time strings to seconds since Epoch, we need the timegm
241 AC_CHECK_FUNCS(timegm)
242 if test "$ac_cv_func_timegm" != yes; then
245 *** timegm() not available - a non-thread-safe kludge will be used
246 *** and the TZ variable might be changed at runtime.
250 # Checking for libgpg-error.
251 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
252 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
253 [The default error source for GPGME.])
257 # Checks for system services
260 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
261 GPG=$withval, NO_OVERRIDE=yes)
262 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
265 if test "$cross_compiling" != "yes"; then
266 AC_PATH_PROG(GPG, gpg)
268 if test -z "$GPG"; then
272 if test "$GPG" = no; then
273 if test "$NO_OVERRIDE" = "yes"; then
274 if test "$cross_compiling" != "yes"; then
277 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
282 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
287 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
290 dnl Check for GnuPG version requirement.
293 if test -z "$GPG" -o "x$GPG" = "xno"; then
296 if test "$cross_compiling" = "yes"; then
297 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
300 if test ! -x "$GPG"; then
301 AC_MSG_WARN([GnuPG not executable, version check disabled])
306 if test "$ok" = "maybe"; then
307 AC_MSG_CHECKING(for GnuPG >= $NEED_GPG_VERSION)
308 req_major=`echo $NEED_GPG_VERSION | \
309 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
310 req_minor=`echo $NEED_GPG_VERSION | \
311 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
312 req_micro=`echo $NEED_GPG_VERSION | \
313 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
314 gpg_version=`$GPG --version | grep ^gpg`
315 major=`echo $gpg_version | \
316 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
317 minor=`echo $gpg_version | \
318 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
319 micro=`echo $gpg_version | \
320 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
321 GPG_VERSION=`echo $gpg_version | sed 's/^gpg (GnuPG) //'`
323 if test "$major" -gt "$req_major"; then
326 if test "$major" -eq "$req_major"; then
327 if test "$minor" -gt "$req_minor"; then
330 if test "$minor" -eq "$req_minor"; then
331 if test "$micro" -ge "$req_micro"; then
338 if test "$ok" = "yes"; then
342 AC_MSG_WARN([GnuPG must be at least version $NEED_GPG_VERSION])
345 AM_CONDITIONAL(RUN_GPG_TESTS, test "$ok" = "yes")
350 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
351 GPGSM=$withval, NO_OVERRIDE=yes)
352 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
355 if test "$cross_compiling" != "yes"; then
356 AC_PATH_PROG(GPGSM, gpgsm)
358 if test -z "$GPGSM"; then
359 GPGSM="$GPGSM_DEFAULT"
362 if test "$GPGSM" = no; then
363 if test "$NO_OVERRIDE" = "yes"; then
364 if test "$cross_compiling" != "yes"; then
367 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
372 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
377 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
378 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
380 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
383 dnl Check for GPGSM version requirement.
384 GPGSM_VERSION=unknown
386 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
389 if test "$cross_compiling" = "yes"; then
390 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
393 if test ! -x "$GPGSM"; then
394 AC_MSG_WARN([GPGSM not executable, version check disabled])
399 if test "$ok" = "maybe"; then
400 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
401 req_major=`echo $NEED_GPGSM_VERSION | \
402 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
403 req_minor=`echo $NEED_GPGSM_VERSION | \
404 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
405 req_micro=`echo $NEED_GPGSM_VERSION | \
406 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
407 gpgsm_version=`$GPGSM --version | grep ^gpgsm`
408 major=`echo $gpgsm_version | \
409 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
410 minor=`echo $gpgsm_version | \
411 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
412 micro=`echo $gpgsm_version | \
413 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
414 GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
416 if test "$major" -gt "$req_major"; then
419 if test "$major" -eq "$req_major"; then
420 if test "$minor" -gt "$req_minor"; then
423 if test "$minor" -eq "$req_minor"; then
424 if test "$micro" -ge "$req_micro"; then
431 if test "$ok" = "yes"; then
435 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
438 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$ok" = "yes")
440 # FIXME: Only build if supported.
441 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
444 # The assuan code uses funopen but it will also build without it. So
445 # test for it. Frankly, this is not required in gpgme, but thats the
446 # way we handle it in libassuan.
447 AC_CHECK_FUNCS(funopen)
448 if test $ac_cv_func_funopen != yes; then
449 # No funopen but we can implement that in terms of fopencookie.
450 AC_CHECK_FUNCS(fopencookie)
451 if test $ac_cv_func_fopencookie = yes; then
456 *** No implementation of fopencookie or funopen available
461 # More assuan replacement functions.
462 AC_REPLACE_FUNCS(isascii)
463 AC_REPLACE_FUNCS(putc_unlocked)
464 AC_REPLACE_FUNCS(memrchr)
466 # More assuan checks.
467 AC_CHECK_HEADERS([sys/uio.h])
469 # End of assuan checks.
471 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
473 # Make the version number in gpgme/gpgme.h the same as the one here.
474 # (this is easier than to have a *.in file just for one substitution)
475 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
477 # Generate values for the DLL version info
479 BUILD_REVISION="`echo '$Revision$' | sed 's/[^0-9]//g'`"
481 test -z "$BUILD_REVISION" && BUILD_REVISION="0"
482 if test "$have_w32_system" = yes; then
483 BUILD_TIMESTAMP=`date --iso-8601=minutes`
485 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
487 BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
489 AC_SUBST(BUILD_REVISION)
490 AC_SUBST(BUILD_TIMESTAMP)
491 AC_SUBST(BUILD_FILEVERSION)
493 # Add a few constants to help porting to W32
494 AH_VERBATIM([SEPCONSTANTS],
496 /* Separators as used in file names and $PATH. Please note that the
497 string version must not contain more than one character because
498 the using code assumes strlen()==1 */
499 #ifdef HAVE_DOSISH_SYSTEM
500 #define DIRSEP_C '\\\\'
502 #define DIRSEP_S "\\\\"
504 #define PATHSEP_C ';'
505 #define PATHSEP_S ";"
511 #define PATHSEP_C ':'
512 #define PATHSEP_S ":"
517 /* Definition of GCC specific attributes. */
519 # define GPGME_GCC_A_PURE __attribute__ ((__pure__))
521 # define GPGME_GCC_A_PURE
526 # Substitution used for gpgme-config
527 GPGME_CONFIG_LIBS="-lgpgme"
528 GPGME_CONFIG_CFLAGS=""
529 AC_SUBST(GPGME_CONFIG_API_VERSION)
530 AC_SUBST(GPGME_CONFIG_LIBS)
531 AC_SUBST(GPGME_CONFIG_CFLAGS)
534 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
535 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
539 # Create config files
541 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
542 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
543 doc/Makefile complus/Makefile
544 gpgme/versioninfo.rc)
545 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
546 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
550 GPGME v${VERSION} has been configured as follows:
553 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
556 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
558 GPGME Pthread: $have_pthread