D'oh, forget the release date in the released NEWS entry!
[gpgme.git] / configure.ac
1 # configure.in for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
4
5 # This file is part of GPGME.
6
7 # GPGME is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # GPGME is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # 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
23 AC_PREREQ(2.57)
24 min_automake_version="1.7.6"
25
26 # Version number: Remember to change it immediately *after* a release.
27 AC_INIT(gpgme, 0.9.1-cvs, [bug-gpgme@gnupg.org])
28 # LT Version numbers, remember to change them just *before* a release.
29 #   (Code changed:                      REVISION++)
30 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
31 #   (Interfaces added:                  AGE++)
32 #   (Interfaces removed/changed:        AGE=0)
33 #
34 LIBGPGME_LT_CURRENT=13
35 # Subtract 2 from this value if you want to make the LFS transition an
36 # ABI break.  [Note to self: Remove this comment with the next regular break.]
37 LIBGPGME_LT_AGE=2
38 LIBGPGME_LT_REVISION=2
39
40 # If the API is changed in an incompatible way: increment the next counter.
41 GPGME_CONFIG_API_VERSION=1
42
43 NEED_GPG_VERSION=1.2.2
44 NEED_GPGSM_VERSION=1.9.6
45 ##############################################
46 AC_PREREQ(2.52)
47 AC_REVISION($Revision$)
48
49 PACKAGE=$PACKAGE_NAME
50 VERSION=$PACKAGE_VERSION
51
52 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
53 AM_CONFIG_HEADER(config.h)
54 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
55 AM_MAINTAINER_MODE
56 AC_CANONICAL_HOST
57
58 AH_VERBATIM([_GNU_SOURCE],
59 [/* Enable GNU extensions on systems that have them.  */
60 #ifndef _GNU_SOURCE
61 # define _GNU_SOURCE
62 #endif])
63
64 AH_VERBATIM([_REENTRANT],
65 [/* To allow the use of GPGME in multithreaded programs we have to use
66   special features from the library.
67   IMPORTANT: gpgme is not yet fully reentrant and you should use it
68   only from one thread.  */
69 #ifndef _REENTRANT
70 # define _REENTRANT 1
71 #endif])
72
73
74 AC_PROG_CC
75
76
77 AC_SUBST(LIBGPGME_LT_CURRENT)
78 AC_SUBST(LIBGPGME_LT_AGE)
79 AC_SUBST(LIBGPGME_LT_REVISION)
80 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
81                                      [Min. needed GnuPG version.])
82 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
83                                        [Min. needed GPGSM version.])
84
85 AC_SUBST(PACKAGE)
86 AC_SUBST(VERSION)
87 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
88 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
89
90 # Don't default to build static libs.
91 AC_DISABLE_STATIC
92 AC_PROG_LIBTOOL
93
94 # For now we hardcode the use of version scripts.  It would be better
95 # to write a test for this or even implement this within libtool.
96 have_ld_version_script=no
97 case "${host}" in
98     *-*-linux*)
99         have_ld_version_script=yes
100         ;;
101     *-*-gnu*)
102         have_ld_version_script=yes
103         ;;
104 esac
105 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
106
107 GPG_DEFAULT=no
108 GPGSM_DEFAULT=no
109 component_system=None
110 case "${host}" in
111     *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* )
112         # special stuff for Windoze NT
113         # OS/2 with the EMX environment
114         # DOS with the DJGPP environment
115         AC_DEFINE(HAVE_DRIVE_LETTERS, ,
116                   [Defined if we run on some of the PCDOS like systems (DOS,
117                    Windoze, OS/2) with special properties like no file modes.])
118         AC_DEFINE(HAVE_DOSISH_SYSTEM, ,
119                   [Defined if the filesystem uses driver letters.])
120         have_dosish_system=yes
121         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
122         # XXX Assuan is not supported in this configuration.
123         #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
124         #component_system='COM+'
125         ;;
126     *)
127         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
128         if test "$have_pth" = yes; then
129           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
130           CFLAGS="$CFLAGS $PTH_CFLAGS"
131         fi
132         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
133         if test "$have_pthread" = yes; then
134           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
135         fi
136
137         # XXX: Probably use exec-prefix here?
138 #       GPG_DEFAULT='/usr/bin/gpg'
139 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
140         ;;
141 esac
142 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes")
143 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
144 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
145
146
147 # Checks for header files.
148 AC_CHECK_HEADERS(sys/select.h)
149
150
151 # Type checks.
152 AC_CHECK_SIZEOF(unsigned int)
153 AC_SYS_LARGEFILE
154 AC_TYPE_OFF_T
155
156 # Checks for compiler features.
157 if test "$GCC" = yes; then
158     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
159 fi
160
161
162 # Checks for library functions.
163 AC_FUNC_FSEEKO
164
165 AC_REPLACE_FUNCS(stpcpy)
166
167 AC_REPLACE_FUNCS(vasprintf)
168 if test "$ac_cv_func_vasprintf" != yes; then
169   GNUPG_CHECK_VA_COPY
170 fi
171
172 # Try to find a thread-safe version of getenv().
173 have_thread_safe_getenv=no
174 jm_GLIBC21
175 if test $GLIBC21 = yes; then
176   have_thread_safe_getenv=yes
177 fi
178 if test $have_thread_safe_getenv = yes; then
179   AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe])
180 fi
181 have_getenv_r=no
182 AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes)
183 if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then
184   AC_MSG_WARN([
185 ***
186 *** getenv() is not thread-safe and getenv_r() does not exist
187 ***])
188 fi
189
190 # For converting time strings to seconds since Epoch, we need the timegm
191 # function.
192 AC_CHECK_FUNCS(timegm)
193 if test "$ac_cv_func_timegm" != yes; then
194   AC_MSG_WARN([
195 ***
196 *** timegm() not available - a non-thread-safe kludge will be used
197 *** and the TZ variable might be changed at runtime.
198 ***])
199 fi
200
201 # Checking for libgpg-error.
202 AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found]))
203 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
204           [The default error source for GPGME.])
205
206
207
208 # Checks for system services
209 NO_OVERRIDE=no
210 AC_ARG_WITH(gpg,
211             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
212             GPG=$withval, NO_OVERRIDE=yes)
213 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
214   GPG=
215   NO_OVERRIDE=yes
216   if test "$cross_compiling" != "yes"; then
217     AC_PATH_PROG(GPG, gpg)
218   fi
219   if test -z "$GPG"; then
220     GPG="$GPG_DEFAULT"
221   fi
222 fi
223 if test "$GPG" = no; then
224   if test "$NO_OVERRIDE" = "yes"; then
225     if test "$cross_compiling" != "yes"; then
226       AC_MSG_WARN([
227 ***
228 *** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it
229 ***])
230     else
231       AC_MSG_ERROR([
232 ***
233 *** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH
234 ***])
235     fi
236   fi
237 else
238   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
239   AC_SUBST(GPG)
240 fi
241 AM_CONDITIONAL(RUN_GPG_TESTS,
242   [test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"])
243 AC_SUBST(GPG_PATH)
244
245 NO_OVERRIDE=no
246 AC_ARG_WITH(gpgsm,
247             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
248             GPGSM=$withval, NO_OVERRIDE=yes)
249 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
250   GPGSM=
251   NO_OVERRIDE=yes
252   if test "$cross_compiling" != "yes"; then
253     AC_PATH_PROG(GPGSM, gpgsm)
254   fi
255   if test -z "$GPGSM"; then
256     GPGSM="$GPGSM_DEFAULT"
257   fi
258 fi
259 if test "$GPGSM" = no; then
260   if test "$NO_OVERRIDE" = "yes"; then
261     if test "$cross_compiling" != "yes"; then
262       AC_MSG_WARN([
263 ***
264 *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
265 ***])
266     else
267       AC_MSG_ERROR([
268 ***
269 *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
270 ***])
271     fi
272   fi
273 else
274   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
275   AC_SUBST(GPGSM)
276 fi
277 AM_CONDITIONAL(HAVE_GPGSM, [test -n "$GPGSM" && test -r "$GPGSM"])
278 AM_CONDITIONAL(RUN_GPGSM_TESTS,
279   [test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"])
280
281 # FIXME: Only build if supported.
282 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
283
284
285 # The assuan code uses funopen but it will also build without it.  So
286 # test for it.  Frankly, this is not required in gpgme, but thats the
287 # way we handle it in libassuan.
288 AC_CHECK_FUNCS(funopen)
289 if test $ac_cv_func_funopen != yes; then
290     # No funopen but we can implement that in terms of fopencookie.
291     AC_CHECK_FUNCS(fopencookie)
292     if test $ac_cv_func_fopencookie = yes; then
293         AC_LIBOBJ([funopen])
294     else
295         AC_MSG_WARN([
296 ***
297 *** No implementation of fopencookie or funopen available
298 ***])
299     fi
300 fi
301
302 AC_REPLACE_FUNCS(isascii)
303 AC_REPLACE_FUNCS(putc_unlocked)
304 AC_REPLACE_FUNCS(memrchr)
305
306
307 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
308
309 # Make the version number in gpgme/gpgme.h the same as the one here.
310 # (this is easier than to have a *.in file just for one substitution)
311 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
312
313 # Substitution used for gpgme-config 
314 GPGME_CONFIG_LIBS="-lgpgme"
315 GPGME_CONFIG_CFLAGS=""
316 AC_SUBST(GPGME_CONFIG_API_VERSION)
317 AC_SUBST(GPGME_CONFIG_LIBS)
318 AC_SUBST(GPGME_CONFIG_CFLAGS)
319
320 # Frob'da Variables
321 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
322            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
323 AC_SUBST(LTLIBOBJS)
324
325 #
326 # Create config files 
327
328 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
329                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
330                 doc/Makefile complus/Makefile)
331 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
332 AC_OUTPUT
333
334 echo "
335         GPGME v${VERSION} has been configured as follows:
336
337         GnuPG version: min. $NEED_GPG_VERSION
338         GnuPG path:    $GPG
339
340         GpgSM version: min. $NEED_GPGSM_VERSION
341         GpgSM path:    $GPGSM
342 "