2008-08-17 Moritz <moritz@gnu.org>
[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.5-cvs, 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(stpcpy strtoul)
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 AC_CHECK_SIZEOF(unsigned short)
128 AC_CHECK_SIZEOF(unsigned int)
129 AC_CHECK_SIZEOF(unsigned long)
130
131 # Checks for library functions.
132
133 # FIXME: what is this for?? -moritz
134 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
135
136 if test "$GCC" = yes; then
137     if test "$USE_MAINTAINER_MODE" = "yes"; then
138         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
139         CFLAGS="$CFLAGS -Wformat-nonliteral"
140     else
141         CFLAGS="$CFLAGS -Wall"
142     fi
143 fi
144
145 #
146 # Taken from libassuan source package
147 #
148
149 AC_CHECK_HEADERS([string.h locale.h sys/uio.h])
150 AC_TYPE_SIGNAL
151 #AC_DEFINE(USE_DESCRIPTOR_PASSING, 0, [We do not need this feature])
152 AC_REPLACE_FUNCS(setenv)
153 # Check for funopen
154 AC_CHECK_FUNCS(funopen)
155 if test $ac_cv_func_funopen != yes; then
156     # No funopen but we can implement that in terms of fopencookie.
157     AC_CHECK_FUNCS(fopencookie)
158     if test $ac_cv_func_fopencookie = yes; then
159         AC_LIBOBJ([funopen])
160     else
161         AC_MSG_WARN([
162 ***
163 *** No implementation of fopencookie or funopen available.
164 *** The assuan_get_data_fp feature won't work.
165 ***])
166     fi
167 fi
168
169 # Native language support:
170 AM_GNU_GETTEXT([external])
171
172 #
173 # Decide what to build
174 #
175
176 if test $have_ksba = no; then
177   enable_auth_x509=no
178 fi
179 AM_CONDITIONAL(AUTH_METHOD_X509, test "$enable_auth_x509" = "yes")
180 AM_CONDITIONAL(AUTH_METHOD_LOCALDB, test "$enable_auth_localdb" = "yes")
181
182 if test "$enable_auth_x509" = "yes"; then
183    AC_DEFINE(ENABLE_AUTH_METHOD_X509, 1, [Enable X509 authentication method])
184 fi
185 if test "$enable_auth_localdb" = "yes"; then
186    AC_DEFINE(ENABLE_AUTH_METHOD_LOCALDB, 1, [Enable local-db authentication method])
187 fi
188
189 #
190 # Print errors here so that they are visible all
191 # together and the user can acquire them all together.
192 #
193 die=no
194 if test "$have_gpg_error" = "no"; then
195    die=yes
196    AC_MSG_NOTICE([[
197 ***  
198 *** You need libgpg-error to build this program.
199 *** This library is for example available at
200 ***   ftp://ftp.gnupg.org/gcrypt/alpha/libgpg-error
201 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
202 ***]])
203 fi
204 if test "$have_libgcrypt" = "no"; then
205    die=yes
206    AC_MSG_NOTICE([[
207 ***  
208 *** You need libgcrypt to build this program.
209 *** This library is for example available at
210 ***   ftp://ftp.gnupg.org/gcrypt/libgcrypt
211 *** (at least version $NEED_LIBGCRYPT_VERSION is required.)
212 ***]])
213 fi
214 if test "$have_ksba" = "no"; then
215    AC_MSG_NOTICE([[
216 ***
217 *** libksba not found, building with X.509 authentication support.
218 *** libksba can be retrieved from:
219 ***   URL FIXME
220 *** (at least version $NEED_KSBA_VERSION (API $NEED_KSBA_API) is required).
221 ***]])
222 fi
223 if test "$die" = "yes"; then
224     AC_MSG_ERROR([[
225 ***
226 *** Required libraries not found. Please consult the above messages
227 *** and install them before running configure again.
228 ***]])
229 fi
230
231 AC_CONFIG_FILES([Makefile
232                  po/Makefile.in
233                  m4/Makefile
234                  am/Makefile
235                  src/Makefile
236                  src/assuan/Makefile
237                  src/util/Makefile
238                  src/scd/Makefile
239                  src/ctrl/Makefile
240                  src/pam/Makefile
241                  src/pam/auth-support/Makefile
242                  src/pam/auth-method-localdb/Makefile
243                  src/pam/auth-method-x509/Makefile
244                  doc/Makefile
245                  tests/Makefile
246                  tools/Makefile
247                  conf/Makefile])
248 AC_OUTPUT
249
250 if test "$PAM_MODULE_DIRECTORY" = "$DEFAULT_PAM_MODULE_DIRECTORY"; then
251    AC_MSG_WARN([
252 **
253 ** Warning: using default value ($DEFAULT_PAM_MODULE_DIRECTORY) as
254 **          installation directory for PAM module; this is probably not
255 **          what you want. Either use the configure flag
256 **
257 **                      --with-pam-module-directory=DIRECTORY
258 **
259 **          or copy the newly built pam_poldi.so into the correct directory
260 **          manually. Usually PAM modules are located in /lib/security.
261 **])
262 else
263   AC_MSG_NOTICE([PAM module installation directory: $PAM_MODULE_DIRECTORY])
264 fi
265
266 echo "
267         Poldi v${VERSION} has been configured as follows:
268
269         installation directory for PAM module: $PAM_MODULE_DIRECTORY
270         configuration directory:               $POLDI_CONF_DIRECTORY
271         
272              X509 authentication: $enable_auth_x509
273          local-db authentication: $enable_auth_localdb
274
275 "