2002-08-21 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 number: Remember to change it immediately *after* a release.
24 AC_INIT(gpgme, 0.3.9, [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=9
32 LIBGPGME_LT_AGE=3
33 LIBGPGME_LT_REVISION=0
34 NEED_GPG_VERSION=1.0.7
35 NEED_GPGSM_VERSION=0.3.8
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 dnl Don't default to build static libs.
81 dnl AC_DISABLE_STATIC
82 AC_PROG_LIBTOOL
83
84 GPG_DEFAULT=no
85 GPGSM_DEFAULT=no
86 component_system=None
87 case "${target}" in
88     *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* )
89         # special stuff for Windoze NT
90         # OS/2 with the EMX environment
91         # DOS with the DJGPP environment
92         AC_DEFINE(HAVE_DRIVE_LETTERS, ,
93                   [Defined if we run on some of the PCDOS like systems (DOS,
94                    Windoze, OS/2) with special properties like no file modes.])
95         AC_DEFINE(HAVE_DOSISH_SYSTEM, ,
96                   [Defined if the filesystem uses driver letters.])
97         have_dosish_system=yes
98         GPG_DEFAULT='c:\\gnupg\\gpg.exe'
99         GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
100         #component_system='COM+'
101         ;;
102     *)
103         AC_CHECK_PTH(1.2.0,,,no,have_pth=yes)
104         if test "$have_pth" = yes; then
105           AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.])
106           CFLAGS="$CFLAGS $PTH_CFLAGS"
107         fi
108         AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
109         if test "$have_pthread" = yes; then
110           AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
111         fi
112
113 dnl     # XXX: Probably use exec-prefix here?
114 dnl     GPG_DEFAULT='/usr/bin/gpg'
115 dnl     GPGSM_DEFAULT='/usr/bin/gpgsm'
116         ;;
117 esac
118 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes")
119 AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
120 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
121
122 dnl
123 dnl Checks for libraries.
124 dnl
125
126 dnl FIXME: check whether Bonobo is installed
127
128 dnl
129 dnl Checks for header files.
130 dnl
131
132 dnl
133 dnl Checks for typedefs and structures.
134 dnl
135 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
136 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
137 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
138 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
139 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
140
141 AC_CHECK_SIZEOF(unsigned int)
142
143 dnl
144 dnl Checks for compiler features.
145 dnl
146
147 if test "$GCC" = yes; then
148     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
149 fi
150
151 dnl
152 dnl Checks for library functions.
153 dnl
154
155 AC_REPLACE_FUNCS(stpcpy)
156
157 # asprintf() is at least used in assuan
158 AC_REPLACE_FUNCS(vasprintf)
159 # Note: fopencokie is only a dummy stub and not used.  
160 #       However some code in assuan/ links against it.
161 AC_REPLACE_FUNCS(fopencookie)
162
163
164 dnl
165 dnl Checks for system services
166 dnl
167
168 NO_OVERRIDE=no
169 AC_ARG_WITH(gpg,
170             AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
171             GPG=$withval, NO_OVERRIDE=yes)
172 if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
173   GPG=
174   NO_OVERRIDE=yes
175   if test "$cross_compiling" != "yes"; then
176     AC_PATH_PROG(GPG, gpg)
177   fi
178   if test -z "$GPG"; then
179     GPG="$GPG_DEFAULT"
180   fi
181 fi
182 if test "$GPG" = no; then
183   if test "$NO_OVERRIDE" = "yes"; then
184     if test "$cross_compiling" != "yes"; then
185       AC_MSG_WARN([Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it])
186     else
187       AC_MSG_ERROR([Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH])
188     fi
189   fi
190 else
191   AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
192   AC_SUBST(GPG)
193 fi
194 AM_CONDITIONAL(RUN_GPG_TESTS,
195   [test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"])
196 AC_SUBST(GPG_PATH)
197
198 NO_OVERRIDE=no
199 AC_ARG_WITH(gpgsm,
200             AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
201             GPGSM=$withval, NO_OVERRIDE=yes)
202 if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
203   GPGSM=
204   NO_OVERRIDE=yes
205   if test "$cross_compiling" != "yes"; then
206     AC_PATH_PROG(GPGSM, gpgsm)
207   fi
208   if test -z "$GPGSM"; then
209     GPGSM="$GPGSM_DEFAULT"
210   fi
211 fi
212 if test "$GPGSM" = no; then
213   if test "$NO_OVERRIDE" = "yes"; then
214     if test "$cross_compiling" != "yes"; then
215       AC_MSG_WARN([Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it])
216     else
217       AC_MSG_ERROR([Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH])
218     fi
219   fi
220 else
221   AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
222   AC_SUBST(GPGSM)
223 fi
224 AM_CONDITIONAL(RUN_GPGSM_TESTS,
225   [test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"])
226
227 dnl FIXME: Only build if supported.
228 AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
229
230 AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
231 AM_CONDITIONAL(BUILD_BONOBO,  test "$component_system" = "Bonobo")
232
233 GPGMEPLUG=no
234 AC_ARG_ENABLE(gpgmeplug,
235             AC_HELP_STRING([--enable-gpgmeplug], [build GPGME Crypt Plug-In]),
236             GPGMEPLUG=$enableval)
237 AM_CONDITIONAL(BUILD_GPGMEPLUG, test "$GPGMEPLUG" = "yes")
238
239 dnl Make the version number in gpgme/gpgme.h the same as the one here.
240 dnl (this is easier than to have a *.in file just for one substitution)
241 GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
242
243 dnl Substitution used for gpgme-config 
244 GPGME_LIBS="-L${libdir} -lgpgme"
245 GPGME_CFLAGS=""
246 AC_SUBST(GPGME_LIBS)
247 AC_SUBST(GPGME_CFLAGS)
248
249 dnl
250 dnl Create config files 
251 dnl
252
253 AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
254                 tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
255                 doc/Makefile
256                 bonobo/Makefile complus/Makefile gpgmeplug/Makefile)
257 AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
258 AC_OUTPUT
259
260 echo "
261         GPGME v${VERSION} has been configured as follows:
262
263         GnuPG version: min. $NEED_GPG_VERSION
264         GnuPG path:    $GPG
265
266         GpgSM version: min. $NEED_GPGSM_VERSION
267         GpgSM path:    $GPGSM
268
269         GPGME CryptPlug: $GPGMEPLUG
270 "