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.1.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=14
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=3
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. */
72 AC_CHECK_TOOL(DLLTOOL, dlltool, :)
73 AC_CHECK_TOOL(WINDRES, windres, :)
76 AC_SUBST(LIBGPGME_LT_CURRENT)
77 AC_SUBST(LIBGPGME_LT_AGE)
78 AC_SUBST(LIBGPGME_LT_REVISION)
79 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
80 [Min. needed GnuPG version.])
81 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
82 [Min. needed GPGSM version.])
86 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
87 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
89 # Don't default to build static libs.
93 # For now we hardcode the use of version scripts. It would be better
94 # to write a test for this or even implement this within libtool.
95 have_ld_version_script=no
98 have_ld_version_script=yes
101 have_ld_version_script=yes
104 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
108 component_system=None
109 have_dosish_system=no
113 # special stuff for Windoze NT
114 have_dosish_system=yes
116 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
117 # XXX Assuan is not supported in this configuration.
118 #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
119 #component_system='COM+'
122 AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
123 if test "$have_pth" = yes; then
124 AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
125 CFLAGS="$CFLAGS $PTH_CFLAGS"
127 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
128 if test "$have_pthread" = yes; then
129 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
132 # XXX: Probably use exec-prefix here?
133 # GPG_DEFAULT='/usr/bin/gpg'
134 # GPGSM_DEFAULT='/usr/bin/gpgsm'
138 if test "$have_dosish_system" = yes; then
139 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
140 [Defined if we run on some of the PCDOS like systems
141 (DOS, Windoze. OS/2) with special properties like
144 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
146 if test "$have_w32_system" = yes; then
147 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
149 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
152 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
153 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
156 # Checks for header files.
157 AC_CHECK_HEADERS(sys/select.h)
161 AC_CHECK_SIZEOF(unsigned int)
165 # Checks for compiler features.
166 if test "$GCC" = yes; then
167 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
171 # Checks for library functions.
174 AC_CHECK_FUNCS(stpcpy)
176 AC_REPLACE_FUNCS(vasprintf)
177 if test "$ac_cv_func_vasprintf" != yes; then
181 # Try to find a thread-safe version of ttyname().
182 AC_REPLACE_FUNCS(ttyname_r)
183 if test "$ac_cv_func_ttyname_r" != yes; then
186 *** ttyname() is not thread-safe and ttyname_r() does not exist
190 # Try to find a thread-safe version of getenv().
191 have_thread_safe_getenv=no
193 if test $GLIBC21 = yes; then
194 have_thread_safe_getenv=yes
196 if test $have_thread_safe_getenv = yes; then
197 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
200 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
201 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
204 *** getenv() is not thread-safe and getenv_r() does not exist
208 # For converting time strings to seconds since Epoch, we need the timegm
210 AC_CHECK_FUNCS(timegm)
211 if test "$ac_cv_func_timegm" != yes; then
214 *** timegm() not available - a non-thread-safe kludge will be used
215 *** and the TZ variable might be changed at runtime.
219 # Checking for libgpg-error.
220 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
221 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
222 [The default error source for GPGME.])
226 # Checks for system services
229 AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
230 GPG=$withval, NO_OVERRIDE=yes)
231 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
234 if test "$cross_compiling" != "yes"; then
235 AC_PATH_PROG(GPG, gpg)
237 if test -z "$GPG"; then
241 if test "$GPG" = no; then
242 if test "$NO_OVERRIDE" = "yes"; then
243 if test "$cross_compiling" != "yes"; then
246 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
251 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
256 AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
259 dnl Check for GnuPG version requirement.
262 if test -z "$GPG" -o "x$GPG" = "xno"; then
265 if test "$cross_compiling" = "yes"; then
266 AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
269 if test ! -x "$GPG"; then
270 AC_MSG_WARN([GnuPG not executable, version check disabled])
275 if test "$ok" = "maybe"; then
276 AC_MSG_CHECKING(for GnuPG >= $NEED_GPG_VERSION)
277 req_major=`echo $NEED_GPG_VERSION | \
278 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
279 req_minor=`echo $NEED_GPG_VERSION | \
280 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
281 req_micro=`echo $NEED_GPG_VERSION | \
282 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
283 gpg_version=`$GPG --version | grep ^gpg`
284 major=`echo $gpg_version | \
285 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
286 minor=`echo $gpg_version | \
287 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
288 micro=`echo $gpg_version | \
289 sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
290 GPG_VERSION=`echo $gpg_version | sed 's/^gpg (GnuPG) //'`
292 if test "$major" -gt "$req_major"; then
295 if test "$major" -eq "$req_major"; then
296 if test "$minor" -gt "$req_minor"; then
299 if test "$minor" -eq "$req_minor"; then
300 if test "$micro" -ge "$req_micro"; then
307 if test "$ok" = "yes"; then
311 AC_MSG_WARN([GnuPG must be at least version $NEED_GPG_VERSION])
314 AM_CONDITIONAL(RUN_GPG_TESTS, test "$ok" = "yes")
319 AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
320 GPGSM=$withval, NO_OVERRIDE=yes)
321 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
324 if test "$cross_compiling" != "yes"; then
325 AC_PATH_PROG(GPGSM, gpgsm)
327 if test -z "$GPGSM"; then
328 GPGSM="$GPGSM_DEFAULT"
331 if test "$GPGSM" = no; then
332 if test "$NO_OVERRIDE" = "yes"; then
333 if test "$cross_compiling" != "yes"; then
336 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
341 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
346 AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
347 AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
349 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
352 dnl Check for GPGSM version requirement.
353 GPGSM_VERSION=unknown
355 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
358 if test "$cross_compiling" = "yes"; then
359 AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
362 if test ! -x "$GPGSM"; then
363 AC_MSG_WARN([GPGSM not executable, version check disabled])
368 if test "$ok" = "maybe"; then
369 AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
370 req_major=`echo $NEED_GPGSM_VERSION | \
371 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
372 req_minor=`echo $NEED_GPGSM_VERSION | \
373 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
374 req_micro=`echo $NEED_GPGSM_VERSION | \
375 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
376 gpgsm_version=`$GPGSM --version | grep ^gpgsm`
377 major=`echo $gpgsm_version | \
378 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
379 minor=`echo $gpgsm_version | \
380 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
381 micro=`echo $gpgsm_version | \
382 sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
383 GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
385 if test "$major" -gt "$req_major"; then
388 if test "$major" -eq "$req_major"; then
389 if test "$minor" -gt "$req_minor"; then
392 if test "$minor" -eq "$req_minor"; then
393 if test "$micro" -ge "$req_micro"; then
400 if test "$ok" = "yes"; then
404 AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
407 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$ok" = "yes")
409 # FIXME: Only build if supported.
410 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
413 # The assuan code uses funopen but it will also build without it. So
414 # test for it. Frankly, this is not required in gpgme, but thats the
415 # way we handle it in libassuan.
416 AC_CHECK_FUNCS(funopen)
417 if test $ac_cv_func_funopen != yes; then
418 # No funopen but we can implement that in terms of fopencookie.
419 AC_CHECK_FUNCS(fopencookie)
420 if test $ac_cv_func_fopencookie = yes; then
425 *** No implementation of fopencookie or funopen available
430 # More assuan replacement functions.
431 AC_REPLACE_FUNCS(isascii)
432 AC_REPLACE_FUNCS(putc_unlocked)
433 AC_REPLACE_FUNCS(memrchr)
435 # More assuan checks.
436 AC_CHECK_HEADERS([sys/uio.h])
438 # End of assuan checks.
440 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
442 # Make the version number in gpgme/gpgme.h the same as the one here.
443 # (this is easier than to have a *.in file just for one substitution)
444 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
446 # Generate values for the DLL version info
447 if test "$have_w32_system" = yes; then
448 BUILD_TIMESTAMP=`date --iso-8601=minutes`
450 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
453 *-cvs) BUILD_FILEVERSION="${BUILD_FILEVERSION}0" ;;
454 *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;;
455 *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;;
458 AC_SUBST(BUILD_TIMESTAMP)
459 AC_SUBST(BUILD_FILEVERSION)
462 # Substitution used for gpgme-config
463 GPGME_CONFIG_LIBS="-lgpgme"
464 GPGME_CONFIG_CFLAGS=""
465 AC_SUBST(GPGME_CONFIG_API_VERSION)
466 AC_SUBST(GPGME_CONFIG_LIBS)
467 AC_SUBST(GPGME_CONFIG_CFLAGS)
470 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
471 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
475 # Create config files
477 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
478 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
479 doc/Makefile complus/Makefile
480 gpgme/versioninfo.rc)
481 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
485 GPGME v${VERSION} has been configured as follows:
488 GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
491 GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
493 GPGME Pthread: $have_pthread