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