Release 1.11.1
[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 General Public License
18 # along with this program; if not, see <https://www.gnu.org/licenses/>.
19
20 # (Process this file with autoconf to produce a configure script.)
21 AC_PREREQ(2.59)
22 min_automake_version="1.14"
23
24 # To build a release you need to create a tag with the version number
25 # (git tag -s gpgme-n.m.k) and run "./autogen.sh --force".  Please
26 # bump the version number immediately after the release and do another
27 # commit and push so that the git magic is able to work.  See below
28 # for the LT versions.
29 m4_define(mym4_version_major, [1])
30 m4_define(mym4_version_minor, [11])
31 m4_define(mym4_version_micro, [1])
32
33 # Below is m4 magic to extract and compute the revision number, the
34 # decimalized short revision number, a beta version string, and a flag
35 # indicating a development version (mym4_isgit). Note that the m4
36 # processing is done by autoconf and not during the configure run.
37 m4_define(mym4_version,
38           [mym4_version_major.mym4_version_minor.mym4_version_micro])
39 m4_define([mym4_revision],
40           m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
41 m4_define([mym4_revision_dec],
42           m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
43 m4_define([mym4_betastring],
44           m4_esyscmd_s([git describe --match 'gpgme-[0-9].*[0-9]' --long|\
45                         awk -F- '$3!=0{print"-beta"$3}']))
46 m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
47 m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
48
49 AC_INIT([gpgme],[mym4_full_version],[http://bugs.gnupg.org])
50
51 # LT Version numbers, remember to change them just *before* a release.
52 #   (Code changed:                      REVISION++)
53 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
54 #   (Interfaces added:                  AGE++)
55 #   (Interfaces removed/changed:        AGE=0)
56 #
57 LIBGPGME_LT_CURRENT=31
58 LIBGPGME_LT_AGE=20
59 LIBGPGME_LT_REVISION=1
60
61 # If there is an ABI break in gpgmepp or qgpgme also bump the
62 # version in IMPORTED_LOCATION in the GpgmeppConfig-w32.cmake.in.in
63
64 LIBGPGMEPP_LT_CURRENT=13
65 LIBGPGMEPP_LT_AGE=7
66 LIBGPGMEPP_LT_REVISION=0
67
68 LIBQGPGME_LT_CURRENT=10
69 LIBQGPGME_LT_AGE=3
70 LIBQGPGME_LT_REVISION=2
71
72 # If the API is changed in an incompatible way: increment the next counter.
73 GPGME_CONFIG_API_VERSION=1
74 ##############################################
75
76 NEED_GPG_ERROR_VERSION=1.24
77 NEED_LIBASSUAN_API=2
78 NEED_LIBASSUAN_VERSION=2.4.2
79
80
81 PACKAGE=$PACKAGE_NAME
82 VERSION=$PACKAGE_VERSION
83
84 VERSION_MAJOR=mym4_version_major
85 VERSION_MINOR=mym4_version_minor
86 VERSION_MICRO=mym4_version_micro
87
88 AC_CONFIG_AUX_DIR([build-aux])
89 AC_CONFIG_MACRO_DIR([m4])
90 AC_CONFIG_SRCDIR(src/gpgme.h.in)
91 AC_CONFIG_HEADER(config.h)
92 AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
93 AM_MAINTAINER_MODE
94 AC_CANONICAL_HOST
95 AM_SILENT_RULES
96 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
97
98 # Enable GNU extensions on systems that have them.
99 AC_GNU_SOURCE
100
101 AH_VERBATIM([_REENTRANT],
102 [/* To allow the use of GPGME in multithreaded programs we have to use
103   special features from the library.
104   IMPORTANT: gpgme is not yet fully reentrant and you should use it
105   only from one thread.  */
106 #ifndef _REENTRANT
107 # define _REENTRANT 1
108 #endif])
109
110 AC_PROG_CC
111 AC_PROG_CPP
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 languages 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 language 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             ], :)
428         fi
429
430         if test "$found_py" = "1" -o "$found_py3" = "1"; then
431             # Reset everything, so that we can look for another Python.
432             unset PYTHON
433             unset PYTHON_VERSION
434             unset PYTHON_CPPFLAGS
435             unset PYTHON_LDFLAGS
436             unset PYTHON_SITE_PKG
437             unset PYTHON_EXTRA_LIBS
438             unset PYTHON_EXTRA_LDFLAGS
439             unset ac_cv_path_PYTHON
440             unset am_cv_pathless_PYTHON
441             unset am_cv_python_version
442             unset am_cv_python_platform
443             unset am_cv_python_pythondir
444             unset am_cv_python_pyexecdir
445             AM_PATH_PYTHON([3.4], [
446                 AX_PYTHON_DEVEL
447                 if test "$PYTHON_VERSION"; then
448                         PYTHONS="$(echo $PYTHONS $PYTHON)"
449                         PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
450                 fi
451             ], :)
452         fi
453
454         # Recover some values lost in the second attempt to find Python.
455         PYTHON="$(echo $PYTHONS | cut -d ' ' -f 1)"
456         PYTHON_VERSION="$(echo $PYTHON_VERSIONS | cut -d ' ' -f 1)"
457
458         # Remove duplicates.
459         PYTHONS="$(echo $PYTHONS | tr '[[:space:]]' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/ $//')"
460         PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS | tr '[[:space:]]' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/ $//')"
461
462         if test "$PYTHON_VERSIONS"; then
463            enabled_languages_v=$(echo $enabled_languages | sed -Ee "s/python[[23]]?/python ($PYTHON_VERSIONS)/")
464            enabled_languages=$(echo $enabled_languages | sed -Ee "s/python[[23]]?/python/")
465         else
466             if test "$explicit_languages" = "1"; then
467                 AC_MSG_ERROR([[
468 ***
469 *** Please install the python development packages.
470 ***]])
471             else
472                 enabled_languages=$(echo $enabled_languages | sed 's/python//')
473             fi
474         fi
475
476         AC_SUBST(PYTHONS, $PYTHONS)
477     fi
478 fi
479
480 AC_SUBST(ENABLED_LANGUAGES, $enabled_languages)
481
482 #
483 # Provide information about the build.
484 #
485 BUILD_REVISION="mym4_revision"
486 AC_SUBST(BUILD_REVISION)
487 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
488                    [GIT commit id revision used to build this package])
489
490 changequote(,)dnl
491 BUILD_FILEVERSION=`echo "$PACKAGE_VERSION"|sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
492 changequote([,])dnl
493 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
494 AC_SUBST(BUILD_FILEVERSION)
495
496 AC_ARG_ENABLE([build-timestamp],
497   AC_HELP_STRING([--enable-build-timestamp],
498                  [set an explicit build timestamp for reproducibility.
499                   (default is the current time in ISO-8601 format)]),
500      [if test "$enableval" = "yes"; then
501         BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
502       else
503         BUILD_TIMESTAMP="$enableval"
504       fi],
505      [BUILD_TIMESTAMP="<none>"])
506 AC_SUBST(BUILD_TIMESTAMP)
507 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
508                    [The time this package was configured for a build])
509
510
511 #
512 # Options to disable some regression tests
513 #
514 run_gpgconf_test="yes"
515 AC_ARG_ENABLE(gpgconf-test,
516   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF regression test]),
517          run_gpgconf_test=$enableval)
518 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
519
520 run_gpg_test="yes"
521 AC_ARG_ENABLE(gpg-test,
522   AC_HELP_STRING([--disable-gpg-test], [disable GPG regression test]),
523          run_gpg_test=$enableval)
524 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
525
526 run_gpgsm_test="yes"
527 AC_ARG_ENABLE(gpgsm-test,
528   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM regression test]),
529          run_gpgsm_test=$enableval)
530 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
531
532 run_g13_test="yes"
533 AC_ARG_ENABLE(g13-test,
534   AC_HELP_STRING([--disable-g13-test], [disable G13 regression test]),
535          run_g13_test=$enableval)
536 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
537
538
539 # Checks for header files.
540 AC_CHECK_HEADERS_ONCE([locale.h sys/select.h sys/uio.h argp.h
541                        unistd.h sys/time.h sys/types.h sys/stat.h])
542
543
544 # Type checks.
545 AC_C_INLINE
546 AC_CHECK_SIZEOF(unsigned int)
547 AC_SYS_LARGEFILE
548 AC_TYPE_OFF_T
549 AC_TYPE_UINTPTR_T
550
551 # A simple compile time check in gpgme.h for GNU/Linux systems that
552 # prevents a file offset bits mismatch between gpgme and the application.
553 NEED__FILE_OFFSET_BITS=0
554 if test "$have_w32_system" != yes; then
555   case "$ac_cv_sys_file_offset_bits" in
556     "" | no | unknown) ;;
557     *)
558     NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
559     ;;
560   esac
561 fi
562 AC_SUBST(NEED__FILE_OFFSET_BITS)
563
564 # Figure out platform dependent typedefs for gpgme.h
565 if test "$have_w32_system" = yes; then
566     INSERT__TYPEDEFS_FOR_GPGME_H="
567 #ifdef _WIN64
568 # include <stdint.h>
569   typedef int64_t gpgme_off_t;
570   typedef int64_t gpgme_ssize_t;
571 #else /* _WIN32 */
572   typedef long gpgme_off_t;
573   typedef long gpgme_ssize_t;
574 #endif /* _WIN32 */"
575     API__OFF_T="gpgme_off_t"
576     API__SSIZE_T="gpgme_ssize_t"
577 else
578     INSERT__TYPEDEFS_FOR_GPGME_H="
579 #include <sys/types.h>
580 typedef off_t   gpgme_off_t;
581 typedef ssize_t gpgme_ssize_t;"
582     API__OFF_T="off_t"
583     API__SSIZE_T="ssize_t"
584 fi
585 AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H)
586 AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H)
587 AC_SUBST(API__OFF_T)
588 AM_SUBST_NOTMAKE(API__OFF_T)
589 AC_SUBST(API__SSIZE_T)
590 AM_SUBST_NOTMAKE(API__SSIZE_T)
591
592 # Checks for compiler features.
593 if test "$GCC" = yes; then
594     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
595     if test "$USE_MAINTAINER_MODE" = "yes"; then
596         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
597
598         # If -Wno-missing-field-initializers is supported we can enable a
599         # a bunch of really useful warnings.
600         AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
601         _gcc_cflags_save=$CFLAGS
602         CFLAGS="-Wno-missing-field-initializers"
603         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
604         AC_MSG_RESULT($_gcc_wopt)
605         CFLAGS=$_gcc_cflags_save;
606         if test x"$_gcc_wopt" = xyes ; then
607           CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
608           CFLAGS="$CFLAGS -Wwrite-strings"
609           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
610           CFLAGS="$CFLAGS -Wno-missing-field-initializers"
611           CFLAGS="$CFLAGS -Wno-sign-compare"
612         fi
613         CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-shadow"
614
615         AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
616         _gcc_cflags_save=$CFLAGS
617         CFLAGS="-Wpointer-arith"
618         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
619         AC_MSG_RESULT($_gcc_wopt)
620         CFLAGS=$_gcc_cflags_save;
621         if test x"$_gcc_wopt" = xyes ; then
622           CFLAGS="$CFLAGS -Wpointer-arith"
623         fi
624     fi
625     if test "$have_w32_system" = yes; then
626        CFLAGS="$CFLAGS -mms-bitfields"
627     fi
628 fi
629
630 # Only used for debugging, so no serious test needed (for actual
631 # functionality you have to test libc as well, this only tests the
632 # compiler).
633 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
634    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([__thread int foo;])],
635                      gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
636 if test "$gpgme_cv_tls_works" = yes; then
637   AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
638 fi
639
640
641 # Checks for library functions.
642 AC_MSG_NOTICE([checking for libraries])
643
644 AC_FUNC_FSEEKO
645
646 # Try to find a thread-safe version of ttyname().
647 gnupg_REPLACE_TTYNAME_R
648 if test "$ac_cv_func_ttyname_r" != yes; then
649   AC_MSG_WARN([
650 ***
651 *** ttyname() is not thread-safe and ttyname_r() does not exist
652 ***])
653 fi
654
655 # Try to find a thread-safe version of getenv().
656 have_thread_safe_getenv=no
657 jm_GLIBC21
658 if test $GLIBC21 = yes -o $have_w32_system = yes; then
659   have_thread_safe_getenv=yes
660 fi
661 if test $have_thread_safe_getenv = yes; then
662   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
663 fi
664 have_getenv_r=no
665 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
666 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
667   AC_MSG_WARN([
668 ***
669 *** getenv() is not thread-safe and getenv_r() does not exist
670 ***])
671 fi
672
673 # For converting time strings to seconds since Epoch, we need the timegm
674 # function.
675 AC_CHECK_FUNCS(timegm)
676 if test "$ac_cv_func_timegm" != yes; then
677   AC_MSG_WARN([
678 ***
679 *** timegm() not available - a non-thread-safe kludge will be used
680 *** and the TZ variable might be changed at runtime.
681 ***])
682 fi
683
684 AC_CHECK_FUNCS(setlocale)
685
686 # Checking for libgpg-error.
687 have_gpg_error=no
688 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
689                   have_gpg_error=yes, have_gpg_error=no)
690 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
691           [The default error source for GPGME.])
692
693 # And for libassuan.
694 have_libassuan=no
695 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
696                   have_libassuan=yes, have_libassuan=no)
697 if test "$have_libassuan" = "yes"; then
698   AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
699                      [version of the libassuan library])
700 fi
701
702
703 #
704 # Other checks
705 #
706
707 # Check for getgid etc
708 AC_CHECK_FUNCS(getgid getegid closefrom)
709
710
711 # Replacement functions.
712 AC_REPLACE_FUNCS(stpcpy)
713 AC_REPLACE_FUNCS(setenv)
714
715 # Assuan check for descriptor passing.
716 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
717                 [supports_descriptor_passing=yes],
718                 [supports_descriptor_passing=no
719                  AC_MSG_WARN([
720 ***
721 *** Data structure for sending ancillary data missing.
722 *** Descriptor passing won't work.
723 ***])],[
724 #include <stdlib.h>
725 #include <stddef.h>
726 #include <stdio.h>
727 #include <sys/types.h>
728 #include <sys/socket.h>
729 #include <sys/un.h>
730 #if HAVE_SYS_UIO_H
731 #include <sys/uio.h>
732 #endif
733 #include <unistd.h>
734        ])
735
736 use_descriptor_passing=yes
737 AC_ARG_ENABLE(fd-passing,
738   AC_HELP_STRING([--disable-fd-passing], [do not use FD passing]),
739   use_descriptor_passing=$enableval)
740
741 if test "$supports_descriptor_passing" != "yes"; then
742   use_descriptor_passing=no
743 fi
744
745 if test "$use_descriptor_passing" = "yes"; then
746 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
747           [Defined if descriptor passing is enabled and supported])
748 fi
749
750 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
751
752
753 uiserver=no
754 if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then
755   uiserver=yes
756 fi
757 if test "$uiserver" != "no"; then
758   AC_DEFINE(ENABLE_UISERVER, 1,
759             [Defined if we are building with uiserver support.])
760 fi
761 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
762
763
764 # Option --disable-linux-getdents
765 #
766 # By default we use SYS_getdents on Linux to optimize fd closing
767 # before an exec.  This option allows to switch this optimization off.
768 use_linux_getdents=yes
769 AC_ARG_ENABLE(linux-getdents,
770               AC_HELP_STRING([--disable-linux-getdents],
771                              [do not use SYS_getdents on Linux]),
772               use_linux_getdents=$enableval)
773 if test "$use_linux_getdents" = "yes"; then
774     case "${host}" in
775         *-*-linux*)
776            AC_DEFINE(USE_LINUX_GETDENTS,1,
777                      [Defined if SYS_getdents can be used on Linux])
778            ;;
779     esac
780 fi
781
782
783 #
784 # Add a few constants to help porting to W32
785 #
786 AH_VERBATIM([SEPCONSTANTS],
787 [
788 /* Separators as used in $PATH and file name.  */
789 #ifdef HAVE_DOSISH_SYSTEM
790 #define PATHSEP_C ';'
791 #define DIRSEP_C '\\'
792 #define DIRSEP_S "\\"
793 #else
794 #define PATHSEP_C ':'
795 #define DIRSEP_C '/'
796 #define DIRSEP_S "/"
797 #endif
798 ])
799
800 AH_BOTTOM([
801 /* Definition of GCC specific attributes.  */
802 #if __GNUC__ > 2
803 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
804 #else
805 # define GPGME_GCC_A_PURE
806 #endif
807
808 /* Under WindowsCE we need gpg-error's strerror macro.  */
809 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
810
811 #define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \
812                     "Copyright (C) 2001--2018 g10 Code GmbH\n"
813 ])
814
815
816 # Substitution used for gpgme-config
817 GPGME_CONFIG_LIBS="-lgpgme"
818 GPGME_CONFIG_CFLAGS=""
819 GPGME_CONFIG_HOST="$host"
820 GPGME_CONFIG_AVAIL_LANG="$enabled_languages"
821 AC_SUBST(GPGME_CONFIG_API_VERSION)
822 AC_SUBST(GPGME_CONFIG_LIBS)
823 AC_SUBST(GPGME_CONFIG_CFLAGS)
824 AC_SUBST(GPGME_CONFIG_HOST)
825 AC_SUBST(GPGME_CONFIG_AVAIL_LANG)
826
827 # Frob'da Variables
828 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
829            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
830 AC_SUBST(LTLIBOBJS)
831
832 # Some checks for gpgme-tool
833 # Done at top: AC_CHECK_HEADER([argp.h])
834 AC_CHECK_TYPES([error_t], [],
835    [AC_DEFINE([error_t], [int],
836    [Define to a type to use for `error_t' if it is not otherwise available.])],
837    [#include <errno.h>])
838
839
840 # A substitution to set generated files in a Emacs buffer to read-only.
841 AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
842 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
843 AC_SUBST(emacs_local_vars_end, ['End:'])
844
845 # Last check.
846 die=no
847 if test "$have_gpg_error" = "no"; then
848    die=yes
849    AC_MSG_NOTICE([[
850 ***
851 *** You need libgpg-error to build this program.
852 **  This library is for example available at
853 ***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
854 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
855 ***]])
856 fi
857 if test "$have_libassuan" = "no"; then
858    die=yes
859    AC_MSG_NOTICE([[
860 ***
861 *** You need libassuan to build this program.
862 *** This library is for example available at
863 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
864 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
865 ***]])
866 fi
867
868 if test "$die" = "yes"; then
869     AC_MSG_ERROR([[
870 ***
871 *** Required libraries not found. Please consult the above messages
872 *** and install them before running configure again.
873 ***]])
874 fi
875
876
877 #
878 # Create config files
879
880 AC_CONFIG_FILES(Makefile src/Makefile
881                 tests/Makefile
882                 tests/gpg/Makefile
883                 tests/gpgsm/Makefile
884                 tests/opassuan/Makefile
885                 doc/Makefile
886                 src/versioninfo.rc
887                 src/gpgme.h)
888 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
889 AC_CONFIG_FILES(lang/cpp/Makefile lang/cpp/src/Makefile)
890 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig-w32.cmake.in)
891 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig.cmake.in)
892 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfigVersion.cmake)
893 AC_CONFIG_FILES(lang/cpp/src/gpgmepp_version.h)
894 AC_CONFIG_FILES(lang/qt/Makefile lang/qt/src/Makefile)
895 AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig-w32.cmake.in)
896 AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig.cmake.in)
897 AC_CONFIG_FILES(lang/qt/src/QGpgmeConfigVersion.cmake)
898 AC_CONFIG_FILES(lang/qt/tests/Makefile)
899 AC_CONFIG_FILES(lang/qt/src/qgpgme_version.h)
900 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
901 AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])])
902 AC_CONFIG_FILES(lang/qt/doc/Makefile)
903 AC_CONFIG_FILES([lang/python/Makefile
904                  lang/python/version.py
905                  lang/python/tests/Makefile])
906 AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
907 AC_OUTPUT
908
909 echo "
910         GPGME v${VERSION} has been configured as follows:
911
912         Revision:          mym4_revision  (mym4_revision_dec)
913         Platform:          $host
914
915         UI Server:         $uiserver
916         FD Passing:        $use_descriptor_passing
917
918         Language bindings: ${enabled_languages_v:-$enabled_languages}
919 "
920 if test "x${gpg_config_script_warn}" != x; then
921 cat <<G10EOF
922         Mismatches between the target platform and the to
923         be used libraries have been been detected for:
924          ${gpg_config_script_warn}
925         Please check above for warning messages.
926
927 G10EOF
928 fi