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