1 # configure.ac for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005 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.)
24 min_automake_version="1.9.3"
26 # Version number: Remember to change it immediately *after* a release.
27 # Make sure to run "svn up" before a "make dist".
28 # See below for the LT versions.
30 # The CVS version is usually the next intended release version with
31 # the string "-cvs" appended. The reason for this is that tests for a
32 # specific feature can already be done under the assumption that the
33 # CVS version is the most recent one in a branch. To disable the CVS
34 # version for the real release, just comment out the my_iscvs macro.
35 # Note, that we are now using Subversion instead of CVS and append the
36 # SVN revision number to the "cvs" suffix. To make this most useful
37 # for snapshot releases please do an "svn up" right before recreating
38 # the configure script, so that a proper revision number for all files
39 # is available when running a "make distcheck".
40 m4_define(my_version, [1.1.1])
41 m4_define(my_iscvs, yes)
42 AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit(
43 [$Revision$],[Ra-z $:])]),
44 [bug-gpgme@gnupg.org])
46 # LT Version numbers, remember to change them just *before* a release.
47 # (Code changed: REVISION++)
48 # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
49 # (Interfaces added: AGE++)
50 # (Interfaces removed/changed: AGE=0)
52 LIBGPGME_LT_CURRENT=16
53 # Subtract 2 from this value if you want to make the LFS transition an
54 # ABI break. [Note to self: Remove this comment with the next regular break.]
56 LIBGPGME_LT_REVISION=0
58 # If the API is changed in an incompatible way: increment the next counter.
59 GPGME_CONFIG_API_VERSION=1
61 NEED_GPG_VERSION=1.2.2
62 NEED_GPGSM_VERSION=1.9.6
63 ##############################################
67 VERSION=$PACKAGE_VERSION
69 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
70 dnl FIXME: Enable this with autoconf 2.59.
71 dnl AC_CONFIG_MACRO_DIR(m4)
72 AM_CONFIG_HEADER(config.h)
73 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
77 # Enable GNU extensions on systems that have them.
80 AH_VERBATIM([_REENTRANT],
81 [/* To allow the use of GPGME in multithreaded programs we have to use
82 special features from the library.
83 IMPORTANT: gpgme is not yet fully reentrant and you should use it
84 only from one thread. */
91 AC_SUBST(LIBGPGME_LT_CURRENT)
92 AC_SUBST(LIBGPGME_LT_AGE)
93 AC_SUBST(LIBGPGME_LT_REVISION)
94 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
95 [Min. needed GnuPG version.])
96 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
97 [Min. needed GPGSM version.])
101 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
102 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
104 # Don't default to build static libs.
110 # For now we hardcode the use of version scripts. It would be better
111 # to write a test for this or even implement this within libtool.
112 have_ld_version_script=no
115 have_ld_version_script=yes
118 have_ld_version_script=yes
121 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
125 component_system=None
126 have_dosish_system=no
130 # special stuff for Windoze NT
131 have_dosish_system=yes
133 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
134 # XXX Assuan is not supported in this configuration.
135 #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
136 #component_system='COM+'
139 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
140 if test "$have_pth" = yes; then
141 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
143 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
144 if test "$have_pthread" = yes; then
145 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
148 # XXX: Probably use exec-prefix here?
149 # GPG_DEFAULT='/usr/bin/gpg'
150 # GPGSM_DEFAULT='/usr/bin/gpgsm'
154 if test "$have_dosish_system" = yes; then
155 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
156 [Defined if we run on some of the PCDOS like systems
157 (DOS, Windoze. OS/2) with special properties like
160 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
162 if test "$have_w32_system" = yes; then
163 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
165 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
169 AC_ARG_ENABLE(w32-glib,
170 AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
171 build_w32_glib=$withval)
172 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
174 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
175 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
178 # Checks for header files.
179 AC_CHECK_HEADERS(sys/select.h)
184 AC_CHECK_SIZEOF(unsigned int)
188 # Checks for compiler features.
189 if test "$GCC" = yes; then
190 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
191 if test "$have_w32_system" = yes; then
192 CFLAGS="$CFLAGS -mms-bitfields"
197 # Checks for library functions.
200 AC_CHECK_FUNCS(stpcpy)
202 AC_REPLACE_FUNCS(vasprintf)
203 if test "$ac_cv_func_vasprintf" != yes; then
207 # Try to find a thread-safe version of ttyname().
208 AC_REPLACE_FUNCS(ttyname_r)
209 if test "$ac_cv_func_ttyname_r" != yes; then
212 *** ttyname() is not thread-safe and ttyname_r() does not exist
216 # Try to find a thread-safe version of getenv().
217 have_thread_safe_getenv=no
219 if test $GLIBC21 = yes; then
220 have_thread_safe_getenv=yes
222 if test $have_thread_safe_getenv = yes; then
223 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
226 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
227 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
230 *** getenv() is not thread-safe and getenv_r() does not exist
234 # For converting time strings to seconds since Epoch, we need the timegm
236 AC_CHECK_FUNCS(timegm)
237 if test "$ac_cv_func_timegm" != yes; then
240 *** timegm() not available - a non-thread-safe kludge will be used
241 *** and the TZ variable might be changed at runtime.
245 # Checking for libgpg-error.
246 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
247 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
248 [The default error source for GPGME.])
252 # Checks for system services
255 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
256 GPG=$withval, NO_OVERRIDE=yes)
257 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
260 if test "$cross_compiling" != "yes"; then
261 AC_PATH_PROG(GPG, gpg)
263 if test -z "$GPG"; then
267 if test "$GPG" = no; then
268 if test "$NO_OVERRIDE" = "yes"; then
269 if test "$cross_compiling" != "yes"; then
272 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
277 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
282 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
285 dnl Check for GnuPG version requirement.
288 if test -z "$GPG" -o "x$GPG" = "xno"; then
291 if test "$cross_compiling" = "yes"; then
292 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
295 if test ! -x "$GPG"; then
296 AC_MSG_WARN([GnuPG not executable, version check disabled])
301 if test "$ok" = "maybe"; then
302 AC_MSG_CHECKING(for GnuPG >= $NEED_GPG_VERSION)
303 req_major=`echo $NEED_GPG_VERSION | \
304 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
305 req_minor=`echo $NEED_GPG_VERSION | \
306 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
307 req_micro=`echo $NEED_GPG_VERSION | \
308 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
309 gpg_version=`$GPG --version | grep ^gpg`
310 major=`echo $gpg_version | \
311 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
312 minor=`echo $gpg_version | \
313 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
314 micro=`echo $gpg_version | \
315 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
316 GPG_VERSION=`echo $gpg_version | sed 's/^gpg (GnuPG) //'`
318 if test "$major" -gt "$req_major"; then
321 if test "$major" -eq "$req_major"; then
322 if test "$minor" -gt "$req_minor"; then
325 if test "$minor" -eq "$req_minor"; then
326 if test "$micro" -ge "$req_micro"; then
333 if test "$ok" = "yes"; then
337 AC_MSG_WARN([GnuPG must be at least version $NEED_GPG_VERSION])
340 AM_CONDITIONAL(RUN_GPG_TESTS, test "$ok" = "yes")
345 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
346 GPGSM=$withval, NO_OVERRIDE=yes)
347 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
350 if test "$cross_compiling" != "yes"; then
351 AC_PATH_PROG(GPGSM, gpgsm)
353 if test -z "$GPGSM"; then
354 GPGSM="$GPGSM_DEFAULT"
357 if test "$GPGSM" = no; then
358 if test "$NO_OVERRIDE" = "yes"; then
359 if test "$cross_compiling" != "yes"; then
362 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
367 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
372 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
373 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
375 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
378 dnl Check for GPGSM version requirement.
379 GPGSM_VERSION=unknown
381 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
384 if test "$cross_compiling" = "yes"; then
385 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
388 if test ! -x "$GPGSM"; then
389 AC_MSG_WARN([GPGSM not executable, version check disabled])
394 if test "$ok" = "maybe"; then
395 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
396 req_major=`echo $NEED_GPGSM_VERSION | \
397 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
398 req_minor=`echo $NEED_GPGSM_VERSION | \
399 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
400 req_micro=`echo $NEED_GPGSM_VERSION | \
401 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
402 gpgsm_version=`$GPGSM --version | grep ^gpgsm`
403 major=`echo $gpgsm_version | \
404 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
405 minor=`echo $gpgsm_version | \
406 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
407 micro=`echo $gpgsm_version | \
408 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
409 GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
411 if test "$major" -gt "$req_major"; then
414 if test "$major" -eq "$req_major"; then
415 if test "$minor" -gt "$req_minor"; then
418 if test "$minor" -eq "$req_minor"; then
419 if test "$micro" -ge "$req_micro"; then
426 if test "$ok" = "yes"; then
430 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
433 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$ok" = "yes")
435 # FIXME: Only build if supported.
436 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
439 # The assuan code uses funopen but it will also build without it. So
440 # test for it. Frankly, this is not required in gpgme, but thats the
441 # way we handle it in libassuan.
442 AC_CHECK_FUNCS(funopen)
443 if test $ac_cv_func_funopen != yes; then
444 # No funopen but we can implement that in terms of fopencookie.
445 AC_CHECK_FUNCS(fopencookie)
446 if test $ac_cv_func_fopencookie = yes; then
451 *** No implementation of fopencookie or funopen available
456 # More assuan replacement functions.
457 AC_REPLACE_FUNCS(isascii)
458 AC_REPLACE_FUNCS(putc_unlocked)
459 AC_REPLACE_FUNCS(memrchr)
461 # More assuan checks.
462 AC_CHECK_HEADERS([sys/uio.h])
464 # End of assuan checks.
466 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
468 # Make the version number in gpgme/gpgme.h the same as the one here.
469 # (this is easier than to have a *.in file just for one substitution)
470 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
472 # Generate values for the DLL version info
474 BUILD_REVISION="`echo '$Revision$' | sed 's/[^0-9]//g'`"
476 test -z "$BUILD_REVISION" && BUILD_REVISION="0"
477 if test "$have_w32_system" = yes; then
478 BUILD_TIMESTAMP=`date --iso-8601=minutes`
480 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
482 BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
484 AC_SUBST(BUILD_REVISION)
485 AC_SUBST(BUILD_TIMESTAMP)
486 AC_SUBST(BUILD_FILEVERSION)
488 # Add a few constants to help porting to W32
489 AH_VERBATIM([SEPCONSTANTS],
491 /* Separators as used in file names and $PATH. Please note that the
492 string version must not contain more than one character because
493 the using code assumes strlen()==1 */
494 #ifdef HAVE_DOSISH_SYSTEM
495 #define DIRSEP_C '\\\\'
497 #define DIRSEP_S "\\\\"
499 #define PATHSEP_C ';'
500 #define PATHSEP_S ";"
506 #define PATHSEP_C ':'
507 #define PATHSEP_S ":"
512 /* Definition of GCC specific attributes. */
514 # define GPGME_GCC_A_PURE __attribute__ ((__pure__))
516 # define GPGME_GCC_A_PURE
521 # Substitution used for gpgme-config
522 GPGME_CONFIG_LIBS="-lgpgme"
523 GPGME_CONFIG_CFLAGS=""
524 AC_SUBST(GPGME_CONFIG_API_VERSION)
525 AC_SUBST(GPGME_CONFIG_LIBS)
526 AC_SUBST(GPGME_CONFIG_CFLAGS)
529 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
530 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
534 # Create config files
536 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
537 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
538 doc/Makefile complus/Makefile
539 gpgme/versioninfo.rc)
540 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
544 GPGME v${VERSION} has been configured as follows:
547 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
550 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
552 GPGME Pthread: $have_pthread