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 AC_INIT(gpgme, 1.2.0-cvs, [bug-gpgme@gnupg.org])
28 # LT Version numbers, remember to change them just *before* a release.
29 # (Code changed: REVISION++)
30 # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
31 # (Interfaces added: AGE++)
32 # (Interfaces removed/changed: AGE=0)
34 LIBGPGME_LT_CURRENT=16
35 # Subtract 2 from this value if you want to make the LFS transition an
36 # ABI break. [Note to self: Remove this comment with the next regular break.]
38 LIBGPGME_LT_REVISION=0
40 # If the API is changed in an incompatible way: increment the next counter.
41 GPGME_CONFIG_API_VERSION=1
43 NEED_GPG_VERSION=1.2.2
44 NEED_GPGSM_VERSION=1.9.6
45 ##############################################
49 VERSION=$PACKAGE_VERSION
51 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
52 dnl FIXME: Enable this with autoconf 2.59.
53 dnl AC_CONFIG_MACRO_DIR(m4)
54 AM_CONFIG_HEADER(config.h)
55 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
59 # Enable GNU extensions on systems that have them.
62 AH_VERBATIM([_REENTRANT],
63 [/* To allow the use of GPGME in multithreaded programs we have to use
64 special features from the library.
65 IMPORTANT: gpgme is not yet fully reentrant and you should use it
66 only from one thread. */
73 AC_SUBST(LIBGPGME_LT_CURRENT)
74 AC_SUBST(LIBGPGME_LT_AGE)
75 AC_SUBST(LIBGPGME_LT_REVISION)
76 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
77 [Min. needed GnuPG version.])
78 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
79 [Min. needed GPGSM version.])
83 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
84 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
86 # Don't default to build static libs.
92 # For now we hardcode the use of version scripts. It would be better
93 # to write a test for this or even implement this within libtool.
94 have_ld_version_script=no
97 have_ld_version_script=yes
100 have_ld_version_script=yes
103 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
107 component_system=None
108 have_dosish_system=no
112 # special stuff for Windoze NT
113 have_dosish_system=yes
115 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
116 # XXX Assuan is not supported in this configuration.
117 #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
118 #component_system='COM+'
121 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
122 if test "$have_pth" = yes; then
123 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
125 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
126 if test "$have_pthread" = yes; then
127 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
130 # XXX: Probably use exec-prefix here?
131 # GPG_DEFAULT='/usr/bin/gpg'
132 # GPGSM_DEFAULT='/usr/bin/gpgsm'
136 if test "$have_dosish_system" = yes; then
137 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
138 [Defined if we run on some of the PCDOS like systems
139 (DOS, Windoze. OS/2) with special properties like
142 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
144 if test "$have_w32_system" = yes; then
145 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
147 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
150 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
151 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
154 # Checks for header files.
155 AC_CHECK_HEADERS(sys/select.h)
159 AC_CHECK_SIZEOF(unsigned int)
163 # Checks for compiler features.
164 if test "$GCC" = yes; then
165 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
169 # Checks for library functions.
172 AC_CHECK_FUNCS(stpcpy)
174 AC_REPLACE_FUNCS(vasprintf)
175 if test "$ac_cv_func_vasprintf" != yes; then
179 # Try to find a thread-safe version of ttyname().
180 AC_REPLACE_FUNCS(ttyname_r)
181 if test "$ac_cv_func_ttyname_r" != yes; then
184 *** ttyname() is not thread-safe and ttyname_r() does not exist
188 # Try to find a thread-safe version of getenv().
189 have_thread_safe_getenv=no
191 if test $GLIBC21 = yes; then
192 have_thread_safe_getenv=yes
194 if test $have_thread_safe_getenv = yes; then
195 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
198 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
199 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
202 *** getenv() is not thread-safe and getenv_r() does not exist
206 # For converting time strings to seconds since Epoch, we need the timegm
208 AC_CHECK_FUNCS(timegm)
209 if test "$ac_cv_func_timegm" != yes; then
212 *** timegm() not available - a non-thread-safe kludge will be used
213 *** and the TZ variable might be changed at runtime.
217 # Checking for libgpg-error.
218 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
219 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
220 [The default error source for GPGME.])
224 # Checks for system services
227 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
228 GPG=$withval, NO_OVERRIDE=yes)
229 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
232 if test "$cross_compiling" != "yes"; then
233 AC_PATH_PROG(GPG, gpg)
235 if test -z "$GPG"; then
239 if test "$GPG" = no; then
240 if test "$NO_OVERRIDE" = "yes"; then
241 if test "$cross_compiling" != "yes"; then
244 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
249 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
254 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
257 dnl Check for GnuPG version requirement.
260 if test -z "$GPG" -o "x$GPG" = "xno"; then
263 if test "$cross_compiling" = "yes"; then
264 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
267 if test ! -x "$GPG"; then
268 AC_MSG_WARN([GnuPG not executable, version check disabled])
273 if test "$ok" = "maybe"; then
274 AC_MSG_CHECKING(for GnuPG >= $NEED_GPG_VERSION)
275 req_major=`echo $NEED_GPG_VERSION | \
276 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
277 req_minor=`echo $NEED_GPG_VERSION | \
278 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
279 req_micro=`echo $NEED_GPG_VERSION | \
280 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
281 gpg_version=`$GPG --version | grep ^gpg`
282 major=`echo $gpg_version | \
283 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
284 minor=`echo $gpg_version | \
285 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
286 micro=`echo $gpg_version | \
287 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
288 GPG_VERSION=`echo $gpg_version | sed 's/^gpg (GnuPG) //'`
290 if test "$major" -gt "$req_major"; then
293 if test "$major" -eq "$req_major"; then
294 if test "$minor" -gt "$req_minor"; then
297 if test "$minor" -eq "$req_minor"; then
298 if test "$micro" -ge "$req_micro"; then
305 if test "$ok" = "yes"; then
309 AC_MSG_WARN([GnuPG must be at least version $NEED_GPG_VERSION])
312 AM_CONDITIONAL(RUN_GPG_TESTS, test "$ok" = "yes")
317 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
318 GPGSM=$withval, NO_OVERRIDE=yes)
319 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
322 if test "$cross_compiling" != "yes"; then
323 AC_PATH_PROG(GPGSM, gpgsm)
325 if test -z "$GPGSM"; then
326 GPGSM="$GPGSM_DEFAULT"
329 if test "$GPGSM" = no; then
330 if test "$NO_OVERRIDE" = "yes"; then
331 if test "$cross_compiling" != "yes"; then
334 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
339 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
344 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
345 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
347 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
350 dnl Check for GPGSM version requirement.
351 GPGSM_VERSION=unknown
353 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
356 if test "$cross_compiling" = "yes"; then
357 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
360 if test ! -x "$GPGSM"; then
361 AC_MSG_WARN([GPGSM not executable, version check disabled])
366 if test "$ok" = "maybe"; then
367 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
368 req_major=`echo $NEED_GPGSM_VERSION | \
369 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
370 req_minor=`echo $NEED_GPGSM_VERSION | \
371 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
372 req_micro=`echo $NEED_GPGSM_VERSION | \
373 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
374 gpgsm_version=`$GPGSM --version | grep ^gpgsm`
375 major=`echo $gpgsm_version | \
376 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
377 minor=`echo $gpgsm_version | \
378 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
379 micro=`echo $gpgsm_version | \
380 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
381 GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
383 if test "$major" -gt "$req_major"; then
386 if test "$major" -eq "$req_major"; then
387 if test "$minor" -gt "$req_minor"; then
390 if test "$minor" -eq "$req_minor"; then
391 if test "$micro" -ge "$req_micro"; then
398 if test "$ok" = "yes"; then
402 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
405 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$ok" = "yes")
407 # FIXME: Only build if supported.
408 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
411 # The assuan code uses funopen but it will also build without it. So
412 # test for it. Frankly, this is not required in gpgme, but thats the
413 # way we handle it in libassuan.
414 AC_CHECK_FUNCS(funopen)
415 if test $ac_cv_func_funopen != yes; then
416 # No funopen but we can implement that in terms of fopencookie.
417 AC_CHECK_FUNCS(fopencookie)
418 if test $ac_cv_func_fopencookie = yes; then
423 *** No implementation of fopencookie or funopen available
428 # More assuan replacement functions.
429 AC_REPLACE_FUNCS(isascii)
430 AC_REPLACE_FUNCS(putc_unlocked)
431 AC_REPLACE_FUNCS(memrchr)
433 # More assuan checks.
434 AC_CHECK_HEADERS([sys/uio.h])
436 # End of assuan checks.
438 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
440 # Make the version number in gpgme/gpgme.h the same as the one here.
441 # (this is easier than to have a *.in file just for one substitution)
442 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
444 # Generate values for the DLL version info
445 if test "$have_w32_system" = yes; then
446 BUILD_TIMESTAMP=`date --iso-8601=minutes`
448 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
451 *-cvs) BUILD_FILEVERSION="${BUILD_FILEVERSION}0" ;;
452 *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;;
453 *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;;
456 AC_SUBST(BUILD_TIMESTAMP)
457 AC_SUBST(BUILD_FILEVERSION)
459 # Add a few constants to help porting to W32
460 AH_VERBATIM([SEPCONSTANTS],
462 /* Separators as used in file names and $PATH. Please note that the
463 string version must not contain more than one character because
464 the using code assumes strlen()==1 */
465 #ifdef HAVE_DOSISH_SYSTEM
466 #define DIRSEP_C '\\\\'
468 #define DIRSEP_S "\\\\"
470 #define PATHSEP_C ';'
471 #define PATHSEP_S ";"
477 #define PATHSEP_C ':'
478 #define PATHSEP_S ":"
483 # Substitution used for gpgme-config
484 GPGME_CONFIG_LIBS="-lgpgme"
485 GPGME_CONFIG_CFLAGS=""
486 AC_SUBST(GPGME_CONFIG_API_VERSION)
487 AC_SUBST(GPGME_CONFIG_LIBS)
488 AC_SUBST(GPGME_CONFIG_CFLAGS)
491 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
492 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
496 # Create config files
498 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
499 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
500 doc/Makefile complus/Makefile
501 gpgme/versioninfo.rc)
502 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
506 GPGME v${VERSION} has been configured as follows:
509 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
512 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
514 GPGME Pthread: $have_pthread