1 # configure.ac for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009, 2010, 2011, 2012, 2013 g10 Code GmbH
6 # This file is part of GPGME.
8 # GPGME is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as
10 # published by the Free Software Foundation; either version 2.1 of the
11 # License, or (at your option) any later version.
13 # GPGME is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
16 # Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
21 # (Process this file with autoconf to produce a configure script.)
23 min_automake_version="1.11"
25 # To build a release you need to create a tag with the version number
26 # (git tag -s gpgme-n.m.k) and run "./autogen.sh --force". Please
27 # bump the version number immediately after the release and do another
28 # commit and push so that the git magic is able to work. See below
29 # for the LT versions.
30 m4_define(mym4_version_major, [1])
31 m4_define(mym4_version_minor, [5])
32 m4_define(mym4_version_micro, [2])
34 # Below is m4 magic to extract and compute the revision number, the
35 # decimalized short revision number, a beta version string, and a flag
36 # indicating a development version (mym4_isgit). Note that the m4
37 # processing is done by autoconf and not during the configure run.
38 m4_define(mym4_version,
39 [mym4_version_major.mym4_version_minor.mym4_version_micro])
40 m4_define([mym4_revision],
41 m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
42 m4_define([mym4_revision_dec],
43 m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
44 m4_define([mym4_betastring],
45 m4_esyscmd_s([git describe --match 'gpgme-[0-9].*[0-9]' --long|\
46 awk -F- '$3!=0{print"-beta"$3}']))
47 m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
48 m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
50 AC_INIT([gpgme],[mym4_full_version],[http://bugs.gnupg.org])
52 # LT Version numbers, remember to change them just *before* a release.
53 # (Code changed: REVISION++)
54 # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
55 # (Interfaces added: AGE++)
56 # (Interfaces removed/changed: AGE=0)
58 LIBGPGME_LT_CURRENT=24
59 # Subtract 2 from this value if you want to make the LFS transition an
60 # ABI break. [Note to self: Remove this comment with the next regular break.]
62 LIBGPGME_LT_REVISION=1
64 # If the API is changed in an incompatible way: increment the next counter.
65 GPGME_CONFIG_API_VERSION=1
66 ##############################################
68 NEED_GPG_ERROR_VERSION=1.11
70 NEED_LIBASSUAN_VERSION=2.0.2
74 VERSION=$PACKAGE_VERSION
76 AC_CONFIG_AUX_DIR([build-aux])
77 AC_CONFIG_MACRO_DIR([m4])
78 AC_CONFIG_SRCDIR(src/gpgme.h.in)
79 AC_CONFIG_HEADER(config.h)
80 # Note: For automake 1.13 add the option
86 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
88 # Enable GNU extensions on systems that have them.
91 AH_VERBATIM([_REENTRANT],
92 [/* To allow the use of GPGME in multithreaded programs we have to use
93 special features from the library.
94 IMPORTANT: gpgme is not yet fully reentrant and you should use it
95 only from one thread. */
103 # Note: A suitable gitlog-to-changelog script can be found in GnuPG master.
104 AC_CHECK_PROGS(GITLOG_TO_CHANGELOG, gitlog-to-changelog, [gitlog-to-changelog])
106 AC_SUBST(LIBGPGME_LT_CURRENT)
107 AC_SUBST(LIBGPGME_LT_AGE)
108 AC_SUBST(LIBGPGME_LT_REVISION)
112 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
113 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
114 VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_version_major \
115 mym4_version_minor mym4_version_micro)
116 AC_SUBST(VERSION_NUMBER)
118 # Don't default to build static libs.
120 LT_INIT([win32-dll disable-static])
121 LT_LANG([Windows Resource])
123 # For now we hardcode the use of version scripts. It would be better
124 # to write a test for this or even implement this within libtool.
125 have_ld_version_script=no
128 have_ld_version_script=yes
131 have_ld_version_script=yes
134 AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X)
138 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
144 component_system=None
145 have_dosish_system=no
146 have_android_system=no
156 have_w32ce_system=yes
159 have_android_system=yes
163 *-mingw32ce*|*-mingw32*)
164 have_dosish_system=yes
166 GPG_DEFAULT='c:\\gnupg\\gpg.exe'
167 GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
168 GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
169 G13_DEFAULT='c:\\gnupg\\g13.exe'
170 #component_system='COM+'
173 AC_ARG_ENABLE(w32-glib,
174 AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
175 build_w32_glib=$enableval)
177 # Check disabled, because the qt-dev packages in gpg4win do
178 # not provide any support for cross compilation.
179 # PKG_CHECK_MODULES(QT4_CORE, QtCore)
182 # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
183 AC_SUBST(QT4_CORE_CFLAGS)
184 AC_SUBST(QT4_CORE_LIBS)
185 AC_ARG_ENABLE(w32-qt,
186 AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
187 build_w32_qt=$enableval)
190 AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
191 if test "$have_pthread" = yes; then
192 AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
195 # XXX: Probably use exec-prefix here?
196 # GPG_DEFAULT='/usr/bin/gpg'
197 # GPGSM_DEFAULT='/usr/bin/gpgsm'
198 # GPGCONF_DEFAULT='/usr/bin/gpgconf'
199 # G13_DEFAULT='/usr/bin/g13'
203 if test "$have_dosish_system" = yes; then
204 AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
205 [Defined if we run on some of the PCDOS like systems
206 (DOS, Windoze. OS/2) with special properties like
209 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
211 if test "$have_w32_system" = yes; then
212 AC_DEFINE(HAVE_W32_SYSTEM,1,
213 [Defined if we run on any kind of W32 API based system])
215 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
217 if test "$have_w64_system" = yes; then
218 AC_DEFINE(HAVE_W64_SYSTEM,1,
219 [Defined if we run on a 64 bit W32 API based system])
221 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
223 if test "$have_w32ce_system" = yes; then
224 AC_DEFINE(HAVE_W32CE_SYSTEM,1,
225 [Defined if we run on a W32 CE API based system])
227 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
229 if test "$have_android_system" = yes; then
230 AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
232 AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
234 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
235 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
237 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
240 AC_ARG_ENABLE([fixed-path],
241 AC_HELP_STRING([--enable-fixed-path=PATH],
242 [locate binaries only via this PATH]),
243 [fixed_search_path="$enableval"],
244 [fixed_search_path=""])
245 if test x$fixed_search_path != x ; then
246 AC_DEFINE_UNQUOTED(FIXED_SEARCH_PATH, "$fixed_search_path",
247 [Locate binaries only via this PATH])
252 # Provide information about the build.
254 BUILD_REVISION="mym4_revision"
255 AC_SUBST(BUILD_REVISION)
256 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
257 [GIT commit id revision used to build this package])
260 BUILD_FILEVERSION=`echo "$PACKAGE_VERSION"|sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
262 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
263 AC_SUBST(BUILD_FILEVERSION)
265 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
266 AC_SUBST(BUILD_TIMESTAMP)
267 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
268 [The time this package was configured for a build])
271 # Options to disable some regression tests
273 run_gpgconf_test="yes"
274 AC_ARG_ENABLE(gpgconf-test,
275 AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF regression test]),
276 run_gpgconf_test=$enableval)
277 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
280 AC_ARG_ENABLE(gpg-test,
281 AC_HELP_STRING([--disable-gpg-test], [disable GPG regression test]),
282 run_gpg_test=$enableval)
283 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
286 AC_ARG_ENABLE(gpgsm-test,
287 AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM regression test]),
288 run_gpgsm_test=$enableval)
289 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
292 AC_ARG_ENABLE(g13-test,
293 AC_HELP_STRING([--disable-g13-test], [disable G13 regression test]),
294 run_g13_test=$enableval)
295 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
298 # Checks for header files.
299 AC_CHECK_HEADERS_ONCE([locale.h sys/select.h sys/uio.h argp.h
300 unistd.h sys/time.h sys/types.h sys/stat.h])
305 AC_CHECK_SIZEOF(unsigned int)
310 # A simple compile time check in gpgme.h for GNU/Linux systems that
311 # prevents a file offset bits mismatch between gpgme and the application.
312 NEED__FILE_OFFSET_BITS=0
313 if test "$have_w32_system" != yes; then
314 case "$ac_cv_sys_file_offset_bits" in
315 "" | no | unknown) ;;
317 NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
321 AC_SUBST(NEED__FILE_OFFSET_BITS)
323 # Figure out platform dependent typedefs for gpgme.h
324 if test "$have_w32_system" = yes; then
325 INSERT__TYPEDEFS_FOR_GPGME_H="
328 typedef int64_t gpgme_off_t;
329 typedef int64_t gpgme_ssize_t;
331 typedef long gpgme_off_t;
332 typedef long gpgme_ssize_t;
334 API__OFF_T="gpgme_off_t"
335 API__SSIZE_T="gpgme_ssize_t"
337 INSERT__TYPEDEFS_FOR_GPGME_H="
338 #include <sys/types.h>
339 typedef off_t gpgme_off_t;
340 typedef ssize_t gpgme_ssize_t;"
342 API__SSIZE_T="ssize_t"
344 AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H)
345 AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H)
347 AM_SUBST_NOTMAKE(API__OFF_T)
348 AC_SUBST(API__SSIZE_T)
349 AM_SUBST_NOTMAKE(API__SSIZE_T)
351 # Checks for compiler features.
352 if test "$GCC" = yes; then
353 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
354 if test "$have_w32_system" = yes; then
355 CFLAGS="$CFLAGS -mms-bitfields"
359 # Only used for debugging, so no serious test needed (for actual
360 # functionality you have to test libc as well, this only tests the
362 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
363 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([__thread int foo;])],
364 gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
365 if test "$gpgme_cv_tls_works" = yes; then
366 AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
370 # Checks for library functions.
371 AC_MSG_NOTICE([checking for libraries])
375 AC_REPLACE_FUNCS(vasprintf)
376 if test "$ac_cv_func_vasprintf" != yes; then
380 # Try to find a thread-safe version of ttyname().
381 gnupg_REPLACE_TTYNAME_R
382 if test "$ac_cv_func_ttyname_r" != yes; then
385 *** ttyname() is not thread-safe and ttyname_r() does not exist
389 # Try to find a thread-safe version of getenv().
390 have_thread_safe_getenv=no
392 if test $GLIBC21 = yes; then
393 have_thread_safe_getenv=yes
395 if test $have_thread_safe_getenv = yes; then
396 AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
399 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
400 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
403 *** getenv() is not thread-safe and getenv_r() does not exist
407 # For converting time strings to seconds since Epoch, we need the timegm
409 AC_CHECK_FUNCS(timegm)
410 if test "$ac_cv_func_timegm" != yes; then
413 *** timegm() not available - a non-thread-safe kludge will be used
414 *** and the TZ variable might be changed at runtime.
418 AC_CHECK_FUNCS(setlocale)
420 # Checking for libgpg-error.
422 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
423 have_gpg_error=yes, have_gpg_error=no)
424 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
425 [The default error source for GPGME.])
429 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
430 have_libassuan=yes, have_libassuan=no)
431 if test "$have_libassuan" = "yes"; then
432 AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
433 [version of the libassuan library])
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
447 AC_REPLACE_FUNCS(funopen)
451 *** No implementation of fopencookie or funopen available
456 # Check for getgid etc
457 AC_CHECK_FUNCS(getgid getegid)
460 # Replacement functions.
461 AC_REPLACE_FUNCS(stpcpy)
462 AC_REPLACE_FUNCS(setenv)
464 # Assuan check for descriptor passing.
465 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
466 [supports_descriptor_passing=yes],
467 [supports_descriptor_passing=no
470 *** Data structure for sending ancillary data missing.
471 *** Descriptor passing won't work.
476 #include <sys/types.h>
477 #include <sys/socket.h>
486 dnl There seems to be a problem with Apple and decriptor passing.
487 dnl Until we found a solution we change the default to no.
491 use_descriptor_passing=no
494 use_descriptor_passing=yes
497 AC_ARG_ENABLE(fd-passing,
498 AC_HELP_STRING([--disable-fd-passing], [do not use FD passing]),
499 use_descriptor_passing=$enableval)
501 if test "$supports_descriptor_passing" != "yes"; then
502 use_descriptor_passing=no
505 if test "$use_descriptor_passing" = "yes"; then
506 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
507 [Defined if descriptor passing is enabled and supported])
510 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
514 if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then
517 if test "$uiserver" != "no"; then
518 AC_DEFINE(ENABLE_UISERVER, 1,
519 [Defined if we are building with uiserver support.])
521 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
524 # Add a few constants to help porting to W32
525 AH_VERBATIM([SEPCONSTANTS],
527 /* Separators as used in $PATH and file name. */
528 #ifdef HAVE_DOSISH_SYSTEM
529 #define PATHSEP_C ';'
530 #define DIRSEP_C '\\'
531 #define DIRSEP_S "\\"
533 #define PATHSEP_C ':'
540 /* Definition of GCC specific attributes. */
542 # define GPGME_GCC_A_PURE __attribute__ ((__pure__))
544 # define GPGME_GCC_A_PURE
547 /* Under WindowsCE we need gpg-error's strerror macro. */
548 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
550 #define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \
551 "Copyright (C) 2001--2013 g10 Code GmbH\n"
555 # Substitution used for gpgme-config
556 GPGME_CONFIG_LIBS="-lgpgme"
557 GPGME_CONFIG_CFLAGS=""
558 GPGME_CONFIG_HOST="$host"
559 AC_SUBST(GPGME_CONFIG_API_VERSION)
560 AC_SUBST(GPGME_CONFIG_LIBS)
561 AC_SUBST(GPGME_CONFIG_CFLAGS)
562 AC_SUBST(GPGME_CONFIG_HOST)
565 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
566 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
569 # Some checks for gpgme-tool
570 # Done at top: AC_CHECK_HEADER([argp.h])
571 AC_CHECK_TYPES([error_t], [],
572 [AC_DEFINE([error_t], [int],
573 [Define to a type to use for `error_t' if it is not otherwise available.])],
574 [#include <errno.h>])
577 # A substitution to set generated files in a Emacs buffer to read-only.
578 AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
579 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
580 AC_SUBST(emacs_local_vars_end, ['End:'])
585 if test "$have_gpg_error" = "no"; then
589 *** You need libgpg-error to build this program.
590 ** This library is for example available at
591 *** ftp://ftp.gnupg.org/gcrypt/libgpg-error
592 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
595 if test "$have_libassuan" = "no"; then
599 *** You need libassuan to build this program.
600 *** This library is for example available at
601 *** ftp://ftp.gnupg.org/gcrypt/libassuan/
602 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
606 if test "$die" = "yes"; then
609 *** Required libraries not found. Please consult the above messages
610 *** and install them before running configure again.
616 # Create config files
618 AC_CONFIG_FILES(Makefile src/Makefile
622 tests/opassuan/Makefile
626 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
627 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
631 GPGME v${VERSION} has been configured as follows:
633 Revision: mym4_revision (mym4_revision_dec)
637 FD Passing: $use_descriptor_passing
638 GPGME Pthread: $have_pthread
640 if test "x${gpg_config_script_warn}" != x; then
642 Mismatches between the target platform and the to
643 be used libraries have been been detected for:
644 ${gpg_config_script_warn}
645 Please check above for warning messages.