GSS_S_PROMPTING_NEEDED is a bit
[cyrus-sasl.git] / saslauthd / configure.in
1 AC_INIT(mechanisms.h)
2 AC_PREREQ([2.54])
3
4 AC_CONFIG_AUX_DIR(config)
5 AC_CANONICAL_HOST
6
7 dnl Should we enable SASLAUTHd at all?
8 AC_ARG_WITH(saslauthd, [  --with-saslauthd=DIR    enable use of the saslauth daemon using state dir DIR ],
9                 with_saslauthd=$withval,
10                 with_saslauthd=yes)
11   if test "$with_saslauthd" = yes; then
12     with_saslauthd="/var/state/saslauthd"
13   fi
14   AC_DEFINE(HAVE_SASLAUTHD,[],[Include support for saslauthd?])
15   AC_DEFINE_UNQUOTED(PATH_SASLAUTHD_RUNDIR, "$with_saslauthd",[Location of saslauthd socket])
16 AM_CONDITIONAL(SASLAUTHD, test "$with_saslauthd" != no)
17
18 AM_INIT_AUTOMAKE(saslauthd,2.1.23)
19 CMU_INIT_AUTOMAKE
20
21 dnl Checks for programs.
22 AC_PROG_CC
23 AC_PROG_CPP
24 AC_PROG_AWK
25 AC_PROG_MAKE_SET
26 AC_PROG_LN_S
27 AC_PROG_INSTALL
28
29 dnl Checks for build foo
30 CMU_C___ATTRIBUTE__
31 CMU_GUESS_RUNPATH_SWITCH
32
33 dnl Checks for libraries.
34 CMU_SOCKETS
35
36 CMU_HAVE_OPENSSL
37 AC_MSG_CHECKING(for OpenSSL)
38 AC_MSG_RESULT($with_openssl)
39
40 SASL_DES_CHK
41
42 dnl mechanism-related checking
43 SASL_KERBEROS_V4_CHK
44 SASL_GSSAPI_CHK
45
46 if test "$gssapi" != no; then
47         if test "$gss_impl" = "heimdal"; then
48             AC_DEFINE(KRB5_HEIMDAL,[],[Using Heimdal])
49         fi
50         AC_DEFINE(HAVE_GSSAPI,[],[Include GSSAPI/Kerberos 5 Support])
51 fi
52
53 SASL2_CRYPT_CHK
54
55 AC_ARG_ENABLE(sia, [  --enable-sia            enable SIA authentication [no] ],
56   sia=$enableval,
57   sia=no)
58 LIB_SIA=""
59 if test "$sia" != no; then
60   if test -f /etc/sia/matrix.conf; then
61     AC_DEFINE(HAVE_SIA,[],[Include SIA Support])
62     LIB_SIA="-lsecurity -ldb -lm -laud"
63   else
64     AC_ERROR([No support for SIA found])
65   fi
66 fi
67 AC_SUBST(LIB_SIA)
68
69 AC_ARG_ENABLE(auth-sasldb, [  --enable-auth-sasldb    enable experimental SASLdb authentication module [no] ],
70   authsasldb=$enableval,
71   authsasldb=no)
72 if test "$authsasldb" != no; then
73   if test ! -d "../sasldb"; then
74      echo "ERROR: Cannot build sasldb module outside of the full SASL source tree."
75      exit 0;
76   fi
77   AC_DEFINE(AUTH_SASLDB,[],[Include SASLdb Support])
78   SASL_DB_PATH_CHECK()
79   SASL_DB_CHECK()
80   SASL_DB_LIB="$SASL_DB_LIB ../sasldb/.libs/libsasldb.al"
81 fi
82
83 AC_ARG_ENABLE(httpform, [  --enable-httpform       enable HTTP form authentication [[no]] ],
84   httpform=$enableval,
85   httpform=no)
86 if test "$httpform" != no; then
87   AC_DEFINE(HAVE_HTTPFORM,[],[Include HTTP form Support])
88 fi
89
90 AC_ARG_WITH(pam, [  --with-pam=DIR          use PAM (rooted in DIR) [yes] ],
91         with_pam=$withval,
92         with_pam=yes)
93 if test "$with_pam" != no; then
94   if test -d $with_pam; then
95     CPPFLAGS="$CPPFLAGS -I${with_pam}/include"
96     LDFLAGS="$LDFLAGS -L${with_pam}/lib"
97   fi
98   cmu_save_LIBS="$LIBS"
99   AC_CHECK_LIB(pam, pam_start, [
100           AC_CHECK_HEADER(security/pam_appl.h,,
101                           with_pam=no)],
102                 with_pam=no, $SASL_DL_LIB)
103   LIBS="$cmu_save_LIBS"
104 fi
105
106 AC_ARG_WITH(ipctype, [  --with-ipctype={unix,doors}    use ipctype [unix] ],
107         with_ipctype=$withval,
108         with_ipctype="unix")
109 MAIN_COMPAT_OBJ="saslauthd-${with_ipctype}.o"
110 AC_SUBST(MAIN_COMPAT_OBJ)
111 if test "$with_ipctype" = "doors"; then
112   AC_DEFINE(USE_DOORS,[],[Use the doors IPC API])
113   AC_DEFINE(SASLAUTHD_THREADED,[],[Saslauthd runs threaded?])
114   LIBS="$LIBS -ldoor -lpthread"
115 fi
116
117 AC_MSG_CHECKING(for PAM support)
118 AC_MSG_RESULT($with_pam)
119 LIB_PAM=""
120 if test "$with_pam" != no; then
121   AC_DEFINE(HAVE_PAM,[],[Support for PAM?])
122   LIB_PAM="-lpam"
123 fi
124 AC_SUBST(LIB_PAM)
125
126 AC_CHECK_LIB(resolv, inet_aton)
127
128 AC_MSG_CHECKING(to include LDAP support)
129 AC_ARG_WITH(ldap, [  --with-ldap=DIR         use LDAP (in DIR) [no] ],
130         with_ldap=$withval,
131         with_ldap=no)
132 AC_MSG_RESULT($with_ldap)
133
134 if test -d $with_ldap; then
135     CPPFLAGS="$CPPFLAGS -I${with_ldap}/include"
136     CMU_ADD_LIBPATH(${with_ldap}/lib)
137 fi
138
139 LDAP_LIBS=""
140 if test "$with_ldap" != no; then
141   AC_CHECK_LIB(ldap, ldap_initialize, [ AC_DEFINE(HAVE_LDAP,[],[Support for LDAP?])
142                                         LDAP_LIBS="-lldap -llber"
143                                         if test "$with_openssl" != "no"; then
144                                             LDAP_LIBS="$LDAP_LIBS -lcrypto $LIB_RSAREF"
145                                         fi],,-llber)
146   
147 fi
148 AC_SUBST(LDAP_LIBS)
149
150
151 dnl Checks for header files.
152 AC_HEADER_STDC
153 AC_HEADER_SYS_WAIT
154 AC_HEADER_TIME
155 AC_CHECK_HEADERS(crypt.h fcntl.h krb5.h strings.h syslog.h unistd.h sys/time.h sys/uio.h)
156
157 dnl Checks for typedefs, structures, and compiler characteristics.
158 AC_C_CONST  
159 AC_TYPE_PID_T
160
161 LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
162 AC_SUBST(LTLIBOBJS)
163
164 dnl Checks for which function macros exist
165 AC_MSG_CHECKING(whether $CC implements __func__)
166 AC_CACHE_VAL(have_func,
167 [AC_TRY_LINK([#include <stdio.h>],[printf("%s", __func__);],
168 have_func=yes,
169 have_func=no)])
170 AC_MSG_RESULT($have_func)
171 if test "$have_func" = yes; then
172        AC_DEFINE(HAVE_FUNC,[],[Does the compiler understand __func__])
173 else
174        AC_MSG_CHECKING(whether $CC implements __PRETTY_FUNCTION__)
175        AC_CACHE_VAL(have_pretty_function,
176        [AC_TRY_LINK([#include <stdio.h>],[printf("%s", __PRETTY_FUNCTION__);],
177        have_pretty_function=yes,
178        have_pretty_function=no)])
179        AC_MSG_RESULT($have_pretty_function)
180        if test "$have_pretty_function" = yes; then
181                AC_DEFINE(HAVE_PRETTY_FUNCTION,[],[Does compiler understand __PRETTY_FUNCTION__])
182        else
183                AC_MSG_CHECKING(whether $CC implements __FUNCTION__)
184                AC_CACHE_VAL(have_function,
185                [AC_TRY_LINK([#include <stdio.h>],[printf("%s", __FUNCTION__);],
186                have_function=yes,
187                have_function=no)])
188                AC_MSG_RESULT($have_function)
189                if test "$have_function" = yes; then
190                        AC_DEFINE(HAVE_FUNCTION,[],[Does compiler understand __FUNCTION__])
191                fi
192        fi
193 fi
194
195 dnl Checks for library functions.
196 AC_TYPE_SIGNAL
197 AC_CHECK_FUNCS(gethostname mkdir socket strdup)
198 AC_CHECK_FUNCS(getspnam getuserpw, break)
199 AC_CHECK_FUNCS(strlcat strlcpy)
200
201 if test $ac_cv_func_getspnam = yes; then
202         AC_MSG_CHECKING(if getpwnam_r/getspnam_r take 5 arguments)
203         AC_TRY_COMPILE(
204                 [
205 #include <sys/types.h>
206 #include <pwd.h>
207 #include <shadow.h>
208                 ],
209                 [
210 struct passwd *pw;
211 struct passwd pwbuf;
212 char pwdata[512];
213 (void) getpwnam_r("bin", &pwbuf, pwdata, sizeof(pwdata), &pw);
214                 ],
215                 [AC_MSG_RESULT(yes)
216                  AC_DEFINE(GETXXNAM_R_5ARG, 1,
217                         [Define if your getpwnam_r()/getspnam_r()
218                         functions take 5 arguments])],
219                 [AC_MSG_RESULT(no)]
220         )
221 fi
222
223 dnl Check for getaddrinfo
224 GETADDRINFOOBJS=""
225 sasl_cv_getaddrinfo=no
226 IPv6_CHECK_FUNC(getaddrinfo,
227                 [AC_DEFINE(HAVE_GETADDRINFO,[],[Do we have a getaddrinfo() function?])], [sasl_cv_getaddrinfo=yes])
228 if test $sasl_cv_getaddrinfo = yes; then
229         AC_LIBOBJ(getaddrinfo)
230 fi
231
232 dnl Check for getnameinfo
233 GETNAMEINFOOBJS=""
234 sasl_cv_getnameinfo=no
235 IPv6_CHECK_FUNC(getnameinfo,
236                 [AC_DEFINE(HAVE_GETNAMEINFO,[],[Do we have a getnameinfo() function?])], [sasl_cv_getnameinfo=yes])
237 if test $sasl_cv_getnameinfo = yes; then
238         AC_LIBOBJ(getnameinfo)
239 fi
240
241 IPv6_CHECK_SS_FAMILY()
242 IPv6_CHECK_SA_LEN()
243 IPv6_CHECK_SOCKLEN_T()
244
245 AC_EGREP_HEADER(sockaddr_storage, sys/socket.h,
246                 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE,[],[Do we have a sockaddr_storage struct?]))
247
248 AH_TOP([
249 #ifndef _SASLAUTHD_H
250 #define _SASLAUTHD_H
251
252 #include <stdio.h>
253 ])
254
255 AH_BOTTOM([
256
257 #ifndef HAVE___ATTRIBUTE__
258 /* Can't use attributes... */
259 #define __attribute__(foo)
260 #endif
261
262 #include <stdlib.h>
263 #include <sys/types.h>
264 #include <sys/socket.h>
265 #ifndef WIN32
266 # include <netdb.h>   
267 # include <sys/param.h>
268 #else /* WIN32 */
269 # include <winsock2.h>
270 #endif /* WIN32 */ 
271 #include <string.h>
272
273 #include <netinet/in.h>
274
275 #ifndef HAVE_SOCKLEN_T
276 typedef unsigned int socklen_t;
277 #endif /* HAVE_SOCKLEN_T */
278
279 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
280 #define _SS_MAXSIZE     128     /* Implementation specific max size */
281 #define _SS_PADSIZE     (_SS_MAXSIZE - sizeof (struct sockaddr))
282
283 struct sockaddr_storage {
284         struct  sockaddr ss_sa;
285         char            __ss_pad2[_SS_PADSIZE];
286 };
287 # define ss_family ss_sa.sa_family
288 #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
289
290 #ifndef AF_INET6
291 /* Define it to something that should never appear */
292 #define AF_INET6        AF_MAX
293 #endif
294
295 /* Create a struct iovec if we need one */
296 #if !defined(HAVE_SYS_UIO_H)
297 struct iovec {
298     long iov_len;
299     char *iov_base;
300 };
301 #else
302 #include <sys/types.h>
303 #include <sys/uio.h>
304 #endif
305
306 #ifndef HAVE_GETADDRINFO
307 #define getaddrinfo     sasl_getaddrinfo
308 #define freeaddrinfo    sasl_freeaddrinfo
309 #define getnameinfo     sasl_getnameinfo
310 #define gai_strerror    sasl_gai_strerror
311 #include "gai.h"
312 #endif
313
314 #ifndef AI_NUMERICHOST   /* support glibc 2.0.x */
315 #define AI_NUMERICHOST  4
316 #define NI_NUMERICHOST  2
317 #define NI_NAMEREQD     4
318 #define NI_NUMERICSERV  8
319 #endif
320
321 /* handy string manipulation functions */
322 #ifndef HAVE_STRLCPY
323 extern size_t saslauthd_strlcpy(char *dst, const char *src, size_t len);
324 #define strlcpy(x,y,z) saslauthd_strlcpy((x),(y),(z))
325 #endif
326 #ifndef HAVE_STRLCAT
327 extern size_t saslauthd_strlcat(char *dst, const char *src, size_t len);
328 #define strlcat(x,y,z) saslauthd_strlcat((x),(y),(z))
329 #endif
330
331 #endif
332 ])
333
334 AC_CONFIG_HEADERS(saslauthd.h)
335
336 AC_OUTPUT(Makefile)