2003-08-18 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / configure.ac
1 # configure.in for GPGME
2 # Copyright (C) 2000 Werner Koch (dd9jn)
3 # Copyright (C) 2001, 2002, 2003 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 # Version number: Remember to change it immediately *after* a release.
24 AC_INIT(gpgme, 0.4.3, [bug-gpgme@gnupg.org])
25 # LT Version numbers, remember to change them just *before* a release.
26 #   (Code changed:                      REVISION++)
27 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
28 #   (Interfaces added:                  AGE++)
29 #   (Interfaces removed:                AGE=0)
30 #
31 LIBGPGME_LT_CURRENT=11
32 LIBGPGME_LT_AGE=0
33 LIBGPGME_LT_REVISION=1
34 NEED_GPG_VERSION=1.2.2
35 NEED_GPGSM_VERSION=0.9.0
36 ##############################################
37 AC_PREREQ(2.52)
38 AC_REVISION($Revision$)
39
40 PACKAGE=$PACKAGE_NAME
41 VERSION=$PACKAGE_VERSION
42
43 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
44 AM_CONFIG_HEADER(config.h)
45 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
46 AM_MAINTAINER_MODE
47
48 AH_VERBATIM([_GNU_SOURCE],
49 [/* Enable GNU extensions on systems that have them.  */
50 #ifndef _GNU_SOURCE
51 # define _GNU_SOURCE
52 #endif])
53
54 AH_VERBATIM([_REENTRANT],
55 [/* To allow the use of GPGME in multithreaded programs we have to use
56   special features from the library.
57   IMPORTANT: gpgme is not yet fully reentrant and you should use it
58   only from one thread.  */
59 #ifndef _REENTRANT
60 # define _REENTRANT 1
61 #endif])
62
63
64 AC_PROG_CC
65
66
67 AC_SUBST(LIBGPGME_LT_CURRENT)
68 AC_SUBST(LIBGPGME_LT_AGE)
69 AC_SUBST(LIBGPGME_LT_REVISION)
70 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
71                                      [Min. needed GnuPG version.])
72 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
73                                        [Min. needed GPGSM version.])
74
75 AC_SUBST(PACKAGE)
76 AC_SUBST(VERSION)
77 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
78 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
79
80 # Don't default to build static libs.
81 AC_DISABLE_STATIC
82 AC_PROG_LIBTOOL
83
84 AC_CANONICAL_HOST
85 # For now we hardcode the use of version scripts.  It would be better
86 # to write a test for this or even implement this within libtool.
87 have_ld_version_script=no
88 case "${host}" in
89     *-*-linux*)
90         have_ld_version_script=yes
91         ;;
92     *-*-gnu*)
93         have_ld_version_script=yes
94         ;;
95 esac
96 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
97
98 GPG_DEFAULT=no
99 GPGSM_DEFAULT=no
100 component_system=None
101 case "${host}" in
102     *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* )
103         # special stuff for Windoze NT
104         # OS/2 with the EMX environment
105         # DOS with the DJGPP environment
106         AC_DEFINE(HAVE_DRIVE_LETTERS, ,
107                   [Defined if we run on some of the PCDOS like systems (DOS,
108                    Windoze, OS/2) with special properties like no file modes.])
109         AC_DEFINE(HAVE_DOSISH_SYSTEM, ,
110                   [Defined if the filesystem uses driver letters.])
111         have_dosish_system=yes
112         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
113         # XXX Assuan is not supported in this configuration.
114         #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
115         #component_system='COM+'
116         ;;
117     *)
118         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
119         if test "$have_pth" = yes; then
120           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
121           CFLAGS="$CFLAGS $PTH_CFLAGS"
122         fi
123         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
124         if test "$have_pthread" = yes; then
125           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
126         fi
127
128         # XXX: Probably use exec-prefix here?
129 #       GPG_DEFAULT='/usr/bin/gpg'
130 #       GPGSM_DEFAULT='/usr/bin/gpgsm'
131         ;;
132 esac
133 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes")
134 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
135 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
136
137
138 # Checks for header files.
139 AC_CHECK_HEADERS(sys/select.h)
140
141
142 # Type checks.
143 AC_CHECK_SIZEOF(unsigned int)
144
145
146 # Checks for compiler features.
147 if test "$GCC" = yes; then
148     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
149 fi
150
151
152 # Checks for library functions.
153 AC_REPLACE_FUNCS(stpcpy)
154
155 AC_REPLACE_FUNCS(vasprintf)
156 if test "$ac_cv_func_vasprintf" != yes; then
157   GNUPG_CHECK_VA_COPY
158 fi
159
160 AM_PATH_GPG_ERROR(0.1,, AC_MSG_ERROR([libgpg-error was not found]))
161 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
162           [The default error source for GPGME.])
163
164 # Checks for system services
165 NO_OVERRIDE=no
166 AC_ARG_WITH(gpg,
167             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
168             GPG=$withval, NO_OVERRIDE=yes)
169 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
170   GPG=
171   NO_OVERRIDE=yes
172   if test "$cross_compiling" != "yes"; then
173     AC_PATH_PROG(GPG, gpg)
174   fi
175   if test -z "$GPG"; then
176     GPG="$GPG_DEFAULT"
177   fi
178 fi
179 if test "$GPG" = no; then
180   if test "$NO_OVERRIDE" = "yes"; then
181     if test "$cross_compiling" != "yes"; then
182       AC_MSG_WARN([Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it])
183     else
184       AC_MSG_ERROR([Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH])
185     fi
186   fi
187 else
188   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
189   AC_SUBST(GPG)
190 fi
191 AM_CONDITIONAL(RUN_GPG_TESTS,
192   [test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"])
193 AC_SUBST(GPG_PATH)
194
195 NO_OVERRIDE=no
196 AC_ARG_WITH(gpgsm,
197             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
198             GPGSM=$withval, NO_OVERRIDE=yes)
199 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
200   GPGSM=
201   NO_OVERRIDE=yes
202   if test "$cross_compiling" != "yes"; then
203     AC_PATH_PROG(GPGSM, gpgsm)
204   fi
205   if test -z "$GPGSM"; then
206     GPGSM="$GPGSM_DEFAULT"
207   fi
208 fi
209 if test "$GPGSM" = no; then
210   if test "$NO_OVERRIDE" = "yes"; then
211     if test "$cross_compiling" != "yes"; then
212       AC_MSG_WARN([Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it])
213     else
214       AC_MSG_ERROR([Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH])
215     fi
216   fi
217 else
218   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
219   AC_SUBST(GPGSM)
220 fi
221 AM_CONDITIONAL(HAVE_GPGSM, [test -n "$GPGSM" && test -r "$GPGSM"])
222 AM_CONDITIONAL(RUN_GPGSM_TESTS,
223   [test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"])
224
225 # FIXME: Only build if supported.
226 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
227
228 if test "$GPGSM" != "no"; then
229   AC_CHECK_FUNCS(funopen)
230   if test $ac_cv_func_funopen != yes; then
231     # No funopen but we can implement that in terms of fopencookie.
232     AC_CHECK_FUNCS(fopencookie, AC_LIBOBJ(funopen),
233                    AC_MSG_ERROR([[
234 No implementation of fopencookie or funopen available.
235 ]]))
236   fi
237
238   AC_REPLACE_FUNCS(isascii)
239   AC_REPLACE_FUNCS(putc_unlocked)
240   AC_REPLACE_FUNCS(memrchr)
241 fi
242
243
244 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
245
246 dnl Make the version number in gpgme/gpgme.h the same as the one here.
247 dnl (this is easier than to have a *.in file just for one substitution)
248 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
249
250 dnl Substitution used for gpgme-config 
251 GPGME_CONFIG_LIBS="-lgpgme"
252 GPGME_CONFIG_CFLAGS=""
253 AC_SUBST(GPGME_CONFIG_LIBS)
254 AC_SUBST(GPGME_CONFIG_CFLAGS)
255
256 dnl Frob'da Variables
257 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
258            sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
259 AC_SUBST(LTLIBOBJS)
260
261 dnl
262 dnl Create config files 
263 dnl
264
265 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
266                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
267                 doc/Makefile complus/Makefile)
268 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
269 AC_OUTPUT
270
271 echo "
272         GPGME v${VERSION} has been configured as follows:
273
274         GnuPG version: min. $NEED_GPG_VERSION
275         GnuPG path:    $GPG
276
277         GpgSM version: min. $NEED_GPGSM_VERSION
278         GpgSM path:    $GPGSM
279 "