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