Update helper scripts.
[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  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.11"
24
25 # Version number: Remember to change it immediately *after* a release.
26 #                 Make sure to run  "svn up" and "./autogen.sh --force"
27 #                 before a "make dist".  See below for the LT versions.
28 #                 Never do a binary build with the same version number
29 #                 in another year; this would mess up the build number.
30 #
31 # The GIT version is usually the next intended release version with
32 # the string "-gitNNNNNN" appended.  The reason for this is that tests
33 # for a specific feature can already be done under the assumption that
34 # the GIT version is the most recent one in a branch.  To disable the
35 # GIT version for the real release, set the my_isgit macro to no.
36 m4_define(my_version_major, [1])
37 m4_define(my_version_minor, [4])
38 m4_define(my_version_micro, [0])
39 m4_define(my_isgit, [yes])
40
41 m4_define(my_version, [my_version_major.my_version_minor.my_version_micro])
42 m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \
43             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
44 m4_define([git_revision],
45           m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
46 m4_define([my_full_version], [my_version[]m4_if(my_isgit,[yes],
47           [m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])])
48
49 AC_INIT([gpgme],[my_full_version],[http://bugs.gnupg.org])
50
51 # LT Version numbers, remember to change them just *before* a release.
52 #   (Code changed:                      REVISION++)
53 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
54 #   (Interfaces added:                  AGE++)
55 #   (Interfaces removed/changed:        AGE=0)
56 #
57 LIBGPGME_LT_CURRENT=19
58 # Subtract 2 from this value if you want to make the LFS transition an
59 # ABI break.  [Note to self: Remove this comment with the next regular break.]
60 LIBGPGME_LT_AGE=8
61 LIBGPGME_LT_REVISION=1
62
63 # If the API is changed in an incompatible way: increment the next counter.
64 GPGME_CONFIG_API_VERSION=1
65 ##############################################
66
67 NEED_LIBASSUAN_API=2
68 NEED_LIBASSUAN_VERSION=2.0.2
69
70 m4_define([git_brevis],m4_esyscmd(printf "%u" 0x[]m4_substr(git_revision,0,4)))
71 BUILD_REVISION=m4_if(git_revision,[],[svn_revision],[git_brevis])
72 VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" \
73                           my_version_major my_version_minor my_version_micro)
74 PACKAGE=$PACKAGE_NAME
75 VERSION=$PACKAGE_VERSION
76
77 AC_CONFIG_AUX_DIR([build-aux])
78 AC_CONFIG_MACRO_DIR([m4])
79 AC_CONFIG_SRCDIR(src/gpgme.h.in)
80 AC_CONFIG_HEADER(config.h)
81 AM_INIT_AUTOMAKE
82 AM_MAINTAINER_MODE
83 AC_CANONICAL_HOST
84
85 # Enable GNU extensions on systems that have them.
86 AC_GNU_SOURCE
87
88 AH_VERBATIM([_REENTRANT],
89 [/* To allow the use of GPGME in multithreaded programs we have to use
90   special features from the library.
91   IMPORTANT: gpgme is not yet fully reentrant and you should use it
92   only from one thread.  */
93 #ifndef _REENTRANT
94 # define _REENTRANT 1
95 #endif])
96
97 AC_PROG_CC
98 AC_PROG_CXX
99
100 # Note: A suitable gitlog-to-changelog script can be found in GnuPG master.
101 AC_CHECK_PROGS(GITLOG_TO_CHANGELOG, gitlog-to-changelog, [gitlog-to-changelog])
102
103 AC_SUBST(LIBGPGME_LT_CURRENT)
104 AC_SUBST(LIBGPGME_LT_AGE)
105 AC_SUBST(LIBGPGME_LT_REVISION)
106
107 AC_SUBST(PACKAGE)
108 AC_SUBST(VERSION)
109 AC_SUBST(VERSION_NUMBER)
110 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
111 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
112
113 # Don't default to build static libs.
114 LT_PREREQ([2.2.6])
115 LT_INIT([win32-dll disable-static])
116 LT_LANG([Windows Resource])
117
118 # For now we hardcode the use of version scripts.  It would be better
119 # to write a test for this or even implement this within libtool.
120 have_ld_version_script=no
121 case "${host}" in
122     *-*-linux*)
123         have_ld_version_script=yes
124         ;;
125     *-*-gnu*)
126         have_ld_version_script=yes
127         ;;
128     *-apple-darwin*)
129         AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X)
130         ;;
131 esac
132
133 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
134
135 GPG_DEFAULT=no
136 GPGSM_DEFAULT=no
137 GPGCONF_DEFAULT=no
138 G13_DEFAULT=no
139 component_system=None
140 have_dosish_system=no
141 have_android_system=no
142 have_w32_system=no
143 have_w64_system=no
144 build_w32_glib=no
145 build_w32_qt=no
146 case "${host}" in
147     x86_64-*mingw32*)
148         have_w64_system=yes
149         ;;
150     *-mingw32ce*)
151         have_w32ce_system=yes
152         ;;
153     *-linux-androideabi)
154         have_android_system=yes
155         ;;
156 esac
157 case "${host}" in
158     *-mingw32ce*|*-mingw32*)
159         have_dosish_system=yes
160         have_w32_system=yes
161         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
162         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
163         GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe'
164         G13_DEFAULT='c:\\gnupg\\g13.exe'
165         #component_system='COM+'
166
167         AM_PATH_GLIB_2_0
168         AC_ARG_ENABLE(w32-glib,
169             AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
170                            build_w32_glib=$enableval)
171
172         # Check disabled, because the qt-dev packages in gpg4win do
173         # not provide any support for cross compilation.
174         # PKG_CHECK_MODULES(QT4_CORE, QtCore)
175
176         # Use it like this:
177         # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
178         AC_SUBST(QT4_CORE_CFLAGS)
179         AC_SUBST(QT4_CORE_LIBS)
180         AC_ARG_ENABLE(w32-qt,
181             AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
182                            build_w32_qt=$enableval)
183         ;;
184     *)
185         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
186         if test "$have_pthread" = yes; then
187           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
188         fi
189
190         # XXX: Probably use exec-prefix here?
191 #       GPG_DEFAULT='/usr/bin/gpg'
192 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
193 #       GPGCONF_DEFAULT='/usr/bin/gpgconf'
194 #       G13_DEFAULT='/usr/bin/g13'
195         ;;
196 esac
197
198 if test "$have_dosish_system" = yes; then
199    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
200              [Defined if we run on some of the PCDOS like systems
201               (DOS, Windoze. OS/2) with special properties like
202               no file modes])
203 fi
204 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
205
206 if test "$have_w32_system" = yes; then
207    AC_DEFINE(HAVE_W32_SYSTEM,1,
208              [Defined if we run on any kind of W32 API based system])
209 fi
210 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
211
212 if test "$have_w64_system" = yes; then
213    AC_DEFINE(HAVE_W64_SYSTEM,1,
214              [Defined if we run on a 64 bit W32 API based system])
215 fi
216 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
217
218 if test "$have_w32ce_system" = yes; then
219    AC_DEFINE(HAVE_W32CE_SYSTEM,1,
220              [Defined if we run on a W32 CE API based system])
221 fi
222 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
223
224 if test "$have_android_system" = yes; then
225    AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
226 fi
227 AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
228
229 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
230 AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
231
232 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
233
234
235
236 # Checks for header files.
237 AC_CHECK_HEADERS_ONCE([locale.h sys/select.h sys/uio.h argp.h
238                        unistd.h sys/time.h sys/types.h sys/stat.h])
239
240
241 # Type checks.
242 AC_C_INLINE
243 AC_CHECK_SIZEOF(unsigned int)
244 AC_SYS_LARGEFILE
245 AC_TYPE_OFF_T
246 AC_TYPE_UINTPTR_T
247
248 # A simple compile time check in gpgme.h for GNU/Linux systems that
249 # prevents a file offset bits mismatch between gpgme and the application.
250 NEED__FILE_OFFSET_BITS=0
251 case "$ac_cv_sys_file_offset_bits" in
252   "" | no | unknown) ;;
253   *)
254   NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
255   ;;
256 esac
257 AC_SUBST(NEED__FILE_OFFSET_BITS)
258
259 # Figure out platform dependent typedefs for gpgme.h
260 if test "$have_w32_system" = yes; then
261    if test "$have_w64_system" = yes; then
262       INSERT__TYPEDEFS_FOR_GPGME_H="/* Typedefs for the 64 bit W32 API.  */
263 #include <basetsd.h>
264 typedef long off_t;
265 typedef __int64 ssize_t;"
266    else
267       INSERT__TYPEDEFS_FOR_GPGME_H="/* Typedefs for the 32 bit W32 API.  */
268 typedef long off_t;
269 typedef long ssize_t;"
270    fi
271 else
272    INSERT__TYPEDEFS_FOR_GPGME_H="#include <sys/types.h>"
273 fi
274 AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H)
275 AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H)
276
277 # Checks for compiler features.
278 if test "$GCC" = yes; then
279     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
280     if test "$have_w32_system" = yes; then
281        CFLAGS="$CFLAGS -mms-bitfields"
282     fi
283 fi
284
285 # Only used for debugging, so no serious test needed (for actual
286 # functionality you have to test libc as well, this only tests the
287 # compiler).
288 AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works],
289    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([__thread int foo;])],
290                      gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no))
291 if test "$gpgme_cv_tls_works" = yes; then
292   AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported])
293 fi
294
295
296 # Checks for library functions.
297 AC_FUNC_FSEEKO
298
299 AC_REPLACE_FUNCS(vasprintf)
300 if test "$ac_cv_func_vasprintf" != yes; then
301   GNUPG_CHECK_VA_COPY
302 fi
303
304 # Try to find a thread-safe version of ttyname().
305 gnupg_REPLACE_TTYNAME_R
306 if test "$ac_cv_func_ttyname_r" != yes; then
307   AC_MSG_WARN([
308 ***
309 *** ttyname() is not thread-safe and ttyname_r() does not exist
310 ***])
311 fi
312
313 # Try to find a thread-safe version of getenv().
314 have_thread_safe_getenv=no
315 jm_GLIBC21
316 if test $GLIBC21 = yes; then
317   have_thread_safe_getenv=yes
318 fi
319 if test $have_thread_safe_getenv = yes; then
320   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
321 fi
322 have_getenv_r=no
323 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
324 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
325   AC_MSG_WARN([
326 ***
327 *** getenv() is not thread-safe and getenv_r() does not exist
328 ***])
329 fi
330
331 # For converting time strings to seconds since Epoch, we need the timegm
332 # function.
333 AC_CHECK_FUNCS(timegm)
334 if test "$ac_cv_func_timegm" != yes; then
335   AC_MSG_WARN([
336 ***
337 *** timegm() not available - a non-thread-safe kludge will be used
338 *** and the TZ variable might be changed at runtime.
339 ***])
340 fi
341
342 AC_CHECK_FUNCS(setlocale)
343
344 # Checking for libgpg-error.
345 AM_PATH_GPG_ERROR(1.8,, AC_MSG_ERROR([libgpg-error was not found]))
346 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
347           [The default error source for GPGME.])
348
349 # And for libassuan.
350 have_libassuan=no
351 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
352                   have_libassuan=yes, have_libassuan=no)
353 if test "$have_libassuan" = "yes"; then
354   AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version",
355                      [version of the libassuan library])
356 fi
357 AM_CONDITIONAL(HAVE_ASSUAN, test "$have_libassuan" = "yes")
358 if test "$have_libassuan" = "yes"; then
359   AC_DEFINE(ENABLE_ASSUAN,1,[Whether Assuan support is enabled])
360 fi
361
362 # Checks for system services
363 NEED_GPG_VERSION_DEFAULT=1.4.0
364 NEED_GPGSM_VERSION_DEFAULT=1.9.6
365 NEED_GPGCONF_VERSION_DEFAULT=2.0.4
366 NEED_G13_VERSION_DEFAULT=2.1.0
367 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
368 NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
369 NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
370 NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
371 AC_ARG_WITH(gpg-version,
372             AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]),
373             NEED_GPG_VERSION=$withval)
374 if test "$NEED_GPG_VERSION" = "yes"; then
375   NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT"
376 fi
377 if test "$NEED_GPG_VERSION" = "no"; then
378   NEED_GPG_VERSION=0.0.0
379 fi
380 AC_ARG_WITH(gpgsm-version,
381             AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]),
382             NEED_GPGSM_VERSION=$withval)
383 if test "$NEED_GPGSM_VERSION" = "yes"; then
384   NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT"
385 fi
386 if test "$NEED_GPGSM_VERSION" = "no"; then
387   NEED_GPGSM_VERSION=0.0.0
388 fi
389 AC_ARG_WITH(gpgconf-version,
390             AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]),
391             NEED_GPGCONF_VERSION=$withval)
392 if test "$NEED_GPGCONF_VERSION" = "yes"; then
393   NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT"
394 fi
395 if test "$NEED_GPGCONF_VERSION" = "no"; then
396   NEED_GPGCONF_VERSION=0.0.0
397 fi
398 AC_ARG_WITH(g13-version,
399             AC_HELP_STRING([--with-g13-version=VER], [require G13 version VER]),
400             NEED_G13_VERSION=$withval)
401 if test "$NEED_G13_VERSION" = "yes"; then
402   NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT"
403 fi
404 if test "$NEED_G13_VERSION" = "no"; then
405   NEED_G13_VERSION=0.0.0
406 fi
407
408 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
409                                      [Min. needed GnuPG version.])
410 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
411                                        [Min. needed GPGSM version.])
412 AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION",
413                                          [Min. needed GPGCONF version.])
414 AC_DEFINE_UNQUOTED(NEED_G13_VERSION, "$NEED_G13_VERSION",
415                                      [Min. needed G13 version.])
416
417
418 NO_OVERRIDE=no
419 AC_ARG_WITH(gpg,
420             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
421             GPG=$withval, NO_OVERRIDE=yes)
422 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
423   GPG=
424   NO_OVERRIDE=yes
425   if test "$cross_compiling" != "yes"; then
426     AC_PATH_PROG(GPG, gpg)
427   fi
428   if test -z "$GPG"; then
429     GPG="$GPG_DEFAULT"
430   fi
431 fi
432 if test "$GPG" = no; then
433   if test "$NO_OVERRIDE" = "yes"; then
434     if test "$cross_compiling" != "yes"; then
435       AC_MSG_WARN([
436 ***
437 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
438 ***])
439     else
440       AC_MSG_ERROR([
441 ***
442 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
443 ***])
444     fi
445   fi
446 else
447   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
448   AC_SUBST(GPG)
449 fi
450 dnl Check for GnuPG version requirement.
451 GPG_VERSION=unknown
452 ok=maybe
453 if test -z "$GPG" -o "x$GPG" = "xno"; then
454   ok=no
455 else
456   if test "$cross_compiling" = "yes"; then
457     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
458     ok=no
459   else
460     if test ! -x "$GPG"; then
461       AC_MSG_WARN([GnuPG not executable, version check disabled])
462       ok=no
463     fi
464   fi
465 fi
466 if test "$ok" = "maybe"; then
467   AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION)
468   req_major=`echo $NEED_GPG_VERSION | \
469              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
470   req_minor=`echo $NEED_GPG_VERSION | \
471              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
472   req_micro=`echo $NEED_GPG_VERSION | \
473              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
474   GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
475   major=`echo $GPG_VERSION | \
476          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
477   minor=`echo $GPG_VERSION | \
478          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
479   micro=`echo $GPG_VERSION | \
480          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
481
482   if test "$major" -gt "$req_major"; then
483     ok=yes
484   else
485     if test "$major" -eq "$req_major"; then
486       if test "$minor" -gt "$req_minor"; then
487         ok=yes
488       else
489         if test "$minor" -eq "$req_minor"; then
490           if test "$micro" -ge "$req_micro"; then
491             ok=yes
492           fi
493         fi
494       fi
495     fi
496   fi
497   if test "$ok" = "yes"; then
498     AC_MSG_RESULT(yes)
499   else
500     AC_MSG_RESULT(no)
501     AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION])
502   fi
503 fi
504 run_gpg_test="$ok"
505 AC_ARG_ENABLE(gpg-test,
506   AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]),
507          run_gpg_test=$enableval)
508 AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes")
509 AC_SUBST(GPG_PATH)
510
511 NO_OVERRIDE=no
512 AC_ARG_WITH(gpgsm,
513             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
514             GPGSM=$withval, NO_OVERRIDE=yes)
515 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
516   GPGSM=
517   NO_OVERRIDE=yes
518   if test "$cross_compiling" != "yes"; then
519     AC_PATH_PROG(GPGSM, gpgsm)
520   fi
521   if test -z "$GPGSM"; then
522     GPGSM="$GPGSM_DEFAULT"
523   fi
524 fi
525 if test "$GPGSM" = no; then
526   if test "$NO_OVERRIDE" = "yes"; then
527     if test "$cross_compiling" != "yes"; then
528       AC_MSG_WARN([
529 ***
530 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
531 ***])
532     else
533       AC_MSG_ERROR([
534 ***
535 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
536 ***])
537     fi
538   fi
539 else
540   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
541   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
542 fi
543 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
544
545
546 dnl Check for GPGSM version requirement.
547 GPGSM_VERSION=unknown
548 ok=maybe
549 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
550   ok=no
551 else
552   if test "$cross_compiling" = "yes"; then
553     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
554     ok=no
555   else
556     if test ! -x "$GPGSM"; then
557       AC_MSG_WARN([GPGSM not executable, version check disabled])
558       ok=no
559     fi
560   fi
561 fi
562 if test "$ok" = "maybe"; then
563   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
564   req_major=`echo $NEED_GPGSM_VERSION | \
565              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
566   req_minor=`echo $NEED_GPGSM_VERSION | \
567              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
568   req_micro=`echo $NEED_GPGSM_VERSION | \
569              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
570   GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
571   major=`echo $GPGSM_VERSION | \
572          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
573   minor=`echo $GPGSM_VERSION | \
574          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
575   micro=`echo $GPGSM_VERSION | \
576          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
577
578   if test "$major" -gt "$req_major"; then
579     ok=yes
580   else
581     if test "$major" -eq "$req_major"; then
582       if test "$minor" -gt "$req_minor"; then
583         ok=yes
584       else
585         if test "$minor" -eq "$req_minor"; then
586           if test "$micro" -ge "$req_micro"; then
587             ok=yes
588           fi
589         fi
590       fi
591     fi
592   fi
593   if test "$ok" = "yes"; then
594     AC_MSG_RESULT(yes)
595   else
596     AC_MSG_RESULT(no)
597     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
598   fi
599 fi
600 run_gpgsm_test="$ok"
601 AC_ARG_ENABLE(gpgsm-test,
602   AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]),
603          run_gpgsm_test=$enableval)
604 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
605
606
607 NO_OVERRIDE=no
608 AC_ARG_WITH(gpgconf,
609             AC_HELP_STRING([--with-gpgconf=PATH],
610                            [use gpgconf binary at PATH]),
611             GPGCONF=$withval, NO_OVERRIDE=yes)
612 if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then
613   GPGCONF=
614   NO_OVERRIDE=yes
615   if test "$cross_compiling" != "yes"; then
616     AC_PATH_PROG(GPGCONF, gpgconf)
617   fi
618   if test -z "$GPGCONF"; then
619     GPGCONF="$GPGCONF_DEFAULT"
620   fi
621 fi
622 if test "$GPGCONF" = no; then
623   if test "$NO_OVERRIDE" = "yes"; then
624     if test "$cross_compiling" != "yes"; then
625       AC_MSG_WARN([
626 ***
627 *** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it
628 ***])
629     else
630       AC_MSG_ERROR([
631 ***
632 *** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH
633 ***])
634     fi
635   fi
636 else
637   AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.])
638   AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled])
639 fi
640 AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no")
641
642 dnl Check for GPGCONF version requirement.
643 GPGCONF_VERSION=unknown
644 ok=maybe
645 if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then
646   ok=no
647 else
648   if test "$cross_compiling" = "yes"; then
649     AC_MSG_WARN([GPGCONF version can not be checked when cross compiling])
650     ok=no
651   else
652     if test ! -x "$GPGCONF"; then
653       AC_MSG_WARN([GPGCONF not executable, version check disabled])
654       ok=no
655     fi
656   fi
657 fi
658 if test "$ok" = "maybe"; then
659   AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION)
660   req_major=`echo $NEED_GPGCONF_VERSION | \
661              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
662   req_minor=`echo $NEED_GPGCONF_VERSION | \
663              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
664   req_micro=`echo $NEED_GPGCONF_VERSION | \
665              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
666   GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'`
667   major=`echo $GPGCONF_VERSION | \
668          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
669   minor=`echo $GPGCONF_VERSION | \
670          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
671   micro=`echo $GPGCONF_VERSION | \
672          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
673
674   if test "$major" -gt "$req_major"; then
675     ok=yes
676   else
677     if test "$major" -eq "$req_major"; then
678       if test "$minor" -gt "$req_minor"; then
679         ok=yes
680       else
681         if test "$minor" -eq "$req_minor"; then
682           if test "$micro" -ge "$req_micro"; then
683             ok=yes
684           fi
685         fi
686       fi
687     fi
688   fi
689   if test "$ok" = "yes"; then
690     AC_MSG_RESULT(yes)
691   else
692     AC_MSG_RESULT(no)
693     AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION])
694   fi
695 fi
696 run_gpgconf_test="$ok"
697 AC_ARG_ENABLE(gpgconf-test,
698   AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]),
699          run_gpgconf_test=$enableval)
700 AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes")
701
702
703 NO_OVERRIDE=no
704 AC_ARG_WITH(g13,
705             AC_HELP_STRING([--with-g13=PATH],
706                            [use g13 binary at PATH]),
707             G13=$withval, NO_OVERRIDE=yes)
708 if test "$NO_OVERRIDE" = "yes" || test "$G13" = "yes"; then
709   G13=
710   NO_OVERRIDE=yes
711   if test "$cross_compiling" != "yes"; then
712     AC_PATH_PROG(G13, g13)
713   fi
714   if test -z "$G13"; then
715     G13="$G13_DEFAULT"
716   fi
717 fi
718 if test "$G13" = no; then
719   if test "$NO_OVERRIDE" = "yes"; then
720     if test "$cross_compiling" != "yes"; then
721       AC_MSG_WARN([
722 ***
723 *** Could not find g13, install g13 or use --with-g13=PATH to enable it
724 ***])
725     else
726       AC_MSG_ERROR([
727 ***
728 *** Can not determine path to g13 when cross-compiling, use --with-g13=PATH
729 ***])
730     fi
731   fi
732 else
733   AC_DEFINE_UNQUOTED(G13_PATH, "$G13", [Path to the G13 binary.])
734   AC_DEFINE(ENABLE_G13,1,[Whether G13 support is enabled])
735 fi
736 AM_CONDITIONAL(HAVE_G13, test "$G13" != "no")
737
738 dnl Check for G13 version requirement.
739 G13_VERSION=unknown
740 ok=maybe
741 if test -z "$G13" -o "x$G13" = "xno"; then
742   ok=no
743 else
744   if test "$cross_compiling" = "yes"; then
745     AC_MSG_WARN([G13 version can not be checked when cross compiling])
746     ok=no
747   else
748     if test ! -x "$G13"; then
749       AC_MSG_WARN([G13 not executable, version check disabled])
750       ok=no
751     fi
752   fi
753 fi
754 if test "$ok" = "maybe"; then
755   AC_MSG_CHECKING(for G13 >= $NEED_G13_VERSION)
756   req_major=`echo $NEED_G13_VERSION | \
757              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
758   req_minor=`echo $NEED_G13_VERSION | \
759              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
760   req_micro=`echo $NEED_G13_VERSION | \
761              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
762   G13_VERSION=`$G13 --version | sed -n '1 s/.*\ \([[0-9]].*\)/\1/p'`
763   major=`echo $G13_VERSION | \
764          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
765   minor=`echo $G13_VERSION | \
766          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
767   micro=`echo $G13_VERSION | \
768          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
769
770   if test "$major" -gt "$req_major"; then
771     ok=yes
772   else
773     if test "$major" -eq "$req_major"; then
774       if test "$minor" -gt "$req_minor"; then
775         ok=yes
776       else
777         if test "$minor" -eq "$req_minor"; then
778           if test "$micro" -ge "$req_micro"; then
779             ok=yes
780           fi
781         fi
782       fi
783     fi
784   fi
785   if test "$ok" = "yes"; then
786     AC_MSG_RESULT(yes)
787   else
788     AC_MSG_RESULT(no)
789     AC_MSG_WARN([G13 must be at least version $NEED_G13_VERSION])
790   fi
791 fi
792 run_g13_test="$ok"
793 AC_ARG_ENABLE(g13-test,
794   AC_HELP_STRING([--disable-g13-test], [disable G13 run test]),
795          run_g13_test=$enableval)
796 AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes")
797
798
799 # Check for funopen
800 AC_CHECK_FUNCS(funopen)
801 if test $ac_cv_func_funopen != yes; then
802     # No funopen but we can implement that in terms of fopencookie.
803     AC_CHECK_FUNCS(fopencookie)
804     if test $ac_cv_func_fopencookie = yes; then
805         AC_REPLACE_FUNCS(funopen)
806     else
807         AC_MSG_WARN([
808 ***
809 *** No implementation of fopencookie or funopen available
810 ***])
811     fi
812 fi
813
814 # Check for getgid etc
815 AC_CHECK_FUNCS(getgid getegid)
816
817
818 # Replacement functions.
819 AC_REPLACE_FUNCS(stpcpy)
820 AC_REPLACE_FUNCS(setenv)
821
822 # Assuan check for descriptor passing.
823 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
824                 [supports_descriptor_passing=yes],
825                 [supports_descriptor_passing=no
826                  AC_MSG_WARN([
827 ***
828 *** Data structure for sending ancillary data missing.
829 *** Descriptor passing won't work.
830 ***])],[
831 #include <stdlib.h>
832 #include <stddef.h>
833 #include <stdio.h>
834 #include <sys/types.h>
835 #include <sys/socket.h>
836 #include <sys/un.h>
837 #if HAVE_SYS_UIO_H
838 #include <sys/uio.h>
839 #endif
840 #include <unistd.h>
841        ])
842
843 use_descriptor_passing=no
844 AC_ARG_ENABLE(fd-passing,
845   AC_HELP_STRING([--enable-fd-passing], [use FD passing if supported]),
846   use_descriptor_passing=$enableval)
847
848 if test "$supports_descriptor_passing" != "yes"; then
849   use_descriptor_passing=no
850 fi
851
852 if test "$use_descriptor_passing" = "yes"; then
853 AC_DEFINE(USE_DESCRIPTOR_PASSING,1,
854           [Defined if descriptor passing is enabled and supported])
855 fi
856
857 AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
858
859
860 uiserver=no
861 if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then
862   uiserver=yes
863 fi
864 if test "$uiserver" != "no"; then
865   AC_DEFINE(ENABLE_UISERVER, 1,
866             [Defined if we are building with uiserver support.])
867 fi
868 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
869
870
871 # Generate values for the DLL version info
872
873 dnl Windows uses an internal build number.  We use the last day of the
874 dnl year concatenated with the hour for it.  WARNING: You should not
875 dnl do a build with the same version number in another year.
876 if test "$have_w32_system" = yes; then
877     BUILD_TIMESTAMP=`date --iso-8601=minutes`
878     BUILD_NUMBER="$(date -u '+%j%H' | sed 's/^0*\(.*\)/\1/')"
879     changequote(,)dnl
880     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
881     changequote([,])dnl
882     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_NUMBER}"
883 fi
884 AC_SUBST(BUILD_NUMBER)
885 AC_SUBST(BUILD_TIMESTAMP)
886 AC_SUBST(BUILD_FILEVERSION)
887
888 # Add a few constants to help porting to W32
889 AH_VERBATIM([SEPCONSTANTS],
890 [
891 /* Separators as used in $PATH.  */
892 #ifdef HAVE_DOSISH_SYSTEM
893 #define PATHSEP_C ';'
894 #else
895 #define PATHSEP_C ':'
896 #endif
897 ])
898
899 AH_BOTTOM([
900 /* Definition of GCC specific attributes.  */
901 #if __GNUC__ > 2
902 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
903 #else
904 # define GPGME_GCC_A_PURE
905 #endif
906
907 /* Under WindowsCE we need gpg-error's strerror macro.  */
908 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
909 ])
910
911
912 # Substitution used for gpgme-config
913 GPGME_CONFIG_LIBS="-lgpgme"
914 GPGME_CONFIG_CFLAGS=""
915 GPGME_CONFIG_HOST="$host"
916 AC_SUBST(GPGME_CONFIG_API_VERSION)
917 AC_SUBST(GPGME_CONFIG_LIBS)
918 AC_SUBST(GPGME_CONFIG_CFLAGS)
919 AC_SUBST(GPGME_CONFIG_HOST)
920
921 # Frob'da Variables
922 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
923            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
924 AC_SUBST(LTLIBOBJS)
925
926 # Some checks for gpgme-tool
927 # Done at top: AC_CHECK_HEADER([argp.h])
928 AC_CHECK_TYPES([error_t], [],
929    [AC_DEFINE([error_t], [int],
930    [Define to a type to use for `error_t' if it is not otherwise available.])],
931    [#include <errno.h>])
932
933
934 # A substitution to set generated files in a Emacs buffer to read-only.
935 AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']])
936 AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
937 AC_SUBST(emacs_local_vars_end, ['End:'])
938
939
940 # Last check.
941 die=no
942 if test "$have_libassuan" = "no"; then
943    die=yes
944    AC_MSG_NOTICE([[
945 ***
946 *** You need libassuan to build this program with GPGSM support.
947 *** This library is for example available at
948 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
949 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
950 ***]])
951 fi
952
953 if test "$die" = "yes"; then
954     AC_MSG_ERROR([[
955 ***
956 *** Required libraries not found. Please consult the above messages
957 *** and install them before running configure again.
958 ***]])
959 fi
960
961
962 #
963 # Create config files
964
965 AC_CONFIG_FILES(Makefile src/Makefile
966                 tests/Makefile
967                 tests/gpg/Makefile
968                 tests/gpgsm/Makefile
969                 tests/opassuan/Makefile
970                 doc/Makefile
971                 src/versioninfo.rc
972                 src/gpgme.h)
973 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
974 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
975 AC_OUTPUT
976
977 echo "
978         GPGME v${VERSION} has been configured as follows:
979
980         Revision:        git_revision  (git_brevis)
981         Platform:        $host
982
983         GnuPG path:      $GPG
984         GnuPG version:   $GPG_VERSION, min. $NEED_GPG_VERSION
985         GpgSM path:      $GPGSM
986         GpgSM version:   $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
987         GpgConf path:    $GPGCONF
988         GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
989         G13 path:        $G13
990         G13 version:     $G13_VERSION, min. $NEED_G13_VERSION
991
992         Assuan version:  $libassuan_version, min. $NEED_LIBASSUAN_VERSION
993
994         UI Server:       $uiserver
995         FD Passing:      $use_descriptor_passing
996         GPGME Pthread:   $have_pthread
997 "