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