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