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