Merged branch dev-0.4
[poldi.git] / configure.ac
1 # configure.ac - Configure script for Poldi
2 # Copyright (C) 2004, 2005, 2007, 2008 g10 Code GmbH
3
4 # This file is part of Poldi.
5 #
6 # Poldi is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # Poldi is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14 # License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, USA
20
21 # Process this file with autoconf to produce a configure script.
22 AC_PREREQ(2.52)
23 min_automake_version="1.7.9"
24
25 # Version number: Remember to change it immediately *after* a release.
26 #                 Add a "-cvs" prefix for non-released code.
27 AC_INIT(poldi, 0.4, gnupg-devel@gnupg.org)
28
29 PACKAGE=$PACKAGE_NAME
30 VERSION=$PACKAGE_VERSION
31
32 NEED_LIBGCRYPT_VERSION=0
33 NEED_GPG_ERROR_VERSION=0.7
34
35 NEED_KSBA_API=1
36 NEED_KSBA_VERSION=1.0.2
37
38         
39 AC_CONFIG_SRCDIR(src/pam/pam_poldi.c)
40 AM_CONFIG_HEADER(config.h)
41 AC_CANONICAL_TARGET
42 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
43
44 POLDI_CONF_DIRECTORY="${sysconfdir}/poldi"
45 AC_SUBST(POLDI_CONF_DIRECTORY)
46
47 # Implementation of the --with-pam-module-directory switch.
48 DEFAULT_PAM_MODULE_DIRECTORY="${libdir}/security"
49 AC_ARG_WITH(pam-module-directory,
50             [  --with-pam-module-directory=NAME
51                           Use NAME as installation directory for PAM modules ],
52             PAM_MODULE_DIRECTORY="$withval",
53             PAM_MODULE_DIRECTORY="$DEFAULT_PAM_MODULE_DIRECTORY")
54 AC_SUBST(PAM_MODULE_DIRECTORY)
55
56 AC_GNU_SOURCE
57
58 have_gpg_error=no
59 have_libgcrypt=no 
60 have_ksba=no
61
62 POLDI_ENABLE_FEATURE(enable_auth_x509, yes, x509-auth, support for X509 authentication)
63 POLDI_ENABLE_FEATURE(enable_auth_localdb, yes, localdb-auth, support for local-db authentication)
64 AC_SUBST(PACKAGE)
65 AC_SUBST(VERSION)
66 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
67 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
68 AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
69                                         [Bug report address])
70 AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION",
71                                        [Required version of Libgcrypt])
72 AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION",
73                                        [Required version of Libksba])
74
75
76 AH_BOTTOM([
77 /* Setup the hardwired names of modules. */
78 #ifndef GNUPG_DEFAULT_SCD
79 #define GNUPG_DEFAULT_SCD    ( GNUPG_BINDIR "/scdaemon" )
80 #endif
81 #ifndef GNUPG_DEFAULT_DIRMNGR
82 #define GNUPG_DEFAULT_DIRMNGR    ( GNUPG_BINDIR "/dirmngr" )
83 #endif
84 ])
85
86 AM_MAINTAINER_MODE
87
88 # Checks for programs.
89 AC_PROG_MAKE_SET
90 AM_SANITY_CHECK
91 missing_dir=`cd $ac_aux_dir && pwd`
92 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
93 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
94 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
95 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
96 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
97 AC_PROG_AWK
98 AC_PROG_CC
99 AM_PROG_CC_C_O
100 AC_PROG_CPP
101 AC_PROG_RANLIB
102 AC_PROG_INSTALL
103 AC_PROG_MAKE_SET
104 AC_SYS_LARGEFILE
105
106 #
107 # Checks for libraries.
108 #
109
110 AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_VERSION",
111                   have_libgcrypt=yes,have_libgcrypt=no)
112 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
113                   have_gpg_error=yes,have_gpg_error=no)
114 AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no)
115
116 AC_CHECK_FUNCS(memicmp stpcpy strlwr strtoul memmove stricmp)
117 AC_CHECK_FUNCS(fopencookie funopen nanosleep)
118
119 # Checks for header files.
120 AC_HEADER_STDC
121
122 # Checks for typedefs, structures, and compiler characteristics.
123 AC_C_CONST
124 AC_C_INLINE
125 AC_TYPE_SIZE_T
126
127 # Necessary for libscd.
128 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
129 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
130 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
131 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
132 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
133
134 AC_CHECK_SIZEOF(unsigned short)
135 AC_CHECK_SIZEOF(unsigned int)
136 AC_CHECK_SIZEOF(unsigned long)
137
138  
139 # Checks for library functions.
140
141 #
142 # See whether we have dlopen available, so that PC/SC can be loaded on
143 # demand.
144 #
145 _dl_save_libs=$LIBS
146 LIBS=""
147 AC_SEARCH_LIBS(dlopen,dl,found_dlopen=yes)
148 if test x"$found_dlopen" = "xyes" ; then
149    AC_DEFINE(HAVE_DL_DLOPEN,1,
150              [Defined when the dlopen function family is available])
151    DLLIBS=$LIBS
152 else
153    DLLIBS=""
154    LIBS=$_dl_save_libs
155 fi
156 AC_SUBST(DLLIBS)
157
158 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
159
160 if test "$GCC" = yes; then
161     if test "$USE_MAINTAINER_MODE" = "yes"; then
162         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
163         CFLAGS="$CFLAGS -Wformat-nonliteral"
164     else
165         CFLAGS="$CFLAGS -Wall"
166     fi
167 fi
168
169 # We use jnlib, so tell other modules about it
170 #AC_DEFINE(HAVE_JNLIB_LOGGING, 1,
171 #         [Defined if jnlib style logging fucntions are available])
172 # Disabled, since we don't use jnlib anymore.
173
174 #
175 # Taken from libassuan source package
176 #
177
178 #AC_DEFINE(HAVE_DOSISH_SYSTEM,0,[We do not run here])
179 #AC_UNDEFINE(HAVE_W32_SYSTEM),0, [We do not run here])
180 AC_CHECK_HEADERS([string.h locale.h sys/uio.h])
181 AC_TYPE_SIGNAL
182 #AC_DEFINE(USE_DESCRIPTOR_PASSING, 0, [We do not need this feature])
183 AC_REPLACE_FUNCS(setenv)
184 # Check for funopen
185 AC_CHECK_FUNCS(funopen)
186 if test $ac_cv_func_funopen != yes; then
187     # No funopen but we can implement that in terms of fopencookie.
188     AC_CHECK_FUNCS(fopencookie)
189     if test $ac_cv_func_fopencookie = yes; then
190         AC_LIBOBJ([funopen])
191     else
192         AC_MSG_WARN([
193 ***
194 *** No implementation of fopencookie or funopen available.
195 *** The assuan_get_data_fp feature won't work.
196 ***])
197     fi
198 fi
199
200 # NLS:
201 AM_GNU_GETTEXT([external])
202
203 #
204 # Decide what to build
205 #
206
207 if test $have_ksba = no; then
208   enable_auth_x509=no
209 fi
210 AM_CONDITIONAL(AUTH_METHOD_X509, test "$enable_auth_x509" = "yes")
211 AM_CONDITIONAL(AUTH_METHOD_LOCALDB, test "$enable_auth_localdb" = "yes")
212
213 if test "$enable_auth_x509" = "yes"; then
214    AC_DEFINE(ENABLE_AUTH_METHOD_X509, 1, [Enable X509 authentication method])
215 fi
216 if test "$enable_auth_localdb" = "yes"; then
217    AC_DEFINE(ENABLE_AUTH_METHOD_LOCALDB, 1, [Enable local-db authentication method])
218 fi
219
220 #
221 # Print errors here so that they are visible all
222 # together and the user can acquire them all together.
223 #
224 die=no
225 if test "$have_gpg_error" = "no"; then
226    die=yes
227    AC_MSG_NOTICE([[
228 ***  
229 *** You need libgpg-error to build this program.
230 *** This library is for example available at
231 ***   ftp://ftp.gnupg.org/gcrypt/alpha/libgpg-error
232 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
233 ***]])
234 fi
235 if test "$have_libgcrypt" = "no"; then
236    die=yes
237    AC_MSG_NOTICE([[
238 ***  
239 *** You need libgcrypt to build this program.
240 *** This library is for example available at
241 ***   ftp://ftp.gnupg.org/gcrypt/libgcrypt
242 *** (at least version $NEED_LIBGCRYPT_VERSION is required.)
243 ***]])
244 fi
245 if test "$have_ksba" = "no"; then
246    AC_MSG_NOTICE([[
247 ***
248 *** libksba not found, building with X.509 authentication support.
249 *** libksba can be retrieved from:
250 ***   URL FIXME
251 *** (at least version $NEED_KSBA_VERSION (API $NEED_KSBA_API) is required).
252 ***]])
253 fi
254 if test "$die" = "yes"; then
255     AC_MSG_ERROR([[
256 ***
257 *** Required libraries not found. Please consult the above messages
258 *** and install them before running configure again.
259 ***]])
260 fi
261
262 AC_CONFIG_FILES([Makefile
263                  po/Makefile.in
264                  m4/Makefile
265                  am/Makefile
266                  src/Makefile
267                  src/assuan/Makefile
268                  src/util/Makefile
269                  src/scd/Makefile
270                  src/ctrl/Makefile
271                  src/pam/Makefile
272                  src/pam/auth-support/Makefile
273                  src/pam/auth-method-localdb/Makefile
274                  src/pam/auth-method-x509/Makefile
275                  doc/Makefile
276                  tests/Makefile
277                  tools/Makefile
278                  conf/Makefile])
279 AC_OUTPUT
280
281 if test "$PAM_MODULE_DIRECTORY" = "$DEFAULT_PAM_MODULE_DIRECTORY"; then
282    AC_MSG_WARN([
283 **
284 ** Warning: using default value ($DEFAULT_PAM_MODULE_DIRECTORY) as
285 **          installation directory for PAM module; this is probably not
286 **          what you want.
287 **])
288 else
289   AC_MSG_NOTICE([PAM module installation directory: $PAM_MODULE_DIRECTORY])
290 fi
291
292 echo "
293         Poldi v${VERSION} has been configured as follows:
294
295         installation directory for PAM module: $PAM_MODULE_DIRECTORY
296         
297              X509 authentication: $enable_auth_x509
298          local-db authentication: $enable_auth_localdb
299
300 "