Imported upstream version 0.59.3
[hcoop/debian/courier-authlib.git] / configure.in
CommitLineData
d9898ee8 1dnl Process this file with autoconf to produce a configure script.
2dnl
3dnl $Id: configure.in,v 1.147 2007/04/22 14:53:55 mrsam Exp $
4dnl
5dnl Copyright 1998 - 2007 Double Precision, Inc. See COPYING for
6dnl distribution information.
7
8AC_PREREQ(2.59)
9AC_INIT(courier-authlib, 0.59.3, [courier-users@lists.sourceforge.net])
10
11AC_CONFIG_SRCDIR([courierauth.h])
12AM_CONFIG_HEADER([courier_auth_config.h])
13
14AM_INIT_AUTOMAKE
15>confdefs.h # Kill PACKAGE_ macros
16
17LPATH="$PATH:/usr/local/bin"
18
19dnl Checks for programs.
20AC_PROG_AWK
21AC_PROG_CC
22AC_PROG_CPP
23AC_PROG_INSTALL
24AC_PROG_LN_S
25AC_PROG_SYSCONFTOOL
26AC_LIBLTDL_INSTALLABLE
27AC_LIBTOOL_DLOPEN
28AM_PROG_LIBTOOL
29AC_SUBST(LTDLINCL)
30AC_SUBST(LIBLTDL)
31AC_PATH_PROGS(PERL, perl5 perl, perl, $LPATH)
32AC_PATH_PROGS(COURIERCONFIG, courier-config, courier-config, $LPATH)
33
34if test "$PERL" = "perl"
35then
36 AC_MSG_ERROR(Perl is required)
37fi
38
39test "x$prefix" = xNONE && prefix=$ac_default_prefix
40test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
41eval "prefix=$prefix"
42eval "exec_prefix=$exec_prefix"
43eval "sysconfdir=$sysconfdir"
44eval "bindir=$bindir"
45eval "sbindir=$sbindir"
46eval "localstatedir=$localstatedir"
47eval "libexecdir=$libexecdir"
48
49AC_ARG_WITH(redhat, [], [ redhat=$withval ], [redhat=no])
50
51if test "$srcdir" = "."
52then
53 case `./config.guess` in
54 *-redhat-*)
55 if test "$redhat" = "no"
56 then
57 hash='#'
58 AC_MSG_WARN(=== I think you are trying to run this configure script)
59 AC_MSG_WARN([=== on Red Hat/Fedora. You're doing too much work!])
60 AC_MSG_WARN([=== It's much faster to create installable binary RPMs])
61 AC_MSG_WARN([=== like this: http://www.courier-mta.org/FAQ.html${hash}rpm])
62 AC_MSG_WARN(=== When you do this you may find that RPM will tell you)
63 AC_MSG_WARN([=== to install some other software first, before trying to])
64 AC_MSG_WARN([=== build this one, and even tell you the name of RPMs you])
65 AC_MSG_WARN([=== need to install from the distribution CD. That's much])
66 AC_MSG_WARN([=== easier than trying to figure out the same from some])
67 AC_MSG_WARN([=== cryptic error message.])
68 AC_MSG_WARN([])
69 AC_MSG_WARN([=== Even if you don't intend to use everything you need to])
70 AC_MSG_WARN([=== have in order to build via RPM, you should still do as])
71 AC_MSG_WARN([=== you're told. All the extra stuff (LDAP, SQL, etc...)])
72 AC_MSG_WARN([=== goes into RPM sub-packages, which do not need to be])
73 AC_MSG_WARN([=== installed.])
74 AC_MSG_WARN([=== But, if you insist, you can simply add '--with-redhat'])
75 AC_MSG_WARN(=== parameter to this configure script and not see this)
76 AC_MSG_WARN(=== error message. You should also do this when upgrading)
77 AC_MSG_WARN([=== and you didn't use RPM with the older version.])
78 AC_MSG_ERROR(... in either case you better know what you're doing!)
79 fi
80 ;;
81 *)
82 ;;
83 esac
84fi
85AC_PATH_PROGS(EXPECT, expect, expect, $LPATH)
86
87if test "$EXPECT" = "expect"
88then
89 AC_MSG_WARN(-----------------------------------------------------)
90 AC_MSG_WARN(expect not found - will not be able to change passwds)
91 AC_MSG_WARN(in webmail)
92 AC_MSG_WARN(-----------------------------------------------------)
93 sleep 5
94else
95 AC_DEFINE_UNQUOTED(HAVE_EXPECT, 1, [ Whether expect(1) is installed ])
96fi
97
98AC_PATH_PROGS(PASSWD, passwd, passwd, $LPATH)
99AC_SUBST(PASSWD)
100
101if test "$GCC" = "yes"
102then
103 CFLAGS="$CFLAGS -Wall"
104fi
105
106CFLAGS="$CFLAGS -I.. -I${srcdir}/.."
107
108AC_MSG_CHECKING(whether -lm is needed for floor)
109AC_TRY_LINK_FUNC(floor,
110 AC_MSG_RESULT(no),
111 LIBM="-lm"
112 AC_MSG_RESULT(yes))
113
114AC_ARG_WITH(pkgconfdir,
115[ --with-pkgconfdir=d Install config files in directory ],
116 [pkgconfdir="$withval"],
117 [pkgconfdir="$sysconfdir/authlib"])
118
119SASL_LIST="SASL(\"PLAIN\", authsasl_plain, authsaslclient_plain) SASL(\"LOGIN\", authsasl_login, authsaslclient_login)"
120
121dnl #########################################################################
122
123dnl Check if the MD5 library is available
124
125dnl #########################################################################
126
127
128if test -d ${srcdir}/md5
129then
130 MD5=1
131 AC_DEFINE_UNQUOTED(HAVE_MD5LIB, 1,
132 [ Whether we have the MD5 library available ])
133 MD5LIB=md5/libmd5.la
134 if test -d ${srcdir}/md5
135 then
136 SASL_LIST="SASL(\"CRAM-MD5\", authsasl_cram, authsaslclient_crammd5) $SASL_LIST"
137 fi
138else
139 MD5LIB=""
140 MD5=0
141fi
142AC_SUBST(MD5LIB)
143AM_CONDITIONAL(HAVE_MD5, test "$MD5" = 1)
144
145dnl #########################################################################
146
147dnl Check if the SHA1 library is available
148
149dnl #########################################################################
150
151
152if test -d ${srcdir}/sha1
153then
154 SHA1=1
155 AC_DEFINE_UNQUOTED(HAVE_SHA1LIB, 1,
156 [ Whether we have the SHA1 library available ])
157 SHA1LIB=sha1/libsha1.la
158 if test -d ${srcdir}/sha1
159 then
160 SASL_LIST="SASL(\"CRAM-SHA1\", authsasl_cram, authsaslclient_cramsha1) $SASL_LIST"
161 SASL_LIST="SASL(\"CRAM-SHA256\", authsasl_cram, authsaslclient_cramsha256) $SASL_LIST"
162 fi
163else
164 SHA1LIB=""
165 SHA1=0
166fi
167AC_SUBST(SHA1LIB)
168AM_CONDITIONAL(HAVE_SHA1, test "$SHA1" = 1)
169
170
171
172dnl #########################################################################
173
174dnl Check if the HMAC library is available
175
176dnl #########################################################################
177
178if test -d ${srcdir}/libhmac
179then
180 HMAC=1
181 AC_DEFINE_UNQUOTED(HAVE_HMACLIB, 1,
182 [ Whether we have the HMAC library available ])
183 HMACLIB=libhmac/libhmac.la
184else
185 HMACLIB=""
186 HMAC=0
187fi
188AC_SUBST(HMACLIB)
189AM_CONDITIONAL(HAVE_HMACLIB, test "$HMAC" = 1)
190
191saveLIBS="$LIBS"
192NETLIBS=""
193USENSL=no
194
195AC_CHECK_LIB(socket,socket,result=yes,result=no)
196if test $result = yes; then
197 NETLIBS="-lsocket"
198else
199 AC_CHECK_LIB(socket,socket,result=yes,result=no,-lnsl)
200 if test $result = yes; then
201 NETLIBS = "-lsocket -lnsl"
202 USENSL=yes
203 else
204 AC_CHECK_LIB(socket,connect,result=yes,result=no)
205 if test $result = yes; then
206 NETLIBS="-lsocket"
207 else
208 AC_CHECK_LIB(socket,connect,result=yes,result=no,-lnsl)
209 if test $result = yes; then
210 NETLIBS="-lsocket -lnsl"
211 USENSL=yes
212 fi
213 fi
214 fi
215fi
216
217if test $USENSL != yes; then
218 LIBS="$LIBS $NETLIBS"
219 AC_TRY_LINK_FUNC(inet_addr, [ : ],
220 [
221 AC_CHECK_LIB(nsl,inet_addr,result=yes,result=no)
222 if test $result = yes; then
223 NETLIBS="$NETLIBS -lnsl"
224 fi
225 ])
226fi
227
228LIBS="$saveLIBS"
229AC_SUBST(NETLIBS)
230
231dnl #########################################################################
232
233dnl Prepare authuserdb module if userdb library is available
234
235dnl #########################################################################
236
237
238AC_ARG_WITH(db, [ --with-db=gdbm Use the GDBM library.
239 --with-db=db Use the libdb.a library.],
240 db="$withval", needs_withdb=1)
241
242case "$db" in
243gdbm)
244 ;;
245db)
246 ;;
247"")
248 ;;
249*)
250 AC_MSG_ERROR(Invalid --with-db option.)
251 ;;
252esac
253
254saveLIBS="$LIBS"
255
256if test "$db" != "db"
257then
258 AC_CHECK_LIB(gdbm, gdbm_open,
259 [ LIBGDBM=-lgdbm ; LIBS="-lgdbm $LIBS" ])
260 AC_CHECK_FUNC(gdbm_open, [ HAVE_GDBM=y ])
261fi
262
263LIBS="$saveLIBS"
264
265if test "$db" != "gdbm"
266then
267 AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
268 [ AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
269 [ AC_CHECK_LIB(db, db_env_create,
270 [ LIBDB=-ldb; LIBS="-ldb $LIBS"]) ]
271 )])
272
273 AC_CHECK_FUNC(dbopen, HAVE_BDB=1)
274 AC_CHECK_FUNC(db_open, HAVE_BDB=1)
275 AC_CHECK_FUNC(db_env_create, HAVE_BDB=1)
276fi
277
278LIBS="$saveLIBS"
279
280if test "$HAVE_GDBM$HAVE_BDB" = ""
281then
282 AC_MSG_ERROR(Cannot find either the gdbm or the db library.)
283fi
284
285USE_GDBM=0
286USE_DB=0
287
288if test "$HAVE_GDBM" = "y"
289then
290 LIBDB=""
291 USE_GDBM=1
292 DBSUBDIR=gdbmobj
293 if test "$needs_withdb" = 1
294 then
295 ac_configure_args="$ac_configure_args --with-db=gdbm"
296 fi
297 dblibrary=gdbmobj/libgdbmobj.la
298else
299 LIBGDBM=""
300 USE_DB=1
301 DBSUBDIR=bdbobj
302 if test "$needs_withdb" = 1
303 then
304 ac_configure_args="$ac_configure_args --with-db=db"
305 fi
306 dblibrary=bdbobj/libbdbobj.la
307fi
308
309AC_SUBST(DBSUBDIR)
310AC_SUBST(USE_GDBM)
311AC_SUBST(USE_DB)
312AC_SUBST(LIBDB)
313AC_SUBST(LIBGDBM)
314
315AC_ARG_WITH(authuserdb,
316[ --without-authuserdb Do not include the authuserdb module ],
317 doauthuserdb="$withval",
318 doauthuserdb="no"
319 if test -d ${srcdir}/userdb
320 then
321 doauthuserdb="yes"
322 fi)
323
324if test "$doauthuserdb" = "no"
325then
326 AUTHUSERDB=""
327else
328 AUTHUSERDB="authuserdb"
329 LIBAUTHUSERDB="libauthuserdb.la"
330
331fi
332
333AC_ARG_WITH(makedatprog, [ ], [ : ],
334 [
335 ac_configure_args="$ac_configure_args --with-makedatprog=$libexecdir/courier-authlib/makedatprog"
336 ])
337
338cat >dbobj.config <<EOF
339LIBDB=$LIBDB
340LIBGDBM=$LIBGDBM
341dblibrary=$dblibrary
342EOF
343
344AC_SUBST(USE_GDBM)
345AC_SUBST(USE_DB)
346
347AC_SUBST(dblibrary)
348AC_SUBST(LIBGDBM)
349AC_SUBST(LIBDB)
350AC_SUBST(LIBAUTHUSERDB)
351
352userdb="$pkgconfdir/userdb"
353AC_ARG_WITH(userdb, [], [ userdb="$withval" ], [ac_configure_args="$ac_configure_args '--with-userdb=$userdb'"])
354
355AC_DEFINE_UNQUOTED(USERDB,"$userdb", [ Location of the userdb database ])
356AC_SUBST(userdb)
357
358dnl Checks for header files.
359dnl
360dnl Because autoconf sets macros for C preprocessor where
361dnl AC_CHECK_HEADERS appears first, the first AC_CHECK_HEADERS
362dnl must not place in conditional level but top level.
363dnl This is a dummy AC_CHECK_HEADERS for it.
364dnl
365AC_CHECK_HEADERS(stdio.h)
366
367dnl #########################################################################
368
369dnl Prepare authpam module if libpam is available.
370
371dnl #########################################################################
372
373AC_ARG_WITH(authpam,
374[ --without-authpam Do not include the authpam module ],
375 doauthpam="$withval")
376
377AC_CHECK_HEADERS(security/pam_appl.h Pam/pam_appl.h)
378if test "$doauthpam" = "no"
379then
380 LIBDL=""
381else
382 saveLIBS="$LIBS"
383 LIBDL=""
384 AC_CHECK_LIB(dl, dlopen, [ LIBDL="-ldl" ])
385 LIBS="$saveLIBS"
386
387 AC_CHECK_LIB(pam, pam_start,
388 [ HAVE_PAM=1
389 LIBS="-lpam $LIBDL $LIBS"
390 AC_CHECK_FUNCS(pam_setcred)],
391
392 HAVE_PAM=0,
393 $LIBDL)
394 LIBS="$saveLIBS"
395fi
396AC_SUBST(LIBDL)
397
398LIBAUTHPAM=""
399if test "$HAVE_PAM" = 1
400then
401 LIBAUTHPAM=libauthpam.la
402fi
403
404AC_ARG_WITH(authpam-libraries,
405[ --with-authpam-libraries="libs" Link 'libs' with authpam, this may be
406 required for FreeBSD 3.3],
407 authpamcrypt="$withval")
408
409AUTHPAMCRYPT="$authpamcrypt"
410AC_SUBST(AUTHPAMCRYPT)
411AC_SUBST(LIBAUTHPAM)
412
413dnl #########################################################################
414
415dnl Prepare authldap module if ldap functions are available.
416
417dnl #########################################################################
418
419AC_ARG_WITH(authldap,
420[ --without-authldap Do not include the authldap module ],
421 doauthldap="$withval",
422 doauthldap="yes")
423
424AC_CHECK_HEADERS(lber.h)
425AC_CHECK_HEADERS(ldap.h)
426AC_CHECK_HEADERS(netinet/in.h)
427
428if test "$doauthldap" = "no"
429then
430 HAVE_LDAP=0
431else
432 saveLIBS="$LIBS"
433 LIBS="$NETLIBS $LIBS"
434 LDAPLIBS=""
435
436 AC_MSG_CHECKING(whether -lresolv is needed for res_query)
437 AC_LINK_IFELSE(AC_LANG_PROGRAM([
438#include <sys/types.h>
439#if HAVE_NETINET_IN_H
440#include <netinet/in.h>
441#endif
442#include <resolv.h>
443
444void (*func)()= (void (*)())res_query;
445],
446 [ (*func)(); ]),
447 AC_MSG_RESULT(no),
448 [
449 LIBS="-lresolv $LIBS"
450
451 AC_LINK_IFELSE(AC_LANG_PROGRAM([
452#include <sys/types.h>
453#if HAVE_NETINET_IN_H
454#include <netinet/in.h>
455#endif
456#include <resolv.h>
457
458void (*func)()= (void (*)())res_query;
459],
460 [ (*func)(); ]), [
461 LDAPLIBS="-lresolv $LDAPLIBS"
462 HAVE_LDAP=1
463 AC_MSG_RESULT(yes)
464 ],
465 AC_MSG_ERROR(Cannot find function res_query))
466 ])
467
468 AC_CHECK_LIB(lber, ber_scanf,
469 [ LDAPLIBS="-llber $LDAPLIBS" LIBS="-llber $LIBS" ])
470 AC_CHECK_LIB(ldap, ldap_open,
471 [ LDAPLIBS="-lldap $LDAPLIBS" ; LIBS="-lldap $LIBS" ])
472 AC_CHECK_FUNC(ldap_search_st, HAVE_LDAP=1, HAVE_LDAP=0)
473 AC_CHECK_FUNC(ldap_start_tls_s, HAVE_LDAP_TLS=1, HAVE_LDAP_TLS=0)
474 AC_CHECK_FUNC(ldap_result2error, HAVE_LDAP_RESULT2ERROR=1, HAVE_LDAP_RESULT2ERROR=0)
475 AC_CHECK_FUNC(ldap_parse_result, HAVE_LDAP_PARSE_RESULT=1, HAVE_LDAP_PARSE_RESULT=0)
476 LIBS="$saveLIBS"
477fi
478
479AC_ARG_WITH(authldaprc,
480[ --with-authldaprc=filename Expect to find authldaprc here ],
481 authldaprc="$withval",
482 authldaprc="$pkgconfdir/authldaprc")
483AC_SUBST(authldaprc)
484
485LIBAUTHLDAP=""
486if test "$HAVE_LDAP" = 1
487then
488 LIBAUTHLDAP="libauthldap.la"
489else
490 authldaprc=""
491fi
492AC_SUBST(LDAPLIBS)
493AC_SUBST(LIBAUTHLDAP)
494
495AM_CONDITIONAL(HAVE_LDAP, test "$HAVE_LDAP" = 1)
496AC_DEFINE_UNQUOTED(HAVE_LDAP_TLS,$HAVE_LDAP_TLS,
497 [ Whether we have ldap_start_tls_s ])
498AC_DEFINE_UNQUOTED(HAVE_LDAP_RESULT2ERROR, $HAVE_LDAP_RESULT2ERROR,
499 [ Whether we have ldap_result2error() function ])
500AC_DEFINE_UNQUOTED(HAVE_LDAP_PARSE_RESULT, $HAVE_LDAP_PARSE_RESULT,
501 [ Whether we have ldap_parse_result() function])
502dnl #########################################################################
503
504dnl Prepare authpwd module
505
506dnl #########################################################################
507
508AC_ARG_WITH(authpwd,
509[ --without-authpwd Do not include the authpwd module ],
510 doauthpwd="$withval",
511 doauthpwd="yes"
512 test "$HAVE_PAM" = 1 && doauthpwd="no"
513 test "$HAVE_LDAP" = 1 && doauthpwd="no"
514 )
515
516HAVE_PWD=1
517if test "$doauthpwd" = "no"
518then
519 HAVE_PWD=0
520fi
521AC_CHECK_FUNCS(endpwent)
522
523dnl #########################################################################
524
525dnl Prepare authshadow module if shadow functions are available.
526
527dnl #########################################################################
528
529AC_ARG_WITH(authshadow,
530[ --without-authshadow Do not include the authshadow module ],
531 doauthshadow="$withval",
532 doauthshadow="yes"
533 test "$HAVE_PAM" = 1 && doauthshadow="no"
534 test "$HAVE_LDAP" = 1 && doauthshadow="no")
535
536AC_CHECK_HEADERS(shadow.h)
537saveLIBS="$LIBS"
538SHADOWLIBS=""
539AC_CHECK_LIB(shadow, getspent,
540 [ SHADOWLIBS="-lshadow" ; LIBS="-lshadow $LIBS" ])
541AC_CHECK_FUNCS(endspent getspent)
542LIBS="$saveLIBS"
543
544if test "$doauthshadow" = "no"
545then
546 HAVE_SHADOW=0
547else
548
549 saveLIBS="$LIBS"
550 AC_CHECK_LIB(shadow, getspent)
551 AC_CHECK_FUNC(getspent, HAVE_SHADOW=1, HAVE_SHADOW=0)
552 LIBS="$saveLIBS"
553fi
554
555LIBAUTHSHADOW=""
556if test "$HAVE_SHADOW" = 1
557then
558 LIBAUTHSHADOW="libauthshadow.la"
559fi
560AC_SUBST(SHADOWLIBS)
561AC_SUBST(LIBAUTHSHADOW)
562
563LIBAUTHPWD=""
564if test "$HAVE_PWD" = 1
565then
566 LIBAUTHPWD="libauthpwd.la"
567fi
568AC_SUBST(LIBAUTHPWD)
569
570dnl #########################################################################
571
572dnl Prepare authvchkpw module if vchkpw is installed.
573
574dnl #########################################################################
575
576changequote(<<,>>)
577
578vpopmail_home=`$PERL -e '@a=getpwnam("vpopmail"); print "$a[7]";'`
579
580changequote([,])
581
582AC_ARG_WITH(authvchkpw,
583[ --without-authvchkpw Do not include the authvchkpw module ],
584 doauthvchkpw="$withval",
585 doauthvchkpw=no
586 if test "$vpopmail_home" != ""
587 then
588 doauthvchkpw=yes
589 fi)
590
591if test "$doauthvchkpw" = "no"
592then
593 HAVE_VCHKPW=0
594 vpopmail_home=.
595else
596 HAVE_VCHKPW=1
597
598
599 cat <<EOF
600----------------------------------------------------
601 NOTE
602
603
604All questions regarding ANY vpopmail-related problems,
605such as compiling/building failures, or login errors
606should be referred to the vpopmail mailing list.
607Vpopmail questions sent to the Courier mailing lists
608will be IGNORED.
609----------------------------------------------------
610\a
611EOF
612 sleep 5
613
614 if test -f ${vpopmail_home}/etc/lib_deps
615 then
616 CFLAGS="`cat ${vpopmail_home}/etc/inc_deps` $CFLAGS"
617 VPOPMAILLIBS="`cat ${vpopmail_home}/etc/lib_deps`"
618 else
619 AC_MSG_ERROR(${vpopmail_home}/etc/lib_deps does not exist - upgrade vpopmail to the current version or fix the permissions on this file)
620 fi
621fi
622AC_SUBST(vpopmail_home)
623AC_SUBST(VPOPMAILLIBS)
624
625LIBAUTHVCHKPW=""
626if test "$HAVE_VCHKPW" = 1
627then
628 LIBAUTHVCHKPW="libauthvchkpw.la"
629 HAVE_VCHKPW="1"
630
631dnl Check if vpopmail has open_smtp_relay() function
632
633 _SAVE_LIBS=$LIBS
634 LIBS="$VPOPMAILLIBS $CRYPTLIBS $LIBS"
635 AC_CHECK_FUNC(open_smtp_relay,
636 AC_DEFINE(HAVE_OPEN_SMTP_RELAY, 1,
637 [ Whether -lvpopmail has the open_smtp_relay() function ]) )
638 AC_CHECK_FUNC(vset_lastauth,
639 AC_DEFINE(HAVE_VSET_LASTAUTH, 1,
640 [ Whether -lvpopmail has the vset_lastauth() function ]))
641 LIBS=$_SAVE_LIBS
642fi
643
644AC_SUBST(LIBAUTHVCHKPW)
645
646dnl #########################################################################
647
648dnl Prepare authpgsql module
649
650dnl #########################################################################
651
652AC_ARG_WITH(authpgsqlrc,
653[ --with-authpgsqlrc=filename Expect to find authpgsql here ],
654 authpgsqlrc="$withval",
655 authpgsqlrc="$pkgconfdir/authpgsqlrc")
656AC_SUBST(authpgsqlrc)
657
658AC_ARG_WITH(authpgsql,
659[ --without-authpgsql Do not include the authpgsql module ],
660 doauthpgsql="$withval")
661
662AC_PATH_PROGS(PG_CONFIG, pg_config, pg_config, $LPATH)
663
664PGSQL_LIBS="-lpq"
665AC_ARG_WITH(pgsql-libs,
666[ --with-pgsql-libs=DIR Look for pgsql libs in this dir ],
667 PGSQL_LIBS="-L$withval $PGSQL_LIBS",
668 if test -x $PG_CONFIG
669 then
670 PGSQL_LIBS="-L`$PG_CONFIG --libdir` $PGSQL_LIBS"
671 fi
672)
673AC_ARG_WITH(pgsql-includes,
674[ --with-pgsql-includes=DIR Look for pgsql includes in this dir ],
675 PGSQL_CFLAGS="-I$withval",
676 if test -x $PG_CONFIG
677 then
678 PGSQL_CFLAGS="-I`$PG_CONFIG --includedir`"
679 fi
680)
681
682if test "$doauthpgsql" = ""
683then
684 LIBS="$PGSQL_LIBS $LIBS"
685 AC_CHECK_FUNC(PQsetdbLogin,
686 doauthpgsql="yes"
687 )
688 LIBS="$saveLIBS"
689fi
690
691if test "$doauthpgsql" != "yes"
692then
693 LIBAUTHPGSQL=""
694 HAVE_AUTHPGSQL=0
695else
696 saveLIBS="$LIBS"
697 LIBS="$PGSQL_LIBS $LIBS"
698 AC_CHECK_FUNC(PQsetdbLogin,
699 AUTHPGSQL="authpgsql"
700 HAVE_AUTHPGSQL=1,
701 AC_MSG_ERROR([--with-authpgsql specified but no libpq.so]))
702 LIBS="$saveLIBS"
703 HAVE_AUTHPGSQL=1
704 CFLAGS="$PGSQL_CFLAGS $CFLAGS"
705 LIBAUTHPGSQL="libauthpgsql.la"
706fi
707
708AC_SUBST(PGSQL_LIBS)
709AC_SUBST(LIBAUTHPGSQL)
710AM_CONDITIONAL(HAVE_AUTHPGSQL, test "$HAVE_AUTHPGSQL" = 1)
711
712dnl #########################################################################
713
714dnl Prepare authmysql module
715
716dnl #########################################################################
717
718AC_ARG_WITH(authmysqlrc,
719[ --with-authmysqlrc=filename Expect to find authmysql here ],
720 authmysqlrc="$withval",
721 authmysqlrc="$pkgconfdir/authmysqlrc")
722AC_SUBST(authmysqlrc)
723
724AC_ARG_WITH(authmysql,
725[ --without-authmysql Do not include the authmysql module ],
726 doauthmysql="$withval")
727AC_ARG_WITH(mysql-libs,
728[ --with-mysql-libs=DIR Look for mysql libs in this dir ],
729 MYSQL_LIBS="-L$withval -lmysqlclient"
730)
731AC_ARG_WITH(mysql-includes,
732[ --with-mysql-includes=DIR Look for mysql includes in this dir ],
733 MYSQL_CFLAGS="-I$withval"
734)
735
736AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, mysql_config, $LPATH)
737
738if test -x "$MYSQL_CONFIG"
739then
740 MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
741 MYSQL_LIBS="`$MYSQL_CONFIG --libs`"
742
743 eval "MYSQL_CFLAGS=\"\`echo $MYSQL_CFLAGS\`\""
744 eval "MYSQL_LIBS=\"\`echo $MYSQL_LIBS\`\""
745fi
746
747if test "$doauthmysql" = ""
748then
749 LIBS="$MYSQL_LIBS $LIBS"
750 AC_CHECK_FUNC(mysql_connect,
751 doauthmysql="yes"
752 )
753 AC_CHECK_FUNC(mysql_real_connect,
754 doauthmysql="yes"
755 )
756 LIBS="$saveLIBS"
757fi
758
759if test "$doauthmysql" != "yes"
760then
761 LIBAUTHMYSQL=""
762 HAVE_AUTHMYSQL=0
763else
764 saveLIBS="$LIBS"
765 LIBS="$MYSQL_LIBS $LIBS"
766 AC_CHECK_FUNC(mysql_connect,
767 LIBAUTHMYSQL="libauthmysql.la"
768 HAVE_AUTHMYSQL=1,
769 [
770 AC_CHECK_FUNC(mysql_real_connect,
771 LIBAUTHMYSQL="libauthmysql.la"
772 HAVE_AUTHMYSQL=1,
773
774 AC_MSG_ERROR([--with-authmysql specified but no mysqlclient.so])
775 )
776 ]
777)
778 LIBS="$saveLIBS"
779 HAVE_AUTHMYSQL=1
780 CFLAGS="$MYSQL_CFLAGS $CFLAGS"
781fi
782AC_SUBST(LIBAUTHMYSQL)
783AC_SUBST(MYSQL_LIBS)
784AM_CONDITIONAL(HAVE_AUTHMYSQL, test "$HAVE_AUTHMYSQL" = 1)
785
786
787dnl #########################################################################
788
789dnl Prepare authcustom stub module.
790
791dnl #########################################################################
792
793
794AC_ARG_WITH(authcustom,
795[ --without-authcustom Do not include the authcustom module ],
796 doauthcustom="$withval",
797 doauthcustom=yes)
798
799LIBAUTHCUSTOM=""
800
801if test "$doauthcustom" = "yes"
802then
803 LIBAUTHCUSTOM="libauthcustom.la"
804fi
805
806AM_CONDITIONAL(HAVE_CUSTOM, test "$AUTHCUSTOM" != "")
807AC_SUBST(LIBAUTHCUSTOM)
808
809
810dnl #########################################################################
811
812dnl Prepare authpipe module.
813
814dnl #########################################################################
815
816
817AC_ARG_WITH(pipeprog,
818[ --with-pipeprog=filename Expect to find the pipe-prog here ],
819 authProg="$withval",
820 authProg="$pkgconfdir/authProg")
821AC_SUBST(authProg)
822
823AC_ARG_WITH(authpipe,
824[ --without-authpipe Do not include the authpipe module ],
825 doauthpipe="$withval",
826 doauthpipe=yes)
827
828LIBAUTHPIPE=""
829
830if test "$doauthpipe" = "yes"
831then
832 LIBAUTHPIPE="libauthpipe.la"
833fi
834
835AM_CONDITIONAL(HAVE_PIPE, test "$AUTHPIPE" != "")
836AC_SUBST(LIBAUTHPIPE)
837
838
839
840dnl Checks for header files.
841AC_HEADER_STDC
842AC_HEADER_SYS_WAIT
843AC_CHECK_HEADERS(sys/stat.h sys/time.h sys/wait.h sys/select.h unistd.h fcntl.h crypt.h termios.h)
844
845dnl Checks for typedefs, structures, and compiler characteristics.
846AC_C_CONST
847AC_PID_T
848AC_TYPE_UID_T
849AC_TYPE_SIGNAL
850
851dnl Other checks
852AC_CHECK_FUNCS(setsid setlogin)
853AC_CHECK_LIB(crypt, crypt, CRYPTLIBS="-lcrypt")
854saveLIBS="$LIBS"
855LIBS="$CRYPTLIBS $LIBS"
856AC_CHECK_FUNC(crypt, AC_DEFINE_UNQUOTED(HAVE_CRYPT, 1,
857 [ Whether we have the crypt() function ]))
858LIBS="$saveLIBS"
859AC_CACHE_CHECK([for crypt() prototype],userdb_cv_NEED_CRYPT_PROTOTYPE,
860
861 AC_TRY_COMPILE( [
862 #if HAVE_CRYPT_H
863 #include <crypt.h>
864 #endif
865 #if HAVE_UNISTD_H
866 #include <unistd.h>
867 #endif
868 int crypt(int, int);
869
870 ], [], userdb_cv_NEED_CRYPT_PROTOTYPE=1,
871 userdb_cv_NEED_CRYPT_PROTOTYPE=0 )
872
873 )
874
875AC_DEFINE_UNQUOTED(NEED_CRYPT_PROTOTYPE, $userdb_cv_NEED_CRYPT_PROTOTYPE,
876 [ Whether we must a prototype for crypt()] )
877AC_SUBST(CRYPTLIBS)
878
879dnl #########################################################################
880
881dnl Prepare the authdaemon module.
882
883dnl #########################################################################
884
885AC_ARG_WITH(authdaemonrc,
886[ --with-authdaemonrc=filename Expect to find authdaemonrc here ],
887 authdaemonrc="$withval",
888 authdaemonrc="$pkgconfdir/authdaemonrc")
889AC_SUBST(authdaemonrc)
890
891AC_ARG_WITH(authdaemonvar,
892[ --with-authdaemonvar=directory Directory where authdaemon.pid and
893 the listening socket is created],
894 authdaemonvar="$withval",
895 authdaemonvar="$localstatedir/spool/authdaemon")
896
897AC_SUBST(authdaemonvar)
898
899AC_SUBST(LIBM)
900
901AC_DEFINE_UNQUOTED(SASL_LIST,$SASL_LIST,
902 [ This macro is used to build the list of SASL modules ])
903
904rm -f authdaemonrc.h authldaprc.h authmysqlrc.h authpgsqlrc.h vpopmail_config.h
905
906
907dnl
908dnl Need to settle on our uid/gids here
909dnl
910
911result=""
912
913if test -x "$COURIERCONFIG"
914then
915 $COURIERCONFIG >conftest.out || exit 1
916 sed -n '/^mail/p' <conftest.out >conftest2.out || exit 1
917 . conftest2.out
918 rm -f conftest.out conftest2.out
919
920 cmailuser="$mailuser"
921 cmailgroup="$mailgroup"
922 result=" (from courier-config)"
923fi
924
925if test -x "$bindir/courierauthconfig"
926then
927 $bindir/courierauthconfig --configfiles >conftest.out || exit 1
928 sed -n '/^mail/p' <conftest.out >conftest2.out || exit 1
929 . conftest2.out
930 rm -f conftest.out conftest2.out
931
932 cmailuser="$mailuser"
933 cmailgroup="$mailgroup"
934 result=" (from previous courierauthconfig)"
935fi
936
937changequote()
938
939LB='['
940RB=']'
941
942changequote([,])
943
944AC_MSG_CHECKING(for mail userid)
945
946AC_ARG_WITH(mailuser,[ --with-mailuser=user Specify mail user name (defaults to
947 courier, daemon, admin, bin, or root)],
948 mailuser="$withval",
949
950 if test "$cmailuser" = ""
951 then
952 AC_TRY_RUN([
953#include <stdio.h>
954#include <pwd.h>
955#include <stdlib.h>
956
957static const char *ids $LB $RB={"courier","daemon","adm","bin","root", 0};
958
959int main()
960{
961int i;
962FILE *f;
963char *p;
964
965 for (i=0; ids $LB i $RB; i++)
966 if (getpwnam(ids $LB i $RB)) break;
967
968 f=fopen("conftest.out", "w");
969 if (f && ids $LB i $RB)
970 {
971 fprintf(f, "%s\n", ids $LB i $RB);
972 fclose(f);
973 exit(0);
974 }
975 fclose(f);
976 exit (1);
977 return (1);
978}
979 ],
980 mailuser=`cat conftest.out`,
981 AC_MSG_ERROR(Cannot determine mail user, use --with-mailuser.),
982 AC_MSG_ERROR(Must use --with-mailuser when cross compiling.))
983 else
984 mailuser="$cmailuser"
985 fi
986 ac_configure_args="$ac_configure_args --with-mailuser=$mailuser")
987
988AC_MSG_RESULT([$mailuser $result])
989
990AC_MSG_CHECKING(for mail group id)
991
992AC_ARG_WITH(mailgroup, [ --with-mailgroup=group Specify mail group name (defaults to courier,
993 daemon, sys, adm, or root)],
994 mailgroup="$withval",
995
996 if test "$cmailgroup" = ""
997 then
998 AC_TRY_RUN([
999#include <stdio.h>
1000#include <grp.h>
1001#include <stdlib.h>
1002
1003static const char *ids $LB $RB={"courier", "daemon","sys","adm", "root", 0};
1004
1005int main()
1006{
1007int i;
1008FILE *f;
1009
1010 for (i=0; ids $LB i $RB; i++)
1011 if (getgrnam(ids $LB i $RB)) break;
1012
1013 f=fopen("conftest.out", "w");
1014 if (f && ids $LB i $RB)
1015 {
1016 fprintf(f, "%s\n", ids $LB i $RB);
1017 fclose(f);
1018 exit(0);
1019 }
1020 fclose(f);
1021 exit (1);
1022 return (1);
1023}
1024 ],
1025
1026 mailgroup=`cat conftest.out`,
1027 AC_MSG_ERROR(Cannot determine mail group, use --with-mailgroup.),
1028 AC_MSG_ERROR(Must use --with-mailgroup when cross compiling.))
1029 else
1030 mailgroup="$cmailgroup"
1031 fi
1032 ac_configure_args="$ac_configure_args --with-mailgroup=$mailgroup"
1033 )
1034AC_MSG_RESULT([$mailgroup $result])
1035AC_SUBST(mailuser)
1036AC_SUBST(mailgroup)
1037rm -f conftest.out
1038
1039AC_ARG_WITH(stdheaderdir,
1040[ --without-stdheaderdir Header files will be installed into a directory
1041 not in the compiler's default search path.],
1042 [
1043 if test "$withval" = "no"
1044 then
1045 AC_DEFINE_UNQUOTED(HAVE_NOSTDHEADERDIR, 1,
1046 [ Whether header installation directory is nontstandard ])
1047 fi
1048 ])
1049
1050AC_CACHE_CHECK([for socklen_t],
1051 authlib_cv_hassocklen_t,
1052
1053AC_COMPILE_IFELSE(
1054AC_LANG_SOURCE( [
1055#include <sys/types.h>
1056#include <sys/socket.h>
1057
1058socklen_t sl_t;
1059],[
1060 accept(0, 0, &sl_t);
1061]),
1062 authlib_cv_hassocklen_t=yes,
1063 authlib_cv_hassocklen_t=no)
1064)
1065
1066socklen_t="int"
1067
1068if test $authlib_cv_hassocklen_t = yes
1069then
1070 :
1071else
1072 AC_DEFINE_UNQUOTED(socklen_t, int, [ Default definition for socklen_t ])
1073fi
1074
1075if test x"$enable_ltdl_install" = x"yes"
1076then
1077 LIBLTDL_SUBDIR=libltdl
1078fi
1079
1080AC_SUBST(LIBLTDL_SUBDIR)
1081
1082AC_ARG_WITH(repository, [], REPOSITORY="$withval")
1083AC_SUBST(REPOSITORY)
1084
1085AM_CONDITIONAL(HAVE_SGML, test -d ${srcdir}/docbook)
1086AC_CONFIG_SUBDIRS(libltdl bdbobj gdbmobj md5 sha1 libhmac numlib makedat userdb rfc822 random128 liblock liblog)
1087
1088AC_CONFIG_FILES(Makefile authdaemond authdaemonrc authsystem.passwd README.authdebug.html dbobj.h authmigrate courier-authlib.spec courier-authlib.lpspec courier-authlib.sysvinit userdb-test-cram-md5.pl)
1089AC_OUTPUT
1090