import cyrus-sasl-2.1.23
[cyrus-sasl.git] / configure.in
1 dnl configure.in for the SASL library
2 dnl Rob Siemborski
3 dnl Rob Earhart
4 dnl $Id: configure.in,v 1.213.2.1 2009/04/27 17:58:25 murch Exp $
5 dnl
6 dnl Copyright (c) 2001 Carnegie Mellon University.  All rights reserved.
7 dnl
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted provided that the following conditions
10 dnl are met:
11 dnl
12 dnl 1. Redistributions of source code must retain the above copyright
13 dnl    notice, this list of conditions and the following disclaimer. 
14 dnl
15 dnl 2. Redistributions in binary form must reproduce the above copyright
16 dnl    notice, this list of conditions and the following disclaimer in
17 dnl    the documentation and/or other materials provided with the
18 dnl    distribution.
19 dnl
20 dnl 3. The name "Carnegie Mellon University" must not be used to
21 dnl    endorse or promote products derived from this software without
22 dnl    prior written permission. For permission or any other legal
23 dnl    details, please contact  
24 dnl      Office of Technology Transfer
25 dnl      Carnegie Mellon University
26 dnl      5000 Forbes Avenue
27 dnl      Pittsburgh, PA  15213-3890
28 dnl      (412) 268-4387, fax: (412) 268-7395
29 dnl      tech-transfer@andrew.cmu.edu
30 dnl
31 dnl 4. Redistributions of any form whatsoever must retain the following
32 dnl    acknowledgment:
33 dnl    \"This product includes software developed by Computing Services
34 dnl     at Carnegie Mellon University (http://www.cmu.edu/computing/).\"
35 dnl
36 dnl CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
37 dnl THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38 dnl AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
39 dnl FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
40 dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
41 dnl AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
42 dnl OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
43 dnl
44 AC_INIT(lib/saslint.h)
45 AC_PREREQ([2.54])
46
47 dnl use ./config.cache as the default cache file.
48 dnl we require a cache file to successfully configure our build.
49 if test $cache_file = "/dev/null"; then
50 cache_file="./config.cache"
51 AC_CACHE_LOAD
52 fi
53
54 AC_CONFIG_AUX_DIR(config)
55 AC_CANONICAL_HOST
56 AC_CANONICAL_TARGET
57
58 dnl
59 dnl REMINDER: When changing the version number here, please also update
60 dnl the values in win32/include/config.h and include/sasl.h as well.
61 dnl
62 AM_INIT_AUTOMAKE(cyrus-sasl, 2.1.23)
63 CMU_INIT_AUTOMAKE
64
65 # and include our config dir scripts
66 ACLOCAL="$ACLOCAL -I \$(top_srcdir)/config"
67
68 DIRS=""
69
70 AC_ARG_ENABLE(cmulocal,
71               [AC_HELP_STRING([--enable-cmulocal],
72                               [enable local mods for CMU [[no]]])],
73               [],
74               enable_cmulocal=no)
75
76 AC_ARG_ENABLE(sample,
77               [AC_HELP_STRING([--enable-sample],
78                               [compile sample code [[yes]]])],
79               enable_sample=yes)
80
81 AC_PROG_CC
82 AC_PROG_CPP
83 AC_PROG_AWK
84 AC_PROG_LN_S
85 AC_PROG_MAKE_SET
86 AC_PROG_INSTALL
87 CMU_C___ATTRIBUTE__
88
89 dnl check for -R, etc. switch
90 CMU_GUESS_RUNPATH_SWITCH
91
92 dnl xxx compatibility
93 AC_ARG_WITH(staticsasl)
94 if test "$with_staticsasl" = yes; then
95         enable_shared=yes
96         enable_static=yes
97 fi
98
99 save_target=$target
100 if test -z "$target"; then
101         target="NONE"
102 fi
103
104 # new libtool
105 AM_DISABLE_STATIC
106 AC_PROG_LIBTOOL
107
108 target=$save_target
109
110 if test "$enable_static" = yes; then
111         SASL_STATIC_LIBS=libsasl2.a
112 else
113         SASL_STATIC_LIBS=
114 fi
115
116 AC_ARG_ENABLE(staticdlopen, [  --enable-staticdlopen   try dynamic plugins when we are a static libsasl [[no]] ],
117                 enable_staticdlopen=$enableval,
118                 enable_staticdlopen=no)
119
120 if test "$enable_staticdlopen" = yes; then
121   AC_DEFINE(TRY_DLOPEN_WHEN_STATIC,[],[Should we try to dlopen() plugins while staticly compiled?])
122 fi
123
124 if test "$ac_cv_prog_gcc" = yes; then
125   CFLAGS="-Wall -W ${CFLAGS}"
126 fi
127
128 AC_ARG_WITH(purecov,[  --with-purecov          link with purecov])
129 if test "$with_purecov" = yes; then
130   AC_CHECK_PROGS(PURECOV, purecov)
131 fi
132 AC_ARG_WITH(purify,[  --with-purify           link with purify])
133 if test "$with_purify" = yes; then
134   AC_CHECK_PROGS(PURIFY, purify)
135 fi
136
137 AC_ARG_ENABLE(java, [  --enable-java           compile Java support [[no]]],
138         enable_java=$enableval, enable_java=no)
139 if test "$enable_java" = yes; then
140   AC_PATH_PROG(JAVAC, javac, no)
141   AC_PATH_PROGS(JAVAH, javah kaffeh, no)
142   AC_CHECK_PROGS(JAVADOC, javadoc, :)   
143   if test "$JAVAC" = "no" -o "$JAVAH" = "no"; then
144     AC_WARN([Disabling Java support])
145     enable_java=no
146   fi
147 else
148 # Make distcheck work
149   JAVAC="true"
150   JAVAH="true"
151   JAVADOC="true"
152 fi
153 AM_CONDITIONAL(JAVA, test "$enable_java" = yes)
154
155 if test "$enable_java" = yes; then
156   AC_MSG_CHECKING([JNI cpp flags])
157   AC_CACHE_VAL(sasl_cv_java_includes,[
158   if test `echo $JAVAH | sed 's,.*/,,'` = "kaffeh"; then
159     sasl_cv_java_includes=-I`echo $JAVAH | sed -e 's,/bin.*,/include/kaffe,'`
160   else
161     java_base=`echo $JAVAC | sed 's,/bin.*,'','`
162
163     AC_ARG_WITH(javabase, [  --with-javabase=PATH    set path to find jni.h in [/usr/java/include] ],
164         java_base=$withval,)
165         
166
167     sasl_cv_java_includes=''
168     for dir in `find ${java_base}/include -follow -type d -print | grep -v green_threads`; do
169       sasl_cv_java_includes="${sasl_cv_java_includes} -I$dir"
170     done
171   fi
172
173   sasl_cv_java_includes="${sasl_cv_java_includes} -I$javapath/include"])
174
175   JAVA_INCLUDES=$sasl_cv_java_includes
176   AC_SUBST(JAVA_INCLUDES)
177   AC_MSG_RESULT(ok)
178
179   JAVAROOT=".."
180   AC_SUBST(JAVAROOT)
181   JAVAC=`echo "$JAVAC" | sed 's,.*/,,'`
182   JAVAH=`echo "$JAVAH" | sed 's,.*/,,'`
183 fi
184
185 AM_CONDITIONAL(SAMPLE, test "$enable_sample" = yes)
186
187 dnl call before we do the berkeley DB checks
188 CMU_SOCKETS
189
190 dnl we extracted this to config/sasldb.m4
191 SASL_DB_PATH_CHECK()
192 SASL_DB_CHECK()
193
194 # Do we not install the SASL DB man pages?
195 AM_CONDITIONAL(NO_SASL_DB_MANS, test "x$SASL_DB_MANS" = "x")
196
197 AC_ARG_ENABLE(keep_db_open, [  --enable-keep-db-open   keep handle to Berkeley DB open for improved performance [[no]] ],
198                 keep_db_open=$enableval,
199                 keep_db_open=no)
200
201 # Disable if Berkeley DB is not used
202 if test "$dblib" != berkeley; then
203   keep_db_open=no
204 fi
205
206 if test "$keep_db_open" = yes; then
207   AC_DEFINE(KEEP_DB_OPEN,[],[Should we keep handle to Berkeley DB open in SASLDB plugin?])
208 fi
209 AC_MSG_CHECKING(if Berkeley DB handle is kept open in SASLDB)
210 AC_MSG_RESULT($keep_db_open)
211
212 AC_CHECK_LIB(dl, dlopen, SASL_DL_LIB="-ldl", SASL_DL_LIB="")
213 AC_SUBST(SASL_DL_LIB)
214
215 dnl /dev/random ?
216
217 AC_ARG_WITH(devrandom, [  --with-devrandom=PATH   set the path to /dev/random [[/dev/random]] ],
218   devrandom=$withval,
219   devrandom=/dev/random)
220 AC_MSG_CHECKING(/dev/random to use)
221 AC_MSG_RESULT($devrandom)
222 AC_DEFINE_UNQUOTED(SASL_DEV_RANDOM, "$devrandom", [File to use for source of randomness])
223
224 dnl Do we need leading underscores on our symbols?
225
226 AC_CHECK_PROGS(NM, nm)
227
228 AC_MSG_CHECKING(for underscore before symbols)
229 AC_CACHE_VAL(sasl_cv_uscore,[
230     echo "main(){int i=1;}
231     foo(){int i=6;}" > conftest.c
232     ${CC} -o a.out conftest.c > /dev/null
233     if (${NM} a.out | grep _foo) > /dev/null; then
234       sasl_cv_uscore=yes
235     else
236       sasl_cv_uscore=no
237     fi])
238 AC_MSG_RESULT($sasl_cv_uscore)
239 rm -f conftest.c a.out
240
241 if test $sasl_cv_uscore = yes; then
242   if test $ac_cv_lib_dl_dlopen = yes ; then
243         AC_MSG_CHECKING(whether dlsym adds the underscore for us)
244         cmu_save_LIBS="$LIBS"
245         LIBS="$LIBS $SASL_DL_LIB"
246         AC_CACHE_VAL(sasl_cv_dlsym_adds_uscore,AC_TRY_RUN( [
247 #include <dlfcn.h>
248 #include <stdio.h>
249 foo() { int i=0;}
250 main() { void *self, *ptr1, *ptr2; self=dlopen(NULL,RTLD_LAZY);
251     if(self) { ptr1=dlsym(self,"foo"); ptr2=dlsym(self,"_foo");
252     if(ptr1 && !ptr2) exit(0); } exit(1); } 
253 ], [sasl_cv_dlsym_adds_uscore=yes], sasl_cv_dlsym_adds_uscore=no
254         AC_DEFINE(DLSYM_NEEDS_UNDERSCORE, [], [Do we need a leading _ for dlsym?]),
255         AC_MSG_WARN(cross-compiler, we'll do our best)))
256         LIBS="$cmu_save_LIBS"
257       AC_MSG_RESULT($sasl_cv_dlsym_adds_uscore)
258   fi
259 fi
260
261 dnl See if we can provide a default logging function...
262 AC_CHECK_FUNCS(syslog)
263
264 AC_ARG_WITH(pam, [  --with-pam=DIR          use PAM (rooted in DIR) [[yes]] ],
265         with_pam=$withval,
266         with_pam=yes)
267 if test "$with_pam" != no; then
268   if test -d $with_pam; then
269     CPPFLAGS="$CPPFLAGS -I${with_pam}/include"
270     LDFLAGS="$LDFLAGS -L${with_pam}/lib"
271   fi
272   AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
273   cmu_save_LIBS="$LIBS"
274   AC_CHECK_FUNC(pam_start, :, 
275         LIBS="-lpam $LIBS" 
276         AC_TRY_LINK([[
277 #include <sys/types.h>
278 #ifdef HAVE_PAM_PAM_APPL_H
279 #include <pam/pam_appl.h>
280 #endif
281 #ifdef HAVE_SECURITY_PAM_H
282 #include <security/pam_appl.h>
283 #endif]],[[
284 const char *service="foo";
285 const char *user="bar";
286 pam_handle_t *pamh;
287 struct pam_conv *conv;
288 int baz;
289 baz = pam_start(service, user, conv, &pamh);
290 return 0;
291 ]], LIBPAM="-lpam")
292 )
293   LIBS="$cmu_save_LIBS $LIBPAM"
294 fi
295
296 AC_ARG_WITH(saslauthd, [  --with-saslauthd=DIR    enable use of the saslauth daemon using state dir DIR ],
297                 with_saslauthd=$withval,
298                 with_saslauthd=yes)
299 if test "$with_saslauthd" != no; then
300   if test "$with_saslauthd" = yes; then
301     with_saslauthd="/var/state/saslauthd"
302   fi
303   AC_DEFINE(HAVE_SASLAUTHD,[],[Include support for saslauthd?])
304   AC_DEFINE_UNQUOTED(PATH_SASLAUTHD_RUNDIR, "$with_saslauthd",
305                      [Where do we look for saslauthd's socket?])
306 fi
307 AM_CONDITIONAL(SASLAUTHD, test "$with_saslauthd" != no)
308 AC_MSG_CHECKING(if I should include saslauthd)
309 AC_MSG_RESULT($with_saslauthd)
310
311 AC_ARG_WITH(authdaemond, [  --with-authdaemond=PATH enable use of authdaemon with default socket=PATH [[yes]] ],
312                 with_authdaemon=$withval,
313                 with_authdaemon=yes)
314 if test "$with_authdaemon" != no; then
315   if test "$with_authdaemon" = yes; then
316     with_authdaemon="/dev/null"
317   fi
318   AC_DEFINE(HAVE_AUTHDAEMON,[],[Include support for Courier's authdaemond?])
319   AC_DEFINE_UNQUOTED(PATH_AUTHDAEMON_SOCKET, "$with_authdaemon",
320                      [Where do we look for Courier authdaemond's socket?])
321 fi
322 AC_MSG_CHECKING(to include Courier authdaemond support)
323 AC_MSG_RESULT($with_authdaemon)
324
325 AC_ARG_WITH(pwcheck,
326 [  --with-pwcheck=DIR     enable deprecated pwcheck daemon using statedir DIR ],
327         with_pwcheck=$withval,
328         with_pwcheck=no)
329 if test "$with_pwcheck" != no; then
330    if test "$with_pwcheck" = yes; then
331      with_pwcheck=/var/pwcheck
332    fi
333    AC_DEFINE(HAVE_PWCHECK,[],[Include Support for pwcheck daemon?])
334    AC_DEFINE_UNQUOTED(PWCHECKDIR, "$with_pwcheck", [Location of pwcheck socket])
335    AC_CHECK_FUNC(getspnam,PWCHECKMETH="getspnam",PWCHECKMETH="getpwnam")
336    AC_SUBST(PWCHECKMETH)
337 fi
338 AM_CONDITIONAL(PWCHECK, test "$with_pwcheck" != no)
339 AC_MSG_CHECKING(if I should include pwcheck)
340 AC_MSG_RESULT($with_pwcheck)
341
342 AC_ARG_WITH(ipctype, [  --with-ipctype={unix,doors}    use ipctype [[unix]] ],
343        with_ipctype=$withval,
344        with_ipctype="unix")
345 IPCTYPE=$with_ipctype
346 AC_SUBST(IPCTYPE)
347 LIB_DOOR=
348 if test "$with_ipctype" = "doors"; then
349    LIB_DOOR="-ldoor"
350    AC_DEFINE(USE_DOORS,[],[use the doors IPC API for saslauthd?])
351 fi
352 AC_SUBST(LIB_DOOR)
353
354 AC_ARG_ENABLE(alwaystrue, [  --enable-alwaystrue     enable the alwaystrue password verifier (discouraged)],
355                 enable_alwaystrue=$enableval,
356                 enable_alwaystrue=no)
357 if test "$enable_alwaystrue" = yes; then
358   AC_DEFINE(HAVE_ALWAYSTRUE, [], [Enable 'alwaystrue' password verifier?])
359 fi
360 AC_MSG_CHECKING(if I should include the alwaystrue verifier)
361 AC_MSG_RESULT($enable_alwaystrue)
362
363 dnl sasl_checkapop support
364 AC_ARG_ENABLE(checkapop, [  --enable-checkapop      enable use of sasl_checkapop [[yes]] ],
365   checkapop=$enableval,
366   checkapop=yes)
367
368 AC_MSG_CHECKING(if we should enable sasl_checkapop)
369 if test "$checkapop" != no; then
370   AC_MSG_RESULT(enabled)
371   AC_DEFINE(DO_SASL_CHECKAPOP, [], [should we support sasl_checkapop?])
372 else
373   AC_MSG_RESULT(disabled)
374 fi
375
376 dnl CRAM-MD5
377 AC_ARG_ENABLE(cram, [  --enable-cram           enable CRAM-MD5 authentication [[yes]] ],
378   cram=$enableval,
379   cram=yes)
380
381 AC_MSG_CHECKING(CRAM-MD5)
382 if test "$cram" != no; then
383   AC_MSG_RESULT(enabled)
384   SASL_MECHS="$SASL_MECHS libcrammd5.la"
385   if test "$enable_static" = yes; then
386     SASL_STATIC_OBJS="$SASL_STATIC_OBJS cram.o"
387     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/cram.c"
388     AC_DEFINE(STATIC_CRAMMD5, [], [Link CRAM-MD5 Staticly])
389   fi
390 else
391   AC_MSG_RESULT(disabled)
392 fi
393
394 CMU_HAVE_OPENSSL
395 AC_MSG_CHECKING(for OpenSSL)
396 AC_MSG_RESULT($with_openssl)
397
398 SASL_DES_CHK
399
400 dnl DIGEST-MD5
401 AC_ARG_ENABLE(digest, [  --enable-digest         enable DIGEST-MD5 authentication [[yes]] ],
402   digest=$enableval,
403   digest=yes)
404
405 if test "$digest" != no; then
406   dnl In order to compile digest, we should look for need libdes.
407   if test -d $digest; then
408     CPPFLAGS="$CPPFLAGS -I$digest/include"
409     LDFLAGS="$LDFLAGS -L$digest/lib"
410   fi
411   if test "$with_des" = no; then
412     AC_WARN(No DES support for DIGEST-MD5)
413   fi
414 fi
415
416 AC_MSG_CHECKING(DIGEST-MD5)
417 if test "$digest" != no; then
418   AC_MSG_RESULT(enabled)
419   SASL_MECHS="$SASL_MECHS libdigestmd5.la"
420   if test "$enable_static" = yes; then
421     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/digestmd5.c"
422     SASL_STATIC_OBJS="$SASL_STATIC_OBJS digestmd5.o"
423     AC_DEFINE(STATIC_DIGESTMD5, [], [Link DIGEST-MD5 Staticly])
424   fi
425 else
426   AC_MSG_RESULT(disabled)
427 fi
428
429 dnl OTP
430 AC_ARG_ENABLE(otp, [  --enable-otp            enable OTP authentication [[yes]] ],
431   otp=$enableval,
432   otp=yes)
433
434 if test "$with_openssl" = no; then
435   AC_WARN([OpenSSL not found -- OTP will be disabled])
436   otp=no
437 fi
438
439 AC_MSG_CHECKING(OTP)
440 if test "$otp" != no; then
441   AC_MSG_RESULT(enabled)
442   OTP_LIBS="-lcrypto $LIB_RSAREF"
443
444   SASL_MECHS="$SASL_MECHS libotp.la"
445   if test "$enable_static" = yes; then
446     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/otp.c"
447     SASL_STATIC_OBJS="$SASL_STATIC_OBJS otp.o"
448     AC_DEFINE(STATIC_OTP, [], [Link OTP Staticly])
449   fi
450
451   dnl Test for OPIE
452   AC_ARG_WITH(with-opie,[  --with-opie=PATH        use OPIE (One Time Passwords in Everything) from PATH],
453         with_opie="${withval}")
454
455   case "$with_opie" in
456         ""|yes) 
457                 AC_CHECK_LIB(opie, opiechallenge, [
458                         AC_CHECK_HEADER(opie.h, with_opie="yes",
459                                         with_opie="no")],
460                         with_opie="no")
461                 ;;
462         *)
463                 if test -d $with_opie; then
464                   CPPFLAGS="${CPPFLAGS} -I${with_opie}/include"
465                   LDFLAGS="${LDFLAGS} -L${with_opie}/lib"
466                 else
467                   with_opie="no"
468                 fi
469                 ;;
470   esac
471
472   AC_MSG_CHECKING(for OPIE)
473   AC_MSG_RESULT($with_opie)
474
475   if test "$with_opie" != no; then
476     AC_DEFINE(HAVE_OPIE,[],[Use OPIE for server-side OTP?])
477     OTP_LIBS="$OTP_LIBS -lopie"
478   fi
479
480   AC_SUBST(OTP_LIBS)
481
482 else
483   AC_MSG_RESULT(disabled)
484 fi
485
486 dnl SRP
487 AC_ARG_ENABLE(srp, [  --enable-srp            enable SRP authentication [[no]] ],
488   srp=$enableval,
489   srp=no)
490
491 if test "$with_openssl" = no; then
492   AC_WARN([OpenSSL not found -- SRP will be disabled])
493   srp=no
494 fi
495
496 AC_MSG_CHECKING(SRP)
497 if test "$srp" != no; then
498   AC_MSG_RESULT(enabled)
499   SRP_LIBS="-lcrypto $LIB_RSAREF"
500
501   SASL_MECHS="$SASL_MECHS libsrp.la"
502   if test "$enable_static" = yes; then
503     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/srp.c"
504     SASL_STATIC_OBJS="$SASL_STATIC_OBJS srp.o"
505     AC_DEFINE(STATIC_SRP, [], [Link SRP Staticly])
506   fi
507
508 dnl srp_setpass support
509   AC_ARG_ENABLE(srp_setpass, [  --enable-srp-setpass    enable setting SRP secrets with saslpasswd [[no]]],
510       srp_setpass=$enableval,
511       srp_setpass=no)
512
513   AC_MSG_CHECKING(if we should enable setting SRP secrets with saslpasswd)
514   if test "$srp_setpass" != no; then
515     AC_MSG_RESULT(enabled)
516     AC_DEFINE(DO_SRP_SETPASS, [], [should we support setpass() for SRP?])
517   else
518     AC_MSG_RESULT(disabled)
519   fi
520
521   AC_SUBST(SRP_LIBS)
522 else
523   AC_MSG_RESULT(disabled)
524 fi
525
526 dnl Kerberos based Mechanisms
527 SASL_KERBEROS_V4_CHK
528 SASL_GSSAPI_CHK
529
530 if test "$gssapi" != "no"; then
531   AC_DEFINE(STATIC_GSSAPIV2,[],[Link GSSAPI Staticly])
532   mutex_default="no"
533   if test "$gss_impl" = "mit"; then
534      mutex_default="yes"
535   fi
536   AC_MSG_CHECKING(to use mutexes aroung GSS calls)
537   AC_ARG_ENABLE(gss_mutexes, [  --enable-gss_mutexes     use mutexes around calls to the GSS library],
538                 use_gss_mutexes=$enableval,
539                 use_gss_mutexes=$mutex_default)
540   if test $use_gss_mutexes = "yes"; then
541      AC_DEFINE(GSS_USE_MUTEXES, [], [should we mutex-wrap calls into the GSS library?])
542   fi
543   AC_MSG_RESULT($use_gss_mutexes)
544 fi
545
546 dnl PLAIN
547 SASL_PLAIN_CHK
548
549 dnl ANONYMOUS
550 AC_ARG_ENABLE(anon, [  --enable-anon           enable ANONYMOUS authentication [[yes]] ],
551   anon=$enableval,
552   anon=yes)
553
554 AC_MSG_CHECKING(ANONYMOUS)
555 if test "$anon" != no; then
556   AC_MSG_RESULT(enabled)
557   SASL_MECHS="$SASL_MECHS libanonymous.la"
558   if test "$enable_static" = yes; then
559     SASL_STATIC_OBJS="$SASL_STATIC_OBJS anonymous.o"
560     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/anonymous.c"
561     AC_DEFINE(STATIC_ANONYMOUS, [], [Link ANONYMOUS Staticly])
562   fi
563 else
564   AC_MSG_RESULT(disabled)
565 fi
566
567 dnl LOGIN
568 AC_ARG_ENABLE(login, [  --enable-login          enable unsupported LOGIN authentication [[no]] ],
569   login=$enableval,
570   login=no)
571
572 AC_MSG_CHECKING(LOGIN)
573 if test "$login" != no; then
574   AC_MSG_RESULT(enabled)
575   SASL_MECHS="$SASL_MECHS liblogin.la"
576   if test "$enable_static" = yes; then
577     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/login.c"
578     SASL_STATIC_OBJS="$SASL_STATIC_OBJS login.o"
579     AC_DEFINE(STATIC_LOGIN,[],[Link LOGIN Staticly])
580   fi
581 else
582   AC_MSG_RESULT(disabled)
583 fi
584
585 dnl NTLM
586 AC_ARG_ENABLE(ntlm, [  --enable-ntlm           enable unsupported NTLM authentication [[no]] ],
587   ntlm=$enableval,
588   ntlm=no)
589
590 if test "$with_openssl" = no; then
591   AC_WARN([OpenSSL not found -- NTLM will be disabled])
592   ntlm=no
593 fi
594
595 AC_MSG_CHECKING(NTLM)
596 if test "$ntlm" != no; then
597   AC_MSG_RESULT(enabled)
598   NTLM_LIBS="-lcrypto $LIB_RSAREF"
599   AC_SUBST(NTLM_LIBS)
600
601   SASL_MECHS="$SASL_MECHS libntlm.la"
602   if test "$enable_static" = yes; then
603     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/ntlm.c"
604     SASL_STATIC_OBJS="$SASL_STATIC_OBJS ntlm.o"
605     AC_DEFINE(STATIC_NTLM,[],[Link NTLM Staticly])
606   fi
607 else
608   AC_MSG_RESULT(disabled)
609 fi
610
611 dnl PASSDSS
612 AC_ARG_ENABLE(passdss, [  --enable-passdss        enable PASSDSS authentication (experimental) [[no]] ],
613   passdss=$enableval,
614   passdss=no)
615
616 if test "$with_openssl" = no; then
617   AC_WARN([OpenSSL not found -- PASSDSS will be disabled])
618   passdss=no
619 fi
620
621 AC_MSG_CHECKING(PASSDSS)
622 if test "$passdss" != no; then
623   AC_MSG_RESULT(enabled)
624   PASSDSS_LIBS="-lcrypto $LIB_RSAREF"
625   AC_SUBST(PASSDSS_LIBS)
626
627   SASL_MECHS="$SASL_MECHS libpassdss.la"
628   if test "$enable_static" = yes; then
629     SASL_STATIC_OBJS="$SASL_STATIC_OBJS passdss.o"
630     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/passdss.c"
631     AC_DEFINE(STATIC_PASSDSS,[],[Link PASSDSS Staticly])
632   fi
633 else
634   AC_MSG_RESULT(disabled)
635 fi
636
637
638 # make the option show up so people don't whine that it is only in the
639 # saslauthd configure script --help
640 AC_ARG_WITH(ldap,   [  --with-ldap=DIR         use LDAP (in DIR) for saslauthd [no] ],,with_ldap=no)
641
642
643 dnl SQL
644 dnl This flag also changes the requirements of --with-mysql and --with-pgsql
645 dnl
646 dnl Desired behavior:
647 dnl
648 dnl doesn't require mysql or postgres if --disable-sql is chosen
649 dnl requires at least one (but not both) if --enable-sql is chosen
650
651 AC_ARG_ENABLE(sql, [  --enable-sql            enable SQL auxprop [[no]] ],
652   sql=$enableval,
653   sql=no)
654
655 AC_MSG_CHECKING(SQL)
656 if test "$sql" != no; then
657   AC_MSG_RESULT(enabled)
658   SASL_MECHS="$SASL_MECHS libsql.la"
659   if test "$enable_static" = yes; then
660     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/sql.c"
661     SASL_STATIC_OBJS="$SASL_STATIC_OBJS sql.o"
662     AC_DEFINE(STATIC_SQL,[],[Link SQL plugin staticly])
663   fi
664 else
665   AC_MSG_RESULT(disabled)
666 fi
667
668 dnl MySQL
669 AC_ARG_WITH(mysql,  [  --with-mysql=PATH       use MySQL from PATH ],
670   with_mysql=$withval,
671   with_mysql=$sql)
672
673 # find location of library 
674 # presuming if one given then correct
675 if test "${with_mysql}" = "yes"; then
676   with_mysql=notfound
677   for mysqlloc in lib/mysql lib mysql/lib
678   do
679     if test -f ${prefix}/${mysqlloc}/libmysqlclient.a; then
680       with_mysql="${prefix}"
681       break
682     elif test -f /usr/local/${mysqlloc}/libmysqlclient.a; then
683       with_mysql="/usr/local"
684       break
685     elif test -f /usr/${mysqlloc}/libmysqlclient.a; then
686       with_mysql="/usr"
687       break
688     fi
689   done
690 fi
691
692 LIB_MYSQL=""
693
694 case "$with_mysql" in
695     no) true;;
696     notfound) AC_WARN([MySQL Library not found]); true;;
697     *)
698      if test -d ${with_mysql}/lib/mysql; then
699         CMU_ADD_LIBPATH_TO(${with_mysql}/lib/mysql, LIB_MYSQL)
700      elif test -d ${with_mysql}/mysql/lib; then
701         CMU_ADD_LIBPATH_TO(${with_mysql}/mysql/lib, LIB_MYSQL)
702      elif test -d ${with_mysql}/lib; then
703         CMU_ADD_LIBPATH_TO(${with_mysql}/lib, LIB_MYSQL)
704      else
705         CMU_ADD_LIBPATH_TO(${with_mysql}, LIB_MYSQL)
706      fi
707
708      LIB_MYSQL_DIR=$LIB_MYSQL
709      LIB_MYSQL="$LIB_MYSQL -lmysqlclient"
710
711      if test -d ${with_mysql}/include/mysql; then
712          CPPFLAGS="${CPPFLAGS} -I${with_mysql}/include/mysql"
713      elif test -d ${with_mysql}/mysql/include; then
714          CPPFLAGS="${CPPFLAGS} -I${with_mysql}/mysql/include"
715      elif test -d ${with_mysql}/include; then
716          CPPFLAGS="${CPPFLAGS} -I${with_mysql}/include"
717      else
718          CPPFLAGS="${CPPFLAGS} -I${with_mysql}"
719      fi
720
721        save_LDFLAGS=$LDFLAGS
722        LDFLAGS="$LDFLAGS $LIB_MYSQL_DIR"
723        AC_CHECK_LIB(mysqlclient, mysql_select_db,
724            AC_DEFINE(HAVE_MYSQL, [], [Do we have mysql support?]),
725            [AC_WARN([MySQL library mysqlclient does not work])
726             with_mysql=no])
727        LDFLAGS=$save_LDFLAGS;;
728          
729 esac
730 AC_SUBST(LIB_MYSQL)
731
732 dnl PgSQL
733 AC_ARG_WITH(pgsql,  [  --with-pgsql=PATH       use PostgreSQL from PATH ],
734   with_pgsql=$withval,
735   with_pgsql=$sql)
736
737 # find location of library 
738 # presuing if one given then correct
739 if test "${with_pgsql}" = "yes"; then
740   with_pgsql=notfound
741   for pgsqlloc in lib/pgsql lib pgsql/lib
742   do
743     if test -f ${prefix}/${pgsqlloc}/libpq.a; then
744       with_pgsql="${prefix}"
745       break
746     elif test -f /usr/local/${pgsqlloc}/libpq.a; then
747       with_pgsql="/usr/local"
748       break
749     elif test -f /usr/${pgsqlloc}/libpq.a; then
750       with_pgsql="/usr"
751       break
752     fi
753   done
754 fi
755
756 LIB_PGSQL=""
757
758 case "$with_pgsql" in
759     no) true;;
760     notfound) AC_WARN([PostgreSQL Library not found]); true;;
761     *)
762      if test -d ${with_pgsql}/lib/pgsql; then
763         CMU_ADD_LIBPATH_TO(${with_pgsql}/lib/pgsql, LIB_PGSQL)
764      elif test -d ${with_pgsql}/pgsql/lib; then
765         CMU_ADD_LIBPATH_TO(${with_pgsql}/pgsql/lib, LIB_PGSQL)
766      elif test -d ${with_pgsql}/lib; then
767         CMU_ADD_LIBPATH_TO(${with_pgsql}/lib, LIB_PGSQL)
768      else
769         CMU_ADD_LIBPATH_TO(${with_pgsql}, LIB_PGSQL)
770      fi
771
772      LIB_PGSQL_DIR=$LIB_PGSQL
773      LIB_PGSQL="$LIB_PGSQL -lpq"
774
775      if test -d ${with_pgsql}/include/pgsql; then
776          CPPFLAGS="${CPPFLAGS} -I${with_pgsql}/include/pgsql"
777      elif test -d ${with_pgsql}/pgsql/include; then
778          CPPFLAGS="${CPPFLAGS} -I${with_pgsql}/pgsql/include"
779      elif test -d ${with_pgsql}/include; then
780          CPPFLAGS="${CPPFLAGS} -I${with_pgsql}/include"
781      else
782          CPPFLAGS="${CPPFLAGS} -I${with_pgsql}"
783      fi
784
785
786        save_LDFLAGS=$LDFLAGS
787        LDFLAGS="$LDFLAGS $LIB_PGSQL_DIR"
788        AC_CHECK_LIB(pq, PQsetdbLogin, AC_DEFINE(HAVE_PGSQL,[],
789            [Do we have Postgres support?]),
790            [AC_WARN([PostgreSQL Library pq does not work])
791             with_pgsql=no])
792        LDFLAGS=$save_LDFLAGS;;
793          
794 esac
795 AC_SUBST(LIB_PGSQL)
796
797 dnl SQLite
798 AC_ARG_WITH(sqlite,  [  --with-sqlite=PATH       use SQLite from PATH ],
799   with_sqlite=$withval,
800   with_sqlite=$sql)
801
802 # find location of library 
803 # presuing if one given then correct
804 if test "${with_sqlite}" = "yes"; then
805   with_sqlite=notfound
806   for sqliteloc in lib
807   do
808     if test -f ${prefix}/${sqliteloc}/libsqlite.a; then
809       with_sqlite="${prefix}"
810       break
811     elif test -f /usr/local/${sqliteloc}/libsqlite.a; then
812       with_sqlite="/usr/local"
813       break
814     elif test -f /usr/${sqliteloc}/libsqlite.a; then
815       with_sqlite="/usr"
816       break
817     fi
818   done
819 fi
820
821 LIB_SQLITE=""
822
823 case "$with_sqlite" in
824     no) true;;
825     notfound) AC_WARN([SQLite Library not found]); true;;
826     *)
827      if test -d ${with_sqlite}/lib; then
828          LIB_SQLITE="-L${with_sqlite}/lib -R${with_sqlite}/lib"
829      else
830          LIB_SQLITE="-L${with_sqlite} -R${with_sqlite}"
831      fi
832
833      LIB_SQLITE_DIR=$LIB_SQLITE
834      LIB_SQLITE="$LIB_SQLITE -lsqlite"
835
836      if test -d ${with_sqlite}/include; then
837          CPPFLAGS="${CPPFLAGS} -I${with_sqlite}/include"
838      else
839          CPPFLAGS="${CPPFLAGS} -I${with_sqlite}"
840      fi
841        AC_CHECK_LIB(sqlite, sqlite_open, AC_DEFINE(HAVE_SQLITE,[],
842            [Do we have SQLite support?]),
843            [AC_WARN([SQLite Library sqlite does not work])
844             with_sqlite=no], $LIB_SQLITE_DIR);;
845          
846 esac
847 AC_SUBST(LIB_SQLITE)
848
849 if test "$sql" = yes -a "$with_pgsql" = no -a "$with_mysql" = no -a "$with_sqlite" = no; then
850     AC_ERROR([--enable-sql chosen but neither Postgres nor MySQL nor SQLite found])
851 fi
852
853 if test "$enable_shared" = yes; then
854         AC_DEFINE(DO_DLOPEN,[],[Should we build a shared plugin (via dlopen) library?])
855 fi
856
857 dnl LDAPDB
858 AC_ARG_ENABLE(ldapdb, [  --enable-ldapdb         enable LDAPDB plugin [no] ],
859   ldapdb=$enableval,
860   ldapdb=no)
861 AC_MSG_CHECKING(LDAPDB)
862 if test "$ldapdb" != no; then
863     AC_MSG_RESULT(enabled)
864
865     if test "$with_ldap" = no; then
866         AC_MSG_ERROR([Cannot enable LDAPDB plugin: You need to specify --with-ldap])
867     fi
868
869     save_CPPFLAGS=$CPPFLAGS
870     save_LDFLAGS=$LDFLAGS
871
872     if test -d $with_ldap; then
873         CPPFLAGS="${CPPFLAGS} -I${with_ldap}/include"
874         CMU_ADD_LIBPATH(${with_ldap}/lib)
875     fi
876
877     AC_CHECK_HEADERS(ldap.h lber.h)
878
879     if test $ac_cv_header_ldap_h = yes -a $ac_cv_header_lber_h = yes; then
880         CMU_OPENLDAP_API
881
882         if test "$cmu_cv_openldap_api" = yes; then
883             AC_CHECK_LIB(ldap, ldap_initialize, [ cmu_link_openldap="-lldap -llber" ], [ cmu_link_openldap=no ],-llber)
884         fi
885     fi
886
887     if test "$cmu_cv_openldap_api" = no -o "$cmu_link_openldap" = no; then
888         AC_MSG_ERROR([Cannot enable LDAPDB plugin: Could not locate OpenLDAP])
889     else
890         CMU_OPENLDAP_COMPAT
891
892         if test "$cmu_cv_openldap_compat" = no; then
893             AC_MSG_ERROR([Cannot enable LDAPDB plugin: OpenLDAP library located but incompatible])
894         else
895             LIB_LDAP=$cmu_link_openldap
896             AC_SUBST(LIB_LDAP)
897
898             SASL_MECHS="$SASL_MECHS libldapdb.la"
899             if test "$enable_static" = yes; then
900                 SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/ldapdb.c"
901                 SASL_STATIC_OBJS="$SASL_STATIC_OBJS ldapdb.o"
902                 AC_DEFINE(STATIC_LDAPDB,[],[Link ldapdb plugin Staticly])
903             fi
904         fi
905     fi
906
907     if test "$cmu_cv_openldap_compat" != yes; then
908         CPPFLAGS=$save_CPPFLAGS
909         LDFLAGS=$save_LDFLAGS
910     fi
911 else
912     AC_MSG_RESULT(disabled)
913 fi
914
915 AC_SUBST(SASL_MECHS)
916 AC_SUBST(SASL_STATIC_SRCS)
917 AC_SUBST(SASL_STATIC_OBJS)
918 AC_SUBST(SASL_STATIC_LIBS)
919
920 AC_ARG_WITH(plugindir, [  --with-plugindir=DIR    set the directory where plugins will
921                           be found [[/usr/lib/sasl2]] ],
922   plugindir=$withval,
923   plugindir=/usr/lib/sasl2)
924 AC_DEFINE_UNQUOTED(PLUGINDIR, "$plugindir", [Runtime plugin location])
925 AC_SUBST(plugindir)
926
927 AC_ARG_WITH(configdir, [   --with-configdir=DIR    set the directory where config files will
928                           be found [/usr/lib/sasl2] ],
929   configdir=$withval,
930   configdir=$plugindir:/etc/sasl2)
931 AC_DEFINE_UNQUOTED(CONFIGDIR, "$configdir", [Runtime config file location])
932 AC_SUBST(configdir)
933
934 dnl look for rc4 libraries. we accept the CMU one or one from openSSL
935 AC_ARG_WITH(rc4, [  --with-rc4              use internal rc4 routines [[yes]] ],
936         with_rc4=$withval,
937         with_rc4=yes)
938
939 if test "$with_rc4" != no; then
940     AC_DEFINE(WITH_RC4,[],[Use internal RC4 implementation?])
941 fi
942
943 building_for_macosx=no
944 case "$host_os" in
945         darwin*)
946 AC_ARG_ENABLE(macos-framework, [  --disable-macos-framework       disable building and installing replacement SASL2 Framework for MacOS X-provided SASL Framework [[no]]],building_for_macosx=no,building_for_macosx=yes)
947         ;;
948 esac
949 AM_CONDITIONAL(MACOSX, test "$building_for_macosx" = yes)
950
951 dnl dmalloc tests
952 AC_MSG_CHECKING(for dmalloc library)
953 AC_ARG_WITH(dmalloc, [  --with-dmalloc=DIR      with DMALLOC support (for test applications) [[no]] ],
954         with_dmalloc=$withval,
955         with_dmalloc=no)
956
957 DMALLOC_LIBS=""
958
959 if test "$with_dmalloc" != "no"; then
960    if test "$with_dmalloc" = "yes"; then
961         with_dmalloc="/usr/local"
962    fi
963
964    if test -r "$with_dmalloc/libdmalloc.a"; then
965         DMALLOC_LIBS="$with_dmalloc/libdmalloc.a"
966         AC_DEFINE(WITH_DMALLOC,[],[Linking against dmalloc?])
967         AC_MSG_RESULT(yes)
968    elif test -r "$with_dmalloc/lib/libdmalloc.a"; then
969         DMALLOC_LIBS="$with_dmalloc/lib/libdmalloc.a"
970         AC_DEFINE(WITH_DMALLOC,[],[Linking against dmalloc?])
971         AC_MSG_RESULT(yes)
972    else
973         AC_MSG_ERROR(cannot find dmalloc library, please check your installation.)
974    fi
975 else
976    AC_MSG_RESULT(no)
977 fi
978
979 AC_SUBST(DMALLOC_LIBS)
980
981 dnl sfio tests
982 AC_MSG_CHECKING(for sfio library)
983 AC_ARG_WITH(sfio, [  --with-sfio=DIR         with SFIO support (for smtptest/libsfsasl) [[no]] ],
984         with_sfio=$withval,
985         with_sfio=no)
986
987 if test "$with_sfio" != "no"; then
988    if test "$with_sfio" = "yes"; then
989         with_sfio="/usr/local"
990    fi
991
992    AC_DEFUN([SFIO_INC_CHK],
993         [if test -r "$with_sfio$1/sfio.h"; then SFIO_DIR=$with_sfio;
994                                               SFIO_INC_DIR=$with_sfio$1])
995
996    AC_DEFUN([SFIO_LIB_CHK],[
997                 str="$SFIO_DIR/$1/libsfio.*"
998                 for i in `echo $str`; do
999                         if test -r $i; then
1000                                 SFIO_LIBDIR=$SFIO_DIR/$1
1001                                 break 2
1002                         fi
1003                 done
1004                 ])
1005
1006    SFIO_INC_CHK()
1007    el[]SFIO_INC_CHK(/include)
1008    el[]SFIO_INC_CHK(/include/sfio)
1009    fi
1010
1011    if test -z "$SFIO_DIR"; then
1012         AC_MSG_ERROR(Cannot find sfio.h, Please check your SFIO installation.)
1013    fi
1014
1015    SFIO_LIB_CHK(lib)
1016    SFIO_LIB_CHK(lib/sfio)
1017
1018    if test -z "$SFIO_LIBDIR"; then
1019         AC_MSG_ERROR(Cannot find sfio library, Please check your SFIO installation.)
1020    fi
1021
1022    SFIO_INC_FLAGS="-I$SFIO_INC_DIR"
1023    SFIO_LIB_FLAGS="-L$SFIO_LIBDIR -lsfio"
1024    SMTPTEST_PROGRAM="smtptest"
1025    SASL_UTIL_LIBS_EXTRA=libsfsasl2.la
1026    SASL_UTIL_HEADERS_EXTRA=sfsasl.h
1027
1028    AC_MSG_RESULT(yes)
1029 else
1030    AC_MSG_RESULT(no)
1031    SFIO_INC_FLAGS=""
1032    SFIO_LIB_FLAGS=""
1033    SMTPTEST_PROGRAM=""
1034    SASL_UTIL_LIBS_EXTRA=""
1035    SASL_UTIL_HEADERS_EXTRA=""
1036 fi
1037
1038 AC_SUBST(SFIO_INC_FLAGS)
1039 AC_SUBST(SFIO_LIB_FLAGS)
1040 AC_SUBST(SMTPTEST_PROGRAM)
1041 AC_SUBST(SASL_UTIL_LIBS_EXTRA)
1042 AC_SUBST(SASL_UTIL_HEADERS_EXTRA)
1043
1044 dnl check for getsubopt
1045 sasl_cv_getsubopt=no
1046 AC_CHECK_FUNC(getsubopt, [AC_DEFINE(HAVE_GETSUBOPT,[],
1047         [do we have getsubopt()?])], [sasl_cv_getsubopt=yes])
1048 if test $sasl_cv_getsubopt = yes; then
1049         AC_LIBOBJ(getsubopt)
1050         GETSUBOPT="getsubopt.lo"
1051 fi
1052 AC_SUBST(GETSUBOPT)
1053
1054 dnl Check for snprintf
1055 sasl_cv_snprintf=no
1056 SNPRINTFOBJS=""
1057 AC_CHECK_FUNC(snprintf, [AC_DEFINE(HAVE_SNPRINTF,[],[Does the system have snprintf()?])], [sasl_cv_snprintf=yes])
1058 AC_CHECK_FUNC(vsnprintf, [AC_DEFINE(HAVE_VSNPRINTF,[],[Does the system have vsnprintf()?])], [sasl_cv_snprintf=yes])
1059 if test $sasl_cv_snprintf = yes; then
1060         AC_LIBOBJ(snprintf)
1061         SNPRINTFOBJS="snprintf.o"
1062         LTSNPRINTFOBJS="snprintf.lo"
1063 fi
1064 AC_SUBST(SNPRINTFOBJS)
1065 AC_SUBST(LTSNPRINTFOBJS)
1066
1067 dnl do we need to link in -lresolv?
1068 AC_CHECK_LIB(resolv, inet_aton)
1069
1070 dnl Check for getaddrinfo
1071 GETADDRINFOOBJS=""
1072 sasl_cv_getaddrinfo=yes
1073 IPv6_CHECK_FUNC(getaddrinfo, [IPv6_CHECK_FUNC(gai_strerror,
1074                 [AC_DEFINE(HAVE_GETADDRINFO,[],[Do we have a getaddrinfo() function?])
1075                 sasl_cv_getaddrinfo=no])])
1076 if test $sasl_cv_getaddrinfo = yes; then
1077     AC_LIBOBJ(getaddrinfo)
1078     GETADDRINFOOBJS="getaddrinfo.o"
1079     LTGETADDRINFOOBJS="getaddrinfo.lo"
1080 fi
1081 AC_SUBST(GETADDRINFOOBJS)
1082 AC_SUBST(LTGETADDRINFOOBJS)
1083
1084 dnl Check for getnameinfo
1085 GETNAMEINFOOBJS=""
1086 sasl_cv_getnameinfo=no
1087 IPv6_CHECK_FUNC(getnameinfo,
1088                 [AC_DEFINE(HAVE_GETNAMEINFO,[],[Do we have a getnameinfo() function?])], [sasl_cv_getnameinfo=yes])
1089 if test $sasl_cv_getnameinfo = yes; then
1090         AC_LIBOBJ(getnameinfo)
1091         GETNAMEINFOOBJS="getnameinfo.o"
1092         LTGETNAMEINFOOBJS="getnameinfo.lo"
1093 fi
1094 AC_SUBST(GETNAMEINFOOBJS)
1095 AC_SUBST(LTGETNAMEINFOOBJS)
1096
1097 LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
1098 AC_SUBST(LTLIBOBJS)
1099
1100 AC_C_CONST
1101 AC_C_INLINE
1102 AC_TYPE_MODE_T
1103 AC_TYPE_PID_T
1104 AC_TYPE_SIGNAL
1105
1106 AC_HEADER_TIME
1107 AC_HEADER_STDC
1108 AC_HEADER_DIRENT
1109 AC_HEADER_SYS_WAIT
1110 AC_CHECK_HEADERS(des.h dlfcn.h fcntl.h limits.h malloc.h paths.h strings.h sys/file.h sys/time.h syslog.h unistd.h inttypes.h sys/uio.h sys/param.h sysexits.h stdarg.h varargs.h)
1111
1112 IPv6_CHECK_SS_FAMILY()
1113 IPv6_CHECK_SA_LEN()
1114 IPv6_CHECK_SOCKLEN_T()
1115
1116 #AC_FUNC_MEMCMP
1117 #AC_FUNC_VPRINTF
1118 AC_CHECK_FUNCS(gethostname getdomainname getpwnam getspnam gettimeofday inet_aton memcpy mkdir select socket strchr strdup strerror strspn strstr strtol jrand48)
1119
1120 if test $enable_cmulocal = yes; then
1121     AC_WARN([enabling CMU local kludges])
1122     AC_DEFINE(KRB4_IGNORE_IP_ADDRESS,[],[Ignore IP Address in Kerberos 4 tickets?])
1123     AC_DEFINE_UNQUOTED(PREFER_MECH, "KERBEROS_V4", [Force a preferred mechanism])
1124 fi
1125
1126 AC_EGREP_HEADER(sockaddr_storage, sys/socket.h, [
1127                 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE,[],[Do we have struct sockaddr_stroage?])])
1128
1129 AC_SUBST(DIRS)
1130
1131 AC_CONFIG_SUBDIRS(saslauthd)
1132
1133 AH_TOP([
1134 /* acconfig.h - autoheader configuration input */
1135 /* 
1136  * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
1137  *
1138  * Redistribution and use in source and binary forms, with or without
1139  * modification, are permitted provided that the following conditions
1140  * are met:
1141  *
1142  * 1. Redistributions of source code must retain the above copyright
1143  *    notice, this list of conditions and the following disclaimer. 
1144  *
1145  * 2. Redistributions in binary form must reproduce the above copyright
1146  *    notice, this list of conditions and the following disclaimer in
1147  *    the documentation and/or other materials provided with the
1148  *    distribution.
1149  *
1150  * 3. The name "Carnegie Mellon University" must not be used to
1151  *    endorse or promote products derived from this software without
1152  *    prior written permission. For permission or any other legal
1153  *    details, please contact  
1154  *      Office of Technology Transfer
1155  *      Carnegie Mellon University
1156  *      5000 Forbes Avenue
1157  *      Pittsburgh, PA  15213-3890
1158  *      (412) 268-4387, fax: (412) 268-7395
1159  *      tech-transfer@andrew.cmu.edu
1160  *
1161  * 4. Redistributions of any form whatsoever must retain the following
1162  *    acknowledgment:
1163  *    "This product includes software developed by Computing Services
1164  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
1165  *
1166  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
1167  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1168  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
1169  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1170  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
1171  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
1172  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1173  */
1174
1175 #ifndef CONFIG_H
1176 #define CONFIG_H
1177 ])
1178
1179 AH_BOTTOM([
1180
1181
1182 /* Create a struct iovec if we need one */
1183 #if !defined(_WIN32) && !defined(HAVE_SYS_UIO_H)
1184 /* (win32 is handled in sasl.h) */
1185 struct iovec {
1186     char *iov_base;
1187     long iov_len;
1188 };
1189 #else
1190 #include <sys/types.h>
1191 #include <sys/uio.h>
1192 #endif
1193
1194 /* location of the random number generator */
1195 #ifdef DEV_RANDOM
1196 #undef DEV_RANDOM
1197 #endif
1198 #define DEV_RANDOM SASL_DEV_RANDOM
1199
1200 /* if we've got krb_get_err_txt, we might as well use it;
1201    especially since krb_err_txt isn't in some newer distributions
1202    (MIT Kerb for Mac 4 being a notable example). If we don't have
1203    it, we fall back to the krb_err_txt array */
1204 #ifdef HAVE_KRB_GET_ERR_TEXT
1205 #define get_krb_err_txt krb_get_err_text
1206 #else
1207 #define get_krb_err_txt(X) (krb_err_txt[(X)])
1208 #endif
1209
1210 /* Make Solaris happy... */
1211 #ifndef __EXTENSIONS__
1212 #define __EXTENSIONS__
1213 #endif
1214
1215 /* Make Linux happy... */
1216 #ifndef _GNU_SOURCE
1217 #define _GNU_SOURCE
1218 #endif
1219
1220 #ifndef HAVE___ATTRIBUTE__
1221 /* Can't use attributes... */
1222 #define __attribute__(foo)
1223 #endif
1224
1225 #define SASL_PATH_ENV_VAR "SASL_PATH"
1226 #define SASL_CONF_PATH_ENV_VAR "SASL_CONF_PATH"
1227
1228 #include <stdlib.h>
1229 #include <sys/types.h>
1230 #include <sys/socket.h>
1231 #ifndef WIN32
1232 # include <netdb.h>
1233 # ifdef HAVE_SYS_PARAM_H
1234 #  include <sys/param.h>
1235 # endif
1236 #else /* WIN32 */
1237 # include <winsock2.h>
1238 #endif /* WIN32 */
1239 #include <string.h>
1240
1241 #include <netinet/in.h>
1242
1243 #ifndef HAVE_SOCKLEN_T
1244 typedef unsigned int socklen_t;
1245 #endif /* HAVE_SOCKLEN_T */
1246
1247 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
1248 #define _SS_MAXSIZE     128     /* Implementation specific max size */
1249 #define _SS_PADSIZE     (_SS_MAXSIZE - sizeof (struct sockaddr))
1250
1251 struct sockaddr_storage {
1252         struct  sockaddr ss_sa;
1253         char            __ss_pad2[_SS_PADSIZE];
1254 };
1255 # define ss_family ss_sa.sa_family
1256 #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
1257
1258 #ifndef AF_INET6
1259 /* Define it to something that should never appear */
1260 #define AF_INET6        AF_MAX
1261 #endif
1262
1263 #ifndef HAVE_GETADDRINFO
1264 #define getaddrinfo     sasl_getaddrinfo
1265 #define freeaddrinfo    sasl_freeaddrinfo
1266 #define gai_strerror    sasl_gai_strerror
1267 #endif
1268
1269 #ifndef HAVE_GETNAMEINFO
1270 #define getnameinfo     sasl_getnameinfo
1271 #endif
1272
1273 #if !defined(HAVE_GETNAMEINFO) || !defined(HAVE_GETADDRINFO)
1274 #include "gai.h"
1275 #endif
1276
1277 #ifndef AI_NUMERICHOST   /* support glibc 2.0.x */
1278 #define AI_NUMERICHOST  4
1279 #define NI_NUMERICHOST  2
1280 #define NI_NAMEREQD     4
1281 #define NI_NUMERICSERV  8
1282 #endif
1283
1284 /* Defined in RFC 1035. max strlen is only 253 due to length bytes. */
1285 #ifndef MAXHOSTNAMELEN
1286 #define        MAXHOSTNAMELEN  255
1287 #endif
1288
1289 #ifndef HAVE_SYSEXITS_H
1290 #include "exits.h"
1291 #else
1292 #include "sysexits.h"
1293 #endif
1294
1295 /* Get the correct time.h */
1296 #if TIME_WITH_SYS_TIME
1297 # include <sys/time.h>
1298 # include <time.h>
1299 #else
1300 # if HAVE_SYS_TIME_H
1301 #  include <sys/time.h>
1302 # else
1303 #  include <time.h>
1304 # endif
1305 #endif
1306
1307 #ifndef HIER_DELIMITER
1308 #define HIER_DELIMITER '/'
1309 #endif
1310
1311 #endif /* CONFIG_H */
1312 ])
1313
1314 AC_CONFIG_HEADERS(config.h)
1315
1316 AC_OUTPUT(Makefile
1317 include/Makefile
1318 sasldb/Makefile
1319 plugins/Makefile
1320 lib/Makefile
1321 utils/Makefile
1322 doc/Makefile
1323 sample/Makefile
1324 java/Makefile
1325 java/CyrusSasl/Makefile
1326 java/Test/Makefile
1327 java/javax/Makefile
1328 java/javax/security/Makefile
1329 java/javax/security/auth/Makefile
1330 java/javax/security/auth/callback/Makefile
1331 pwcheck/Makefile
1332 man/Makefile)
1333
1334 echo Configuration Complete.  Type \'make\' to build.