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