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