python: Support adding and revoking UIDs.
[gpgme.git] / configure.ac
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, 2014, 2015  g10 Code GmbH
5 #
6 # This file is part of GPGME.
7 #
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.
12 #
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.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <https://www.gnu.org/licenses/>.
20
21 # (Process this file with autoconf to produce a configure script.)
22 AC_PREREQ(2.59)
23 min_automake_version="1.14"
24
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, [8])
32 m4_define(mym4_version_micro, [1])
33
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])
49
50 AC_INIT([gpgme],[mym4_full_version],[http://bugs.gnupg.org])
51
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)
57 #
58 LIBGPGME_LT_CURRENT=28
59 LIBGPGME_LT_AGE=17
60 LIBGPGME_LT_REVISION=0
61
62 # If there is an ABI break in gpgmepp or qgpgme also bump the
63 # version in IMPORTED_LOCATION in the GpgmeppConfig-w32.cmake.in.in
64
65 LIBGPGMEPP_LT_CURRENT=9
66 LIBGPGMEPP_LT_AGE=3
67 LIBGPGMEPP_LT_REVISION=0
68
69 LIBQGPGME_LT_CURRENT=8
70 LIBQGPGME_LT_AGE=1
71 LIBQGPGME_LT_REVISION=0
72
73 # If the API is changed in an incompatible way: increment the next counter.
74 GPGME_CONFIG_API_VERSION=1
75 ##############################################
76
77 NEED_GPG_ERROR_VERSION=1.17
78 NEED_LIBASSUAN_API=2
79 NEED_LIBASSUAN_VERSION=2.0.2
80
81
82 PACKAGE=$PACKAGE_NAME
83 VERSION=$PACKAGE_VERSION
84
85 VERSION_MAJOR=mym4_version_major
86 VERSION_MINOR=mym4_version_minor
87 VERSION_MICRO=mym4_version_micro
88
89 AC_CONFIG_AUX_DIR([build-aux])
90 AC_CONFIG_MACRO_DIR([m4])
91 AC_CONFIG_SRCDIR(src/gpgme.h.in)
92 AC_CONFIG_HEADER(config.h)
93 AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
94 AM_MAINTAINER_MODE
95 AC_CANONICAL_HOST
96 AM_SILENT_RULES
97 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
98
99 # Enable GNU extensions on systems that have them.
100 AC_GNU_SOURCE
101
102 AH_VERBATIM([_REENTRANT],
103 [/* To allow the use of GPGME in multithreaded programs we have to use
104   special features from the library.
105   IMPORTANT: gpgme is not yet fully reentrant and you should use it
106   only from one thread.  */
107 #ifndef _REENTRANT
108 # define _REENTRANT 1
109 #endif])
110
111 AC_PROG_CC
112 AC_PROG_CXX
113
114 # Note: A suitable gitlog-to-changelog script can be found in GnuPG master.
115 AC_CHECK_PROGS(GITLOG_TO_CHANGELOG, gitlog-to-changelog, [gitlog-to-changelog])
116
117 AC_SUBST(LIBGPGME_LT_CURRENT)
118 AC_SUBST(LIBGPGME_LT_AGE)
119 AC_SUBST(LIBGPGME_LT_REVISION)
120 AC_SUBST(LIBGPGMEPP_LT_CURRENT)
121 AC_SUBST(LIBGPGMEPP_LT_AGE)
122 AC_SUBST(LIBGPGMEPP_LT_REVISION)
123 AC_SUBST(LIBQGPGME_LT_CURRENT)
124 AC_SUBST(LIBQGPGME_LT_AGE)
125 AC_SUBST(LIBQGPGME_LT_REVISION)
126
127 AC_SUBST(PACKAGE)
128 AC_SUBST(VERSION)
129 AC_SUBST(VERSION_MAJOR)
130 AC_SUBST(VERSION_MINOR)
131 AC_SUBST(VERSION_MICRO)
132 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
133 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
134 VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_version_major \
135                           mym4_version_minor mym4_version_micro)
136 AC_SUBST(VERSION_NUMBER)
137
138 # We need to compile and run a program on the build machine.  A
139 # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
140 # the AC archive is broken for autoconf 2.57.  Given that there is no
141 # newer version of that macro, we assume that it is also broken for
142 # autoconf 2.61 and thus we use a simple but usually sufficient
143 # approach.
144 AC_MSG_CHECKING(for cc for build)
145 if test "$cross_compiling" = "yes"; then
146   CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
147 else
148   CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
149 fi
150 AC_MSG_RESULT($CC_FOR_BUILD)
151 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
152
153
154 # Don't default to build static libs.
155 LT_PREREQ([2.2.6])
156 LT_INIT([win32-dll disable-static])
157 LT_LANG([Windows Resource])
158
159 # For now we hardcode the use of version scripts.  It would be better
160 # to write a test for this or even implement this within libtool.
161 have_ld_version_script=no
162 case "${host}" in
163     *-*-linux*)
164         have_ld_version_script=yes
165         ;;
166     *-*-gnu*)
167         have_ld_version_script=yes
168         ;;
169     *-apple-darwin*)
170         AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
171                   Expose all libc features (__DARWIN_C_FULL).)
172         AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X)
173         ;;
174 esac
175
176 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
177
178 GPG_DEFAULT=no
179 GPGSM_DEFAULT=no
180 GPGCONF_DEFAULT=no
181 G13_DEFAULT=no
182 component_system=None
183 have_dosish_system=no
184 have_android_system=no
185 have_w32_system=no
186 have_w64_system=no
187 have_macos_system=no
188 build_w32_glib=no
189 build_w32_qt=no
190 available_languages="cl cpp python python2 python3 qt"
191 default_languages="cl cpp python qt"
192 case "${host}" in
193     x86_64-*mingw32*)
194         have_w64_system=yes
195         ;;
196     *-mingw32ce*)
197         have_w32ce_system=yes
198         ;;
199     *-linux-androideabi)
200         have_android_system=yes
201         ;;
202     *-apple-darwin*)
203         have_macos_system=yes
204         ;;
205 esac
206 case "${host}" in
207     *-mingw32ce*|*-mingw32*)
208         have_dosish_system=yes
209         have_w32_system=yes
210         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
211         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
212         GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
213         G13_DEFAULT='c:\\gnupg\\g13.exe'
214         #component_system='COM+'
215
216         AM_PATH_GLIB_2_0
217         AC_ARG_ENABLE(w32-glib,
218             AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
219                            build_w32_glib=$enableval)
220        ;;
221     *)
222
223         # XXX: Probably use exec-prefix here?
224 #       GPG_DEFAULT='/usr/bin/gpg'
225 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
226 #       GPGCONF_DEFAULT='/usr/bin/gpgconf'
227 #       G13_DEFAULT='/usr/bin/g13'
228         ;;
229 esac
230
231 if test "$have_dosish_system" = yes; then
232    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
233              [Defined if we run on some of the PCDOS like systems
234               (DOS, Windoze. OS/2) with special properties like
235               no file modes])
236 fi
237 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
238
239 if test "$have_w32_system" = yes; then
240    AC_DEFINE(HAVE_W32_SYSTEM,1,
241              [Defined if we run on any kind of W32 API based system])
242 fi
243 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
244
245 if test "$have_w64_system" = yes; then
246    AC_DEFINE(HAVE_W64_SYSTEM,1,
247              [Defined if we run on a 64 bit W32 API based system])
248 fi
249 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
250
251 if test "$have_w32ce_system" = yes; then
252    AC_DEFINE(HAVE_W32CE_SYSTEM,1,
253              [Defined if we run on a W32 CE API based system])
254 fi
255 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
256
257 if test "$have_android_system" = yes; then
258    AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
259 fi
260 AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
261
262 if test "$have_macos_system" = yes; then
263    AC_DEFINE(HAVE_MACOS_SYSTEM,1,
264              [Defined if we build for an MacOS system])
265 fi
266 AM_CONDITIONAL(HAVE_MACOS_SYSTEM, test "$have_macos_system" = yes)
267
268 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
269
270
271 AC_ARG_ENABLE([fixed-path],
272               AC_HELP_STRING([--enable-fixed-path=PATH],
273                              [locate binaries only via this PATH]),
274               [fixed_search_path="$enableval"],
275               [fixed_search_path=""])
276 if test x$fixed_search_path != x ; then
277   AC_DEFINE_UNQUOTED(FIXED_SEARCH_PATH, "$fixed_search_path",
278                     [Locate binaries only via this PATH])
279 fi
280
281
282 # Note: You need to declare all possible langauges also in
283 #       lang/Makefile.am's DIST_SUBDIRS.
284 AC_ARG_ENABLE([languages],
285               AC_HELP_STRING([--enable-languages=languages],
286                              [enable only specific language bindings]),
287                              [enabled_languages=`echo $enableval | \
288                              tr ',:' '  ' | tr '[A-Z]' '[a-z]' | \
289                              sed 's/c++/cpp/'`],
290                              [enabled_languages="maybe"])
291 if test "x$enabled_languages" = "x" \
292    -o "$enabled_languages" = "no"; then
293    enabled_languages=
294 fi
295
296 # If languages are explicitly set missing requirements
297 # for the languages are treated as errors otherwise
298 # there will be a warning.
299 explicit_languages=1
300 if test "x$enabled_languages" = "xmaybe"; then
301     explicit_languages=0
302     enabled_languages="$default_languages"
303 fi
304
305 for language in $enabled_languages; do
306     LIST_MEMBER($language, $available_languages)
307     if test "$found" = "0"; then
308        AC_MSG_ERROR([unsupported language binding specified])
309     fi
310 done
311
312
313
314 # Enable C++ 11 if cpp language is requested
315 LIST_MEMBER("cpp", $enabled_languages)
316 if test "$found" = "1"; then
317     AX_CXX_COMPILE_STDCXX(11, noext, optional)
318     if test "$HAVE_CXX11" != "1"; then
319         if test "$explicit_languages" = "1"; then
320             AC_MSG_ERROR([[
321 ***
322 *** A compiler with c++11 support is required for the c++ binding.
323 ***]])
324         else
325             enabled_languages=$(echo $enabled_languages | sed 's/cpp//')
326             enabled_languages=$(echo $enabled_languages | sed 's/qt//')
327             AC_MSG_WARN([[
328 ***
329 *** No c++11 support detected. C++ and Qt bindings will be disabled.
330 ***]])
331         fi
332     fi
333 fi
334
335 # Check that if qt is enabled cpp also is enabled
336 LIST_MEMBER("qt", $enabled_languages)
337 if test "$found" = "1"; then
338     # We need to ensure that in the langauge order qt comes after cpp
339     # so we remove qt first and explicitly add it as last list member.
340     enabled_languages=$(echo $enabled_languages | sed 's/qt//')
341     LIST_MEMBER("cpp", $enabled_languages)
342     if test "$found" = "0"; then
343         AC_MSG_ERROR([[
344 ***
345 *** Qt language binding depends on cpp binding.
346 ***]])
347     fi
348     FIND_QT
349     if test "$have_qt5_libs" != "yes"; then
350         if test "$explicit_languages" = "1"; then
351         AC_MSG_ERROR([[
352 ***
353 *** Qt5 (Qt5Core) is required for Qt binding.
354 ***]])
355         else
356            AC_MSG_WARN([[
357 ***
358 *** Qt5 (Qt5Core) not found Qt Binding will be disabled.
359 ***]])
360         fi
361     else
362         enabled_languages=`echo $enabled_languages qt`
363
364         AC_CHECK_PROGS([DOXYGEN], [doxygen])
365         if test -z "$DOXYGEN";
366             # This is not highlighted becase it's not really important.
367             then AC_MSG_WARN([Doxygen not found - Qt binding doc will not be built.])
368         fi
369         AC_CHECK_PROGS([GRAPHVIZ], [dot])
370         if test -z "$GRAPHVIZ";
371             then AC_MSG_WARN([Graphviz not found - Qt binding doc will not have diagrams.])
372         fi
373     fi
374 fi
375 AM_CONDITIONAL([HAVE_DOXYGEN],
376                [test -n "$DOXYGEN"])
377 if test -n "$GRAPHVIZ"; then
378     HAVE_DOT="YES"
379 else
380     HAVE_DOT="NO"
381 fi
382 AC_SUBST(HAVE_DOT)
383
384 # Python bindings.
385 LIST_MEMBER("python2", $enabled_languages)
386 found_py2=$found
387 LIST_MEMBER("python3", $enabled_languages)
388 found_py3=$found
389 LIST_MEMBER("python", $enabled_languages)
390 found_py=$found
391 if test "$found_py" = "1" -o "$found_py2" = "1" -o "$found_py3" = "1"; then
392     AX_PKG_SWIG
393     if test -z "$SWIG"; then
394         if test "$explicit_languages" = "1"; then
395             AC_MSG_ERROR([[
396 ***
397 *** You need SWIG to build the Python bindings.
398 ***]])
399         else
400             enabled_languages=$(echo $enabled_languages | sed 's/python//')
401         fi
402     else
403         # Reset all the stuff, just to be sure.
404         PYTHONS=
405         PYTHON_VERSIONS=
406         unset PYTHON
407         unset PYTHON_VERSION
408         unset PYTHON_CPPFLAGS
409         unset PYTHON_LDFLAGS
410         unset PYTHON_SITE_PKG
411         unset PYTHON_EXTRA_LIBS
412         unset PYTHON_EXTRA_LDFLAGS
413         unset ac_cv_path_PYTHON
414         unset am_cv_pathless_PYTHON
415         unset am_cv_python_version
416         unset am_cv_python_platform
417         unset am_cv_python_pythondir
418         unset am_cv_python_pyexecdir
419
420         if test "$found_py" = "1" -o "$found_py2" = "1"; then
421             AM_PATH_PYTHON([2.7])
422             AX_PYTHON_DEVEL
423             if test "$PYTHON_VERSION"; then
424                 PYTHONS="$(echo $PYTHONS $PYTHON)"
425                 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
426             fi
427         fi
428
429         if test "$found_py" = "1" -o "$found_py3" = "1"; then
430             # Reset everything, so that we can look for another Python.
431             unset PYTHON
432             unset PYTHON_VERSION
433             unset PYTHON_CPPFLAGS
434             unset PYTHON_LDFLAGS
435             unset PYTHON_SITE_PKG
436             unset PYTHON_EXTRA_LIBS
437             unset PYTHON_EXTRA_LDFLAGS
438             unset ac_cv_path_PYTHON
439             unset am_cv_pathless_PYTHON
440             unset am_cv_python_version
441             unset am_cv_python_platform
442             unset am_cv_python_pythondir
443             unset am_cv_python_pyexecdir
444             AM_PATH_PYTHON([3.4])
445             AX_PYTHON_DEVEL
446             if test "$PYTHON_VERSION"; then
447                 PYTHONS="$(echo $PYTHONS $PYTHON)"
448                 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
449             fi
450         fi
451
452         if test "$PYTHON_VERSIONS"; then
453            enabled_languages_v=$(echo $enabled_languages | sed "s/python\([[23]]\)\?/python ($PYTHON_VERSIONS)/")
454            enabled_languages=$(echo $enabled_languages | sed "s/python\([[23]]\)\?/python/")
455         else
456             if test "$explicit_languages" = "1"; then
457                 AC_MSG_ERROR([[
458 ***
459 *** Please install the python development packages.
460 ***]])
461             else
462                 enabled_languages=$(echo $enabled_languages | sed 's/python//')
463             fi
464         fi
465
466         AC_SUBST(PYTHONS, $PYTHONS)
467         AC_SUBST(PYTHON_VERSIONS, $PYTHON_VERSIONS)
468     fi
469 fi
470
471 AC_SUBST(ENABLED_LANGUAGES, $enabled_languages)
472
473 #
474 # Provide information about the build.
475 #
476 BUILD_REVISION="mym4_revision"
477 AC_SUBST(BUILD_REVISION)
478 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
479                    [GIT commit id revision used to build this package])
480
481 changequote(,)dnl
482 BUILD_FILEVERSION=`echo "$PACKAGE_VERSION"|sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
483 changequote([,])dnl
484 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
485 AC_SUBST(BUILD_FILEVERSION)
486
487 AC_ARG_ENABLE([build-timestamp],
488   AC_HELP_STRING([--enable-build-timestamp],
489                  [set an explicit build timestamp for reproducibility.
490                   (default is the current time in ISO-8601 format)]),
491      [if test "$enableval" = "yes"; then
492         BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
493       else
494         BUILD_TIMESTAMP="$enableval"
495       fi],
496      [BUILD_TIMESTAMP="<none>"])
497 AC_SUBST(BUILD_TIMESTAMP)
498 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
499                    [The time this package was configured for a build])
500
501
502 #
503 # Options to disable some regression tests
504 #
505 run_gpgconf_test="yes"
506 AC_ARG_ENABLE(gpgconf-test,
507   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF regression test]),
508          run_gpgconf_test=$enableval)
509 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
510
511 run_gpg_test="yes"
512 AC_ARG_ENABLE(gpg-test,
513   AC_HELP_STRING([--disable-gpg-test], [disable GPG regression test]),
514          run_gpg_test=$enableval)
515 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
516
517 run_gpgsm_test="yes"
518 AC_ARG_ENABLE(gpgsm-test,
519   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM regression test]),
520          run_gpgsm_test=$enableval)
521 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
522
523 run_g13_test="yes"
524 AC_ARG_ENABLE(g13-test,
525   AC_HELP_STRING([--disable-g13-test], [disable G13 regression test]),
526          run_g13_test=$enableval)
527 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
528
529
530 # Checks for header files.
531 AC_CHECK_HEADERS_ONCE([locale.h sys/select.h sys/uio.h argp.h
532                        unistd.h sys/time.h sys/types.h sys/stat.h])
533
534
535 # Type checks.
536 AC_C_INLINE
537 AC_CHECK_SIZEOF(unsigned int)
538 AC_SYS_LARGEFILE
539 AC_TYPE_OFF_T
540 AC_TYPE_UINTPTR_T
541
542 # A simple compile time check in gpgme.h for GNU/Linux systems that
543 # prevents a file offset bits mismatch between gpgme and the application.
544 NEED__FILE_OFFSET_BITS=0
545 if test "$have_w32_system" != yes; then
546   case "$ac_cv_sys_file_offset_bits" in
547     "" | no | unknown) ;;
548     *)
549     NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
550     ;;
551   esac
552 fi
553 AC_SUBST(NEED__FILE_OFFSET_BITS)
554
555 # Figure out platform dependent typedefs for gpgme.h
556 if test "$have_w32_system" = yes; then
557     INSERT__TYPEDEFS_FOR_GPGME_H="
558 #ifdef _WIN64
559 # include <stdint.h>
560   typedef int64_t gpgme_off_t;
561   typedef int64_t gpgme_ssize_t;
562 #else /* _WIN32 */
563   typedef long gpgme_off_t;
564   typedef long gpgme_ssize_t;
565 #endif /* _WIN32 */"
566     API__OFF_T="gpgme_off_t"
567     API__SSIZE_T="gpgme_ssize_t"
568 else
569     INSERT__TYPEDEFS_FOR_GPGME_H="
570 #include <sys/types.h>
571 typedef off_t   gpgme_off_t;
572 typedef ssize_t gpgme_ssize_t;"
573     API__OFF_T="off_t"
574     API__SSIZE_T="ssize_t"
575 fi
576 AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H)
577 AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H)
578 AC_SUBST(API__OFF_T)
579 AM_SUBST_NOTMAKE(API__OFF_T)
580 AC_SUBST(API__SSIZE_T)
581 AM_SUBST_NOTMAKE(API__SSIZE_T)
582
583 # Checks for compiler features.
584 if test "$GCC" = yes; then
585     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
586     if test "$USE_MAINTAINER_MODE" = "yes"; then
587         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
588
589         # If -Wno-missing-field-initializers is supported we can enable a
590         # a bunch of really useful warnings.
591         AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
592         _gcc_cflags_save=$CFLAGS
593         CFLAGS="-Wno-missing-field-initializers"
594         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
595         AC_MSG_RESULT($_gcc_wopt)
596         CFLAGS=$_gcc_cflags_save;
597         if test x"$_gcc_wopt" = xyes ; then
598           CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
599           CFLAGS="$CFLAGS -Wwrite-strings"
600           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
601           CFLAGS="$CFLAGS -Wno-missing-field-initializers"
602           CFLAGS="$CFLAGS -Wno-sign-compare"
603         fi
604         CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-shadow"
605
606         AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
607         _gcc_cflags_save=$CFLAGS
608         CFLAGS="-Wpointer-arith"
609         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
610         AC_MSG_RESULT($_gcc_wopt)
611         CFLAGS=$_gcc_cflags_save;
612         if test x"$_gcc_wopt" = xyes ; then
613           CFLAGS="$CFLAGS -Wpointer-arith"
614         fi
615     fi
616     if test "$have_w32_system" = yes; then
617        CFLAGS="$CFLAGS -mms-bitfields"
618     fi
619 fi
620
621 # Only used for debugging, so no serious test needed (for actual
622 # functionality you have to test libc as well, this only tests the
623 # compiler).
624 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
625    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([__thread int foo;])],
626                      gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
627 if test "$gpgme_cv_tls_works" = yes; then
628   AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
629 fi
630
631
632 # Checks for library functions.
633 AC_MSG_NOTICE([checking for libraries])
634
635 AC_FUNC_FSEEKO
636
637 # Try to find a thread-safe version of ttyname().
638 gnupg_REPLACE_TTYNAME_R
639 if test "$ac_cv_func_ttyname_r" != yes; then
640   AC_MSG_WARN([
641 ***
642 *** ttyname() is not thread-safe and ttyname_r() does not exist
643 ***])
644 fi
645
646 # Try to find a thread-safe version of getenv().
647 have_thread_safe_getenv=no
648 jm_GLIBC21
649 if test $GLIBC21 = yes; then
650   have_thread_safe_getenv=yes
651 fi
652 if test $have_thread_safe_getenv = yes; then
653   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
654 fi
655 have_getenv_r=no
656 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
657 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
658   AC_MSG_WARN([
659 ***
660 *** getenv() is not thread-safe and getenv_r() does not exist
661 ***])
662 fi
663
664 # For converting time strings to seconds since Epoch, we need the timegm
665 # function.
666 AC_CHECK_FUNCS(timegm)
667 if test "$ac_cv_func_timegm" != yes; then
668   AC_MSG_WARN([
669 ***
670 *** timegm() not available - a non-thread-safe kludge will be used
671 *** and the TZ variable might be changed at runtime.
672 ***])
673 fi
674
675 AC_CHECK_FUNCS(setlocale)
676
677 # Checking for libgpg-error.
678 have_gpg_error=no
679 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
680                   have_gpg_error=yes, have_gpg_error=no)
681 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
682           [The default error source for GPGME.])
683
684 # And for libassuan.
685 have_libassuan=no
686 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
687                   have_libassuan=yes, have_libassuan=no)
688 if test "$have_libassuan" = "yes"; then
689   AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
690                      [version of the libassuan library])
691 fi
692
693
694 #
695 # Other checks
696 #
697
698 # Check for getgid etc
699 AC_CHECK_FUNCS(getgid getegid closefrom)
700
701
702 # Replacement functions.
703 AC_REPLACE_FUNCS(stpcpy)
704 AC_REPLACE_FUNCS(setenv)
705
706 # Assuan check for descriptor passing.
707 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
708                 [supports_descriptor_passing=yes],
709                 [supports_descriptor_passing=no
710                  AC_MSG_WARN([
711 ***
712 *** Data structure for sending ancillary data missing.
713 *** Descriptor passing won't work.
714 ***])],[
715 #include <stdlib.h>
716 #include <stddef.h>
717 #include <stdio.h>
718 #include <sys/types.h>
719 #include <sys/socket.h>
720 #include <sys/un.h>
721 #if HAVE_SYS_UIO_H
722 #include <sys/uio.h>
723 #endif
724 #include <unistd.h>
725        ])
726
727 use_descriptor_passing=yes
728 AC_ARG_ENABLE(fd-passing,
729   AC_HELP_STRING([--disable-fd-passing], [do not use FD passing]),
730   use_descriptor_passing=$enableval)
731
732 if test "$supports_descriptor_passing" != "yes"; then
733   use_descriptor_passing=no
734 fi
735
736 if test "$use_descriptor_passing" = "yes"; then
737 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
738           [Defined if descriptor passing is enabled and supported])
739 fi
740
741 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
742
743
744 uiserver=no
745 if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then
746   uiserver=yes
747 fi
748 if test "$uiserver" != "no"; then
749   AC_DEFINE(ENABLE_UISERVER, 1,
750             [Defined if we are building with uiserver support.])
751 fi
752 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
753
754
755 # Add a few constants to help porting to W32
756 AH_VERBATIM([SEPCONSTANTS],
757 [
758 /* Separators as used in $PATH and file name.  */
759 #ifdef HAVE_DOSISH_SYSTEM
760 #define PATHSEP_C ';'
761 #define DIRSEP_C '\\'
762 #define DIRSEP_S "\\"
763 #else
764 #define PATHSEP_C ':'
765 #define DIRSEP_C '/'
766 #define DIRSEP_S "/"
767 #endif
768 ])
769
770 AH_BOTTOM([
771 /* Definition of GCC specific attributes.  */
772 #if __GNUC__ > 2
773 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
774 #else
775 # define GPGME_GCC_A_PURE
776 #endif
777
778 /* Under WindowsCE we need gpg-error's strerror macro.  */
779 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
780
781 #define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \
782                     "Copyright (C) 2001--2016 g10 Code GmbH\n"
783 ])
784
785
786 # Substitution used for gpgme-config
787 GPGME_CONFIG_LIBS="-lgpgme"
788 GPGME_CONFIG_CFLAGS=""
789 GPGME_CONFIG_HOST="$host"
790 GPGME_CONFIG_AVAIL_LANG="$enabled_languages"
791 AC_SUBST(GPGME_CONFIG_API_VERSION)
792 AC_SUBST(GPGME_CONFIG_LIBS)
793 AC_SUBST(GPGME_CONFIG_CFLAGS)
794 AC_SUBST(GPGME_CONFIG_HOST)
795 AC_SUBST(GPGME_CONFIG_AVAIL_LANG)
796
797 # Frob'da Variables
798 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
799            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
800 AC_SUBST(LTLIBOBJS)
801
802 # Some checks for gpgme-tool
803 # Done at top: AC_CHECK_HEADER([argp.h])
804 AC_CHECK_TYPES([error_t], [],
805    [AC_DEFINE([error_t], [int],
806    [Define to a type to use for `error_t' if it is not otherwise available.])],
807    [#include <errno.h>])
808
809
810 # A substitution to set generated files in a Emacs buffer to read-only.
811 AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
812 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
813 AC_SUBST(emacs_local_vars_end, ['End:'])
814
815 # Last check.
816 die=no
817 if test "$have_gpg_error" = "no"; then
818    die=yes
819    AC_MSG_NOTICE([[
820 ***
821 *** You need libgpg-error to build this program.
822 **  This library is for example available at
823 ***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
824 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
825 ***]])
826 fi
827 if test "$have_libassuan" = "no"; then
828    die=yes
829    AC_MSG_NOTICE([[
830 ***
831 *** You need libassuan to build this program.
832 *** This library is for example available at
833 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
834 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
835 ***]])
836 fi
837
838 if test "$die" = "yes"; then
839     AC_MSG_ERROR([[
840 ***
841 *** Required libraries not found. Please consult the above messages
842 *** and install them before running configure again.
843 ***]])
844 fi
845
846
847 #
848 # Create config files
849
850 AC_CONFIG_FILES(Makefile src/Makefile
851                 tests/Makefile
852                 tests/gpg/Makefile
853                 tests/gpgsm/Makefile
854                 tests/opassuan/Makefile
855                 doc/Makefile
856                 src/versioninfo.rc
857                 src/gpgme.h)
858 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
859 AC_CONFIG_FILES(lang/cpp/Makefile lang/cpp/src/Makefile)
860 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig-w32.cmake.in)
861 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig.cmake.in)
862 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfigVersion.cmake)
863 AC_CONFIG_FILES(lang/cpp/src/gpgmepp_version.h)
864 AC_CONFIG_FILES(lang/qt/Makefile lang/qt/src/Makefile)
865 AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig-w32.cmake.in)
866 AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig.cmake.in)
867 AC_CONFIG_FILES(lang/qt/src/QGpgmeConfigVersion.cmake)
868 AC_CONFIG_FILES(lang/qt/tests/Makefile)
869 AC_CONFIG_FILES(lang/qt/src/qgpgme_version.h)
870 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
871 AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])])
872 AC_CONFIG_FILES(lang/qt/doc/Makefile)
873 AC_CONFIG_FILES([lang/python/Makefile
874                  lang/python/gpg/version.py
875                  lang/python/tests/Makefile])
876 AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
877 AC_OUTPUT
878
879 echo "
880         GPGME v${VERSION} has been configured as follows:
881
882         Revision:          mym4_revision  (mym4_revision_dec)
883         Platform:          $host
884
885         UI Server:         $uiserver
886         FD Passing:        $use_descriptor_passing
887
888         Language bindings: ${enabled_languages_v:-$enabled_languages}
889 "
890 if test "x${gpg_config_script_warn}" != x; then
891 cat <<G10EOF
892         Mismatches between the target platform and the to
893         be used libraries have been been detected for:
894          ${gpg_config_script_warn}
895         Please check above for warning messages.
896
897 G10EOF
898 fi