2002-06-02 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 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 numbers (Remember to change them just before a release.)
24 #   (Code changed:                      REVISION++)
25 #   (Interfaces added/removed/changed:  CURRENT++, REVISION=0)
26 #   (Interfaces added:                  AGE++)
27 #   (Interfaces removed:                AGE=0)
28 #
29 AC_INIT(gpgme, 0.3.7-cvs, [gnupg-devel@gnupg.org])
30 LIBGPGME_LT_CURRENT=8
31 LIBGPGME_LT_AGE=2
32 LIBGPGME_LT_REVISION=0
33 NEED_GPG_VERSION=1.0.7
34 NEED_GPGSM_VERSION=0.3.7
35 ##############################################
36 AC_PREREQ(2.52)
37 AC_REVISION($Revision$)
38
39 PACKAGE=$PACKAGE_NAME
40 VERSION=$PACKAGE_VERSION
41
42 AC_CONFIG_SRCDIR(gpgme/gpgme.h)
43 AM_CONFIG_HEADER(config.h)
44 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
45 AM_MAINTAINER_MODE
46
47 AH_VERBATIM([_GNU_SOURCE],
48 [/* Enable GNU extensions on systems that have them.  */
49 #ifndef _GNU_SOURCE
50 # define _GNU_SOURCE
51 #endif])
52
53 AH_VERBATIM([_REENTRANT],
54 [/* To allow the use of GPGME in multithreaded programs we have to use
55   special features from the library.
56   IMPORTANT: gpgme is not yet fully reentrant and you should use it
57   only from one thread.  */
58 #ifndef _REENTRANT
59 # define _REENTRANT 1
60 #endif])
61
62
63 AC_PROG_CC
64
65
66 AC_SUBST(LIBGPGME_LT_CURRENT)
67 AC_SUBST(LIBGPGME_LT_AGE)
68 AC_SUBST(LIBGPGME_LT_REVISION)
69 AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION",
70                                      [Min. needed GnuPG version.])
71 AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
72                                        [Min. needed GPGSM version.])
73
74 AC_SUBST(PACKAGE)
75 AC_SUBST(VERSION)
76 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
77 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
78
79 dnl Don't default to build static libs.
80 dnl AC_DISABLE_STATIC
81 AC_PROG_LIBTOOL
82
83 GPG_DEFAULT=no
84 GPGSM_DEFAULT=no
85 component_system=None
86 case "${target}" in
87     *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* )
88         # special stuff for Windoze NT
89         # OS/2 with the EMX environment
90         # DOS with the DJGPP environment
91         AC_DEFINE(HAVE_DRIVE_LETTERS, ,
92                   [Defined if we run on some of the PCDOS like systems (DOS,
93                    Windoze, OS/2) with special properties like no file modes.])
94         AC_DEFINE(HAVE_DOSISH_SYSTEM, ,
95                   [Defined if the filesystem uses driver letters.])
96         have_dosish_system=yes
97         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
98         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
99         #component_system='COM+'
100         ;;
101     *)
102         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
103         if test "$have_pth" = yes; then
104           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
105           CFLAGS="$CFLAGS $PTH_CFLAGS"
106         fi
107         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
108         if test "$have_pthread" = yes; then
109           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
110         fi
111
112 dnl     # XXX: Probably use exec-prefix here?
113 dnl     GPG_DEFAULT='/usr/bin/gpg'
114 dnl     GPGSM_DEFAULT='/usr/bin/gpgsm'
115         ;;
116 esac
117 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes")
118 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
119 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
120
121 dnl
122 dnl Checks for libraries.
123 dnl
124
125 dnl FIXME: check whether Bonobo is installed
126
127 dnl
128 dnl Checks for header files.
129 dnl
130
131 dnl
132 dnl Checks for typedefs and structures.
133 dnl
134 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
135 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
136 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
137 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
138 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
139
140 dnl We should not use them in this software;
141 dnl However jnlib/types.h needs them - so we take the easy way.
142 AC_CHECK_SIZEOF(unsigned short)
143 AC_CHECK_SIZEOF(unsigned int)
144 AC_CHECK_SIZEOF(unsigned long)
145
146 dnl
147 dnl Checks for compiler features.
148 dnl
149
150 if test "$GCC" = yes; then
151     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
152 fi
153
154 dnl
155 dnl Checks for library functions.
156 dnl
157 dnl These are needed by libjnlib
158 AC_CHECK_FUNCS(memicmp stpcpy strlwr strtoul memmove stricmp)
159
160 # asprintf() is at least used in assuan
161 AC_REPLACE_FUNCS(vasprintf)
162 # Note: fopencokie is only a dummy stub and not used.  
163 #       However some code in assuan/ links against it.
164 AC_REPLACE_FUNCS(fopencookie)
165
166
167 dnl We use jnlib, so tell other modules about it
168 AC_DEFINE(HAVE_JNLIB_LOGGING, 1,
169         [Defined if jnlib style logging fucntions are available.])
170
171 dnl
172 dnl Checks for system services
173 dnl
174
175 NO_OVERRIDE=no
176 AC_ARG_WITH(gpg,
177             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
178             GPG=$withval, NO_OVERRIDE=yes)
179 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
180   GPG=
181   NO_OVERRIDE=yes
182   if test "$cross_compiling" != "yes"; then
183     AC_PATH_PROG(GPG, gpg)
184   fi
185   if test -z "$GPG"; then
186     GPG="$GPG_DEFAULT"
187   fi
188 fi
189 if test "$GPG" = no; then
190   if test "$NO_OVERRIDE" = "yes"; then
191     if test "$cross_compiling" != "yes"; then
192       AC_MSG_WARN([Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it])
193     else
194       AC_MSG_ERROR([Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH])
195     fi
196   fi
197 else
198   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
199   AC_SUBST(GPG)
200 fi
201 AM_CONDITIONAL(RUN_GPG_TESTS,
202   [test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"])
203 AC_SUBST(GPG_PATH)
204
205 NO_OVERRIDE=no
206 AC_ARG_WITH(gpgsm,
207             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
208             GPGSM=$withval, NO_OVERRIDE=yes)
209 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
210   GPGSM=
211   NO_OVERRIDE=yes
212   if test "$cross_compiling" != "yes"; then
213     AC_PATH_PROG(GPGSM, gpgsm)
214   fi
215   if test -z "$GPGSM"; then
216     GPGSM="$GPGSM_DEFAULT"
217   fi
218 fi
219 if test "$GPGSM" = no; then
220   if test "$NO_OVERRIDE" = "yes"; then
221     if test "$cross_compiling" != "yes"; then
222       AC_MSG_WARN([Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it])
223     else
224       AC_MSG_ERROR([Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH])
225     fi
226   fi
227 else
228   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
229   AC_SUBST(GPGSM)
230 fi
231 AM_CONDITIONAL(RUN_GPGSM_TESTS,
232   [test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"])
233
234 dnl FIXME: Only build if supported.
235 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
236
237 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
238 AM_CONDITIONAL(BUILD_BONOBO,  test "$component_system" = "Bonobo")
239
240 GPGMEPLUG=no
241 AC_ARG_ENABLE(gpgmeplug,
242             AC_HELP_STRING([--enable-gpgmeplug], [build GPGME Crypt Plug-In]),
243             GPGMEPLUG=$enableval)
244 AM_CONDITIONAL(BUILD_GPGMEPLUG, test "$GPGMEPLUG" = "yes")
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_LIBS="-L${libdir} -lgpgme"
252 GPGME_CFLAGS=""
253 AC_SUBST(GPGME_LIBS)
254 AC_SUBST(GPGME_CFLAGS)
255
256 dnl
257 dnl Create config files 
258 dnl
259
260 AC_CONFIG_FILES(Makefile assuan/Makefile jnlib/Makefile gpgme/Makefile
261                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
262                 doc/Makefile
263                 bonobo/Makefile complus/Makefile gpgmeplug/Makefile)
264 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
265 AC_OUTPUT
266
267 echo "
268         GPGME v${VERSION} has been configured as follows:
269
270         GnuPG version: min. $NEED_GPG_VERSION
271         GnuPG path:    $GPG
272
273         GpgSM version: min. $NEED_GPGSM_VERSION
274         GpgSM path:    $GPGSM
275
276         GPGME CryptPlug: $GPGMEPLUG
277 "