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