Post-release tweaks.
[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 g10 Code GmbH
4
5 # This file is part of GPGME.
6
7 # GPGME is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as
9 # published by the Free Software Foundation; either version 2.1 of the
10 # License, or (at your option) any later version.
11
12 # GPGME is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
15 # Public License for more details.
16
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20  
21 # (Process this file with autoconf to produce a configure script.)
22 AC_PREREQ(2.59)
23 min_automake_version="1.9.3"
24
25 # Version number: Remember to change it immediately *after* a release.
26 #                 Make sure to run  "svn up" before a "make dist".
27 #                 See below for the LT versions.
28 #
29 # The CVS version is usually the next intended release version with
30 # the string "-cvs" appended.  The reason for this is that tests for a
31 # specific feature can already be done under the assumption that the
32 # CVS version is the most recent one in a branch.  To disable the CVS
33 # version for the real release, just comment out the my_iscvs macro.
34 # Note, that we are now using Subversion instead of CVS and append the
35 # SVN revision number to the "cvs" suffix.  To make this most useful
36 # for snapshot releases please do an "svn up" right before recreating
37 # the configure script, so that a proper revision number for all files
38 # is available when running a "make distcheck".
39 m4_define(my_version, [1.1.3])
40 m4_define(my_iscvs, yes)
41 AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit(
42                [$Revision$],[Ra-z $:])]),
43                [bug-gpgme@gnupg.org])
44
45 # LT Version numbers, remember to change them just *before* a release.
46 #   (Code changed:                      REVISION++)
47 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
48 #   (Interfaces added:                  AGE++)
49 #   (Interfaces removed/changed:        AGE=0)
50 #
51 LIBGPGME_LT_CURRENT=17
52 # Subtract 2 from this value if you want to make the LFS transition an
53 # ABI break.  [Note to self: Remove this comment with the next regular break.]
54 LIBGPGME_LT_AGE=6
55 LIBGPGME_LT_REVISION=1
56
57 # If the API is changed in an incompatible way: increment the next counter.
58 GPGME_CONFIG_API_VERSION=1
59
60 NEED_GPG_VERSION=1.2.2
61 NEED_GPGSM_VERSION=1.9.6
62 ##############################################
63
64
65 PACKAGE=$PACKAGE_NAME
66 VERSION=$PACKAGE_VERSION
67
68 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
69 dnl FIXME: Enable this with autoconf 2.59.
70 dnl AC_CONFIG_MACRO_DIR(m4)
71 AM_CONFIG_HEADER(config.h)
72 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
73 AM_MAINTAINER_MODE
74 AC_CANONICAL_HOST
75
76 # Enable GNU extensions on systems that have them.
77 AC_GNU_SOURCE
78
79 AH_VERBATIM([_REENTRANT],
80 [/* To allow the use of GPGME in multithreaded programs we have to use
81   special features from the library.
82   IMPORTANT: gpgme is not yet fully reentrant and you should use it
83   only from one thread.  */
84 #ifndef _REENTRANT
85 # define _REENTRANT 1
86 #endif])
87
88 AC_PROG_CC
89
90 AC_SUBST(LIBGPGME_LT_CURRENT)
91 AC_SUBST(LIBGPGME_LT_AGE)
92 AC_SUBST(LIBGPGME_LT_REVISION)
93 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
94                                      [Min. needed GnuPG version.])
95 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
96                                        [Min. needed GPGSM version.])
97
98 AC_SUBST(PACKAGE)
99 AC_SUBST(VERSION)
100 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
101 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
102
103 # Don't default to build static libs.
104 AC_DISABLE_STATIC
105 AC_LIBTOOL_WIN32_DLL
106 AC_LIBTOOL_RC
107 AC_PROG_LIBTOOL
108
109 # For now we hardcode the use of version scripts.  It would be better
110 # to write a test for this or even implement this within libtool.
111 have_ld_version_script=no
112 case "${host}" in
113     *-*-linux*)
114         have_ld_version_script=yes
115         ;;
116     *-*-gnu*)
117         have_ld_version_script=yes
118         ;;
119 esac
120 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
121
122 GPG_DEFAULT=no
123 GPGSM_DEFAULT=no
124 component_system=None
125 have_dosish_system=no
126 have_w32_system=no
127 case "${host}" in
128     *-mingw32*)
129         # special stuff for Windoze NT
130         have_dosish_system=yes
131         have_w32_system=yes
132         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
133         # XXX Assuan is not supported in this configuration.
134         #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
135         #component_system='COM+'
136         ;;
137     *)
138         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
139         if test "$have_pth" = yes; then
140           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
141         fi
142         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
143         if test "$have_pthread" = yes; then
144           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
145         fi
146
147         # XXX: Probably use exec-prefix here?
148 #       GPG_DEFAULT='/usr/bin/gpg'
149 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
150         ;;
151 esac
152
153 if test "$have_dosish_system" = yes; then
154    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
155              [Defined if we run on some of the PCDOS like systems 
156               (DOS, Windoze. OS/2) with special properties like
157               no file modes])
158 fi
159 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
160
161 if test "$have_w32_system" = yes; then
162    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
163 fi
164 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
165
166 build_w32_glib=no
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=$withval)
171 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
172
173 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
174 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
175
176
177 # Checks for header files.
178 AC_CHECK_HEADERS(sys/select.h)
179
180
181 # Type checks.
182 AC_C_INLINE
183 AC_CHECK_SIZEOF(unsigned int)
184 AC_SYS_LARGEFILE
185 AC_TYPE_OFF_T
186
187 # Checks for compiler features.
188 if test "$GCC" = yes; then
189     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
190     if test "$have_w32_system" = yes; then
191        CFLAGS="$CFLAGS -mms-bitfields"
192     fi
193 fi
194
195
196 # Checks for library functions.
197 AC_FUNC_FSEEKO
198
199 AC_CHECK_FUNCS(stpcpy)
200
201 AC_REPLACE_FUNCS(vasprintf)
202 if test "$ac_cv_func_vasprintf" != yes; then
203   GNUPG_CHECK_VA_COPY
204 fi
205
206 # Try to find a thread-safe version of ttyname().
207 AC_REPLACE_FUNCS(ttyname_r)
208 if test "$ac_cv_func_ttyname_r" != yes; then
209   AC_MSG_WARN([
210 ***
211 *** ttyname() is not thread-safe and ttyname_r() does not exist
212 ***])
213 fi
214
215 # Try to find a thread-safe version of getenv().
216 have_thread_safe_getenv=no
217 jm_GLIBC21
218 if test $GLIBC21 = yes; then
219   have_thread_safe_getenv=yes
220 fi
221 if test $have_thread_safe_getenv = yes; then
222   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
223 fi
224 have_getenv_r=no
225 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
226 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
227   AC_MSG_WARN([
228 ***
229 *** getenv() is not thread-safe and getenv_r() does not exist
230 ***])
231 fi
232
233 # For converting time strings to seconds since Epoch, we need the timegm
234 # function.
235 AC_CHECK_FUNCS(timegm)
236 if test "$ac_cv_func_timegm" != yes; then
237   AC_MSG_WARN([
238 ***
239 *** timegm() not available - a non-thread-safe kludge will be used
240 *** and the TZ variable might be changed at runtime.
241 ***])
242 fi
243
244 # Checking for libgpg-error.
245 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
246 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
247           [The default error source for GPGME.])
248
249
250
251 # Checks for system services
252 NO_OVERRIDE=no
253 AC_ARG_WITH(gpg,
254             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
255             GPG=$withval, NO_OVERRIDE=yes)
256 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
257   GPG=
258   NO_OVERRIDE=yes
259   if test "$cross_compiling" != "yes"; then
260     AC_PATH_PROG(GPG, gpg)
261   fi
262   if test -z "$GPG"; then
263     GPG="$GPG_DEFAULT"
264   fi
265 fi
266 if test "$GPG" = no; then
267   if test "$NO_OVERRIDE" = "yes"; then
268     if test "$cross_compiling" != "yes"; then
269       AC_MSG_WARN([
270 ***
271 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
272 ***])
273     else
274       AC_MSG_ERROR([
275 ***
276 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
277 ***])
278     fi
279   fi
280 else
281   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
282   AC_SUBST(GPG)
283 fi
284 dnl Check for GnuPG version requirement.
285 GPG_VERSION=unknown
286 ok=maybe
287 if test -z "$GPG" -o "x$GPG" = "xno"; then
288   ok=no
289 else
290   if test "$cross_compiling" = "yes"; then
291     AC_MSG_WARN([GnuPG version can not be checked when cross compiling])
292     ok=no
293   else
294     if test ! -x "$GPG"; then
295       AC_MSG_WARN([GnuPG not executable, version check disabled])
296       ok=no
297     fi
298   fi
299 fi
300 if test "$ok" = "maybe"; then
301   AC_MSG_CHECKING(for GnuPG >= $NEED_GPG_VERSION)
302   req_major=`echo $NEED_GPG_VERSION | \
303              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
304   req_minor=`echo $NEED_GPG_VERSION | \
305              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
306   req_micro=`echo $NEED_GPG_VERSION | \
307              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
308   gpg_version=`$GPG --version | grep ^gpg`
309   major=`echo $gpg_version | \
310          sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
311   minor=`echo $gpg_version | \
312          sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
313   micro=`echo $gpg_version | \
314          sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
315   GPG_VERSION=`echo $gpg_version | sed 's/^gpg (GnuPG) //'`
316
317   if test "$major" -gt "$req_major"; then
318     ok=yes
319   else
320     if test "$major" -eq "$req_major"; then
321       if test "$minor" -gt "$req_minor"; then
322         ok=yes
323       else
324         if test "$minor" -eq "$req_minor"; then
325           if test "$micro" -ge "$req_micro"; then
326             ok=yes
327           fi
328         fi
329       fi
330     fi
331   fi
332   if test "$ok" = "yes"; then
333     AC_MSG_RESULT(yes)
334   else
335     AC_MSG_RESULT(no)
336     AC_MSG_WARN([GnuPG must be at least version $NEED_GPG_VERSION])
337   fi
338 fi
339 AM_CONDITIONAL(RUN_GPG_TESTS, test "$ok" = "yes")
340 AC_SUBST(GPG_PATH)
341
342 NO_OVERRIDE=no
343 AC_ARG_WITH(gpgsm,
344             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
345             GPGSM=$withval, NO_OVERRIDE=yes)
346 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
347   GPGSM=
348   NO_OVERRIDE=yes
349   if test "$cross_compiling" != "yes"; then
350     AC_PATH_PROG(GPGSM, gpgsm)
351   fi
352   if test -z "$GPGSM"; then
353     GPGSM="$GPGSM_DEFAULT"
354   fi
355 fi
356 if test "$GPGSM" = no; then
357   if test "$NO_OVERRIDE" = "yes"; then
358     if test "$cross_compiling" != "yes"; then
359       AC_MSG_WARN([
360 ***
361 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
362 ***])
363     else
364       AC_MSG_ERROR([
365 ***
366 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
367 ***])
368     fi
369   fi
370 else
371   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
372   AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
373 fi
374 AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
375
376
377 dnl Check for GPGSM version requirement.
378 GPGSM_VERSION=unknown
379 ok=maybe
380 if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
381   ok=no
382 else
383   if test "$cross_compiling" = "yes"; then
384     AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
385     ok=no
386   else
387     if test ! -x "$GPGSM"; then
388       AC_MSG_WARN([GPGSM not executable, version check disabled])
389       ok=no
390     fi
391   fi
392 fi
393 if test "$ok" = "maybe"; then
394   AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
395   req_major=`echo $NEED_GPGSM_VERSION | \
396              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
397   req_minor=`echo $NEED_GPGSM_VERSION | \
398              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
399   req_micro=`echo $NEED_GPGSM_VERSION | \
400              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
401   gpgsm_version=`$GPGSM --version | grep ^gpgsm`
402   major=`echo $gpgsm_version | \
403          sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
404   minor=`echo $gpgsm_version | \
405          sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
406   micro=`echo $gpgsm_version | \
407          sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
408   GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
409
410   if test "$major" -gt "$req_major"; then
411     ok=yes
412   else
413     if test "$major" -eq "$req_major"; then
414       if test "$minor" -gt "$req_minor"; then
415         ok=yes
416       else
417         if test "$minor" -eq "$req_minor"; then
418           if test "$micro" -ge "$req_micro"; then
419             ok=yes
420           fi
421         fi
422       fi
423     fi
424   fi
425   if test "$ok" = "yes"; then
426     AC_MSG_RESULT(yes)
427   else
428     AC_MSG_RESULT(no)
429     AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
430   fi
431 fi
432 AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$ok" = "yes")
433
434 # FIXME: Only build if supported.
435 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
436
437
438 # The assuan code uses funopen but it will also build without it.  So
439 # test for it.  Frankly, this is not required in gpgme, but thats the
440 # way we handle it in libassuan.
441 AC_CHECK_FUNCS(funopen)
442 if test $ac_cv_func_funopen != yes; then
443     # No funopen but we can implement that in terms of fopencookie.
444     AC_CHECK_FUNCS(fopencookie)
445     if test $ac_cv_func_fopencookie = yes; then
446         AC_LIBOBJ([funopen])
447     else
448         AC_MSG_WARN([
449 ***
450 *** No implementation of fopencookie or funopen available
451 ***])
452     fi
453 fi
454
455 # More assuan replacement functions.
456 AC_REPLACE_FUNCS(isascii)
457 AC_REPLACE_FUNCS(putc_unlocked)
458 AC_REPLACE_FUNCS(memrchr)
459
460 # More assuan checks.
461 AC_CHECK_HEADERS([sys/uio.h])
462
463 # End of assuan checks.
464
465 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
466
467 # Make the version number in gpgme/gpgme.h the same as the one here.
468 # (this is easier than to have a *.in file just for one substitution)
469 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
470
471 # Generate values for the DLL version info
472 changequote(,)dnl 
473 BUILD_REVISION="`echo '$Revision$' | sed 's/[^0-9]//g'`"
474 changequote([,])dnl
475 test -z "$BUILD_REVISION" && BUILD_REVISION="0"
476 if test "$have_w32_system" = yes; then
477     BUILD_TIMESTAMP=`date --iso-8601=minutes`
478     changequote(,)dnl 
479     BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
480     changequote([,])dnl
481     BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
482 fi
483 AC_SUBST(BUILD_REVISION)
484 AC_SUBST(BUILD_TIMESTAMP)
485 AC_SUBST(BUILD_FILEVERSION)
486
487 # Add a few constants to help porting to W32
488 AH_VERBATIM([SEPCONSTANTS],
489 [
490 /* Separators as used in file names and $PATH. Please note that the
491    string version must not contain more than one character because
492    the using code assumes strlen()==1 */
493 #ifdef HAVE_DOSISH_SYSTEM
494 #define DIRSEP_C '\\\\'
495 #define EXTSEP_C '.'
496 #define DIRSEP_S "\\\\"
497 #define EXTSEP_S "."
498 #define PATHSEP_C ';'
499 #define PATHSEP_S ";"
500 #else
501 #define DIRSEP_C '/'
502 #define EXTSEP_C '.'
503 #define DIRSEP_S "/"
504 #define EXTSEP_S "."
505 #define PATHSEP_C ':'
506 #define PATHSEP_S ":"
507 #endif
508 ])
509
510 AH_BOTTOM([
511 /* Definition of GCC specific attributes.  */
512 #if __GNUC__ > 2 
513 # define GPGME_GCC_A_PURE  __attribute__ ((__pure__))
514 #else
515 # define GPGME_GCC_A_PURE
516 #endif
517 ])
518
519
520 # Substitution used for gpgme-config 
521 GPGME_CONFIG_LIBS="-lgpgme"
522 GPGME_CONFIG_CFLAGS=""
523 AC_SUBST(GPGME_CONFIG_API_VERSION)
524 AC_SUBST(GPGME_CONFIG_LIBS)
525 AC_SUBST(GPGME_CONFIG_CFLAGS)
526
527 # Frob'da Variables
528 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
529            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
530 AC_SUBST(LTLIBOBJS)
531
532 #
533 # Create config files 
534
535 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
536                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
537                 doc/Makefile complus/Makefile
538                 gpgme/versioninfo.rc)
539 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
540 AC_OUTPUT
541
542 echo "
543         GPGME v${VERSION} has been configured as follows:
544
545         GnuPG path:    $GPG
546         GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION
547
548         GpgSM path:    $GPGSM
549         GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION
550
551         GPGME Pthread: $have_pthread
552         GPGME Pth:     $have_pth
553 "