SASL support from Ken Hornstein <kenh@cmf.nrl.navy.mil>.
[mmh] / configure.in
1 dnl
2 dnl configure.in -- autoconf template for nmh
3 dnl
4 dnl $Id$
5 dnl
6
7 AC_INIT(h/nmh.h)
8 AC_CONFIG_HEADER(config.h)
9
10 AC_CANONICAL_SYSTEM
11
12 dnl ---------------------
13 dnl define a macro or two
14 dnl ---------------------
15
16 AC_DEFUN(NMH_PROG_GNU_LIBTOOL, [
17   tmptest=`$LIBTOOL --version 2>&1 | grep GNU`
18   if test x"$tmptest" != x  ; then
19     GNU_LIBTOOL=1
20     AC_SUBST(GNU_LIBTOOL)dnl
21   fi
22 ] )
23   
24
25 dnl What version of nmh are we building?
26 VERSION=`sed -e 's/nmh-//' ${srcdir}/VERSION`
27 echo "configuring for nmh-$VERSION"
28 AC_SUBST(VERSION)dnl
29
30 dnl --------------------------
31 dnl CHECK COMMAND LINE OPTIONS
32 dnl --------------------------
33
34 dnl Do you want client-side support for apop?
35 AC_ARG_ENABLE(apop,
36 [  --enable-apop           enable client-side support for POP3 and APOP])
37 if test x"$enable_apop" = x"yes"; then
38   AC_DEFINE(APOP)dnl
39   APOPLIB=md5.o
40   enable_pop=yes
41 fi
42 AC_SUBST(APOPLIB)dnl
43
44 dnl Do you want to debug nmh?
45 undefine([debug])dnl
46 AC_ARG_ENABLE(debug,
47 [  --enable-debug          enable nmh code debugging])
48 dnl The old redundant --enable-nmh-debug is deprecated and undocumented.
49 if test x"$enable_nmh_debug" = x"yes"; then
50   enable_debug=yes
51 fi
52
53 dnl Allow users to send email from addresses other than their default?
54 undefine([masquerade])dnl
55 AC_ARG_ENABLE(masquerade,
56   [  --enable-masquerade[='draft_from mmailid username_extension']
57                           enable up to 3 types of address masquerading [none]],
58   [if test x"$enable_masquerade" = x"yes"; then
59     masquerade="draft_from mmailid username_extension"
60   else
61     masquerade="$enable_masquerade"
62   fi])
63 AC_SUBST(masquerade)dnl
64
65 dnl Do you want mhe support?
66 undefine([mhe])dnl
67 AC_ARG_ENABLE(mhe,
68 [  --enable-mhe            enable mhe support (DEFAULT)])
69
70 dnl mhe support is on by default, so define it unless --disable-mhe or the
71 dnl deprecated, undocumented --disable-nmh-mhe are specified.
72 if test x"$enable_mhe" != x"no" -a x"$enable_nmh_mhe" != x"no"; then
73   AC_DEFINE(MHE)dnl
74 fi
75
76 dnl Do you want client-side support for pop?
77 undefine([pop])dnl
78 AC_ARG_ENABLE(pop,
79 [  --enable-pop            enable client-side support for plain POP3])
80 dnl The old redundant --enable-nmh-pop is deprecated and undocumented.
81 if test x"$enable_nmh_pop" = x"yes"; then
82   enable_pop=yes
83 fi
84
85 dnl Do you want support for hesiod
86 AC_ARG_WITH(hesiod,
87 [  --with-hesiod=PREFIX    specify location of Hesiod])
88 if test x"$with_hesiod" != x -a x"$with_hesiod" != x"no"; then
89   AC_DEFINE(HESIOD)dnl
90 fi
91
92 dnl Do you want client-side support for kpop
93 AC_ARG_WITH(krb4,
94 [  --with-krb4=PREFIX      specify location of Kerberos V4 for KPOP support])
95 if test x"$with_krb4" != x -a x"$with_krb4" != x"no"; then
96   enable_pop=yes
97   AC_DEFINE(KPOP)dnl
98   AC_DEFINE(KPOP_PRINCIPAL, "pop")dnl
99 fi
100
101 dnl After we know if we're including apop and kpop support, do pop stuff
102 if test x"$enable_pop" = x"yes"; then
103   AC_DEFINE(POP)dnl
104   POPLIB=popsbr.o
105   POPSED='/^%nmhbeginpop%/d;/^%nmhendpop%/d'
106 else
107   POPSED='/^%nmhbeginpop%/,/^%nmhendpop%/d'
108 fi
109 AC_SUBST(POPLIB)dnl
110 AC_SUBST(POPSED)dnl
111
112 dnl What should be the default editor?
113 undefine([editor])dnl
114 AC_ARG_WITH(editor,
115 [  --with-editor=EDITOR    specify the default editor])
116
117 if test -n "$with_editor"; then
118   editorpath="$with_editor"
119 fi
120
121 dnl Do you want client-side support for using SASL for authentication?
122 dnl Note that this code will be enabled for both POP and SMTP
123 AC_ARG_WITH(cyrus-sasl,
124 [  --with-cyrus-sasl=<dir> Specify location of Cyrus SASL library for auth])
125 if test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != "no"; then
126   AC_DEFINE(CYRUS_SASL)dnl
127 fi
128
129 dnl What method of posting should post use?
130 undefine([mts])dnl
131 AC_ARG_WITH(mts,
132 [  --with-mts=MTS          specify the default mail transport agent/service])
133
134 if test x"$with_mts" = x"smtp"; then
135   MTS="smtp"
136 elif test x"$with_mts" = x"sendmail"; then
137   MTS="sendmail"
138 else
139   MTS="smtp"
140 fi
141 AC_SUBST(MTS)dnl
142
143 dnl Both the smtp and sendmail mail transport services use the smtp code
144 AC_DEFINE(SMTPMTS)dnl
145
146 dnl What should be the default pager?
147 undefine([pager])dnl
148 AC_ARG_WITH(pager,
149 [  --with-pager=PAGER      specify the default pager])
150
151 if test -n "$with_pager"; then
152   pagerpath="$with_pager"
153 fi
154
155 dnl What should be the default mail server(s)?
156 undefine([smtpservers])dnl
157 AC_ARG_WITH(smtpservers,
158 [  --with-smtpservers='SMTPSERVER1[ SMTPSERVER2...]'
159                           specify the default SMTP server(s) [localhost]])
160 if test -n "$with_smtpservers"; then
161   smtpservers="$with_smtpservers"
162 else
163   smtpservers="localhost"
164 fi
165 AC_SUBST(smtpservers)dnl
166
167 dnl ----------------------------------------------------
168 dnl Default location is /usr/local/nmh/{bin,etc,lib,man}
169 dnl ----------------------------------------------------
170 AC_PREFIX_DEFAULT(/usr/local/nmh)
171
172 dnl ------------------
173 dnl CHECK THE COMPILER
174 dnl ------------------
175 dnl We want these before the checks,
176 dnl so the checks can modify their values.
177 test -z "$CFLAGS" && CFLAGS= auto_cflags=1
178 if test x"$enable_debug" = x"yes"; then
179   test -z "$LDFLAGS" && LDFLAGS=-g
180 fi
181
182 AC_PROG_CC
183
184 dnl if the user hasn't specified CFLAGS, then
185 dnl   if compiler is gcc, then
186 dnl     use -O2 and some warning flags
187 dnl   else use -O
188 if test -n "$auto_cflags"; then
189   if test x"$enable_debug" = x"yes"; then
190     if test -n "$GCC"; then
191       test -z "$CFLAGS" && CFLAGS="-Wall -g" || CFLAGS="$CFLAGS -Wall -g"
192     else
193       test -z "$CFLAGS" && CFLAGS=-g || CFLAGS="$CFLAGS -g"
194     fi
195   else
196     test -z "$LDFLAGS" && LDFLAGS=-s
197     if test -n "$GCC"; then
198       test -z "$CFLAGS" && CFLAGS="-Wall -O2" || CFLAGS="$CFLAGS -Wall -O2"
199     else
200       test -z "$CFLAGS" && CFLAGS=-O  || CFLAGS="$CFLAGS -O"
201     fi
202   fi
203 fi
204
205 AC_C_CONST              dnl Does compiler support `const'.
206
207 dnl ------------------
208 dnl CHECK FOR PROGRAMS
209 dnl ------------------
210 AC_PROG_MAKE_SET        dnl Does make define $MAKE
211 AC_PROG_INSTALL         dnl Check for BSD compatible `install'
212 AC_PROG_RANLIB          dnl Check for `ranlib'
213 AC_PROG_AWK             dnl Check for mawk,gawk,nawk, then awk
214 AC_PROG_LEX             dnl Check for lex/flex
215
216 dnl Look for `cut'
217 pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
218 AC_PATH_PROG(cutpath, cut, no, [$pathtmp])
219
220 dnl ----------------------------------------------
221 dnl check for lclint, and lint if it doesn't exist
222 dnl ----------------------------------------------
223 AC_CHECK_PROG(linttmp1, lclint, lclint, no)dnl
224 if test x$ac_cv_prog_linttmp1 != xno ; then
225   LINT=$ac_cv_prog_linttmp1
226   LINTFLAGS="-weak +posixlib -macrovarprefixexclude"
227 else
228   AC_CHECK_PROG(linttmp2, lint, lint, no)dnl
229   if test x$ac_cv_prog_linttmp2 != xno ; then
230     LINT=$ac_cv_prog_linttmp2
231     LINTFLAGS=""
232   else
233     LINT="echo 'No lint program found'"
234     LINTFLAGS=""
235   fi
236 fi
237 AC_SUBST(LINT)
238 AC_SUBST(LINTFLAGS)
239
240 dnl try to figure out which one we've got
241 AC_CHECK_PROG(LIBTOOL, libtool, libtool, , [$pathtmp])
242 NMH_PROG_GNU_LIBTOOL
243
244 dnl Check for lorder and tsort commands
245 AC_CHECK_PROG(LORDER, lorder, lorder, no)dnl
246 AC_CHECK_PROG(TSORT, tsort, tsort, no)dnl
247
248 dnl If either doesn't exist, replace them with echo and cat
249 if test x$ac_cv_prog_LORDER != xlorder -o x$ac_cv_prog_TSORT != xtsort; then
250   LORDER=echo
251   TSORT=cat
252   AC_SUBST(LORDER)dnl
253   AC_SUBST(TSORT)dnl
254 dnl Mac OS X has lorder, but sh is too broken for it to work
255 dnl elif test -z "`lorder config/config.c 2>&1 | grep config/config.c`" ; then
256 dnl   LORDER=echo
257 dnl   TSORT=cat
258 dnl   AC_SUBST(LORDER)dnl
259 dnl   AC_SUBST(TSORT)dnl
260 fi
261
262 dnl Check whether tsort can deal with loops
263 AC_CACHE_CHECK(whether tsort can deal with loops, nmh_cv_tsort_loop,
264   [if test -z "`echo a b b a | tsort 2>/dev/null | grep a`" ; then
265     nmh_cv_tsort_loop=no
266   else
267     nmh_cv_tsort_loop=yes
268   fi])
269 if test x$nmh_cv_tsort_loop = xno ; then
270   LORDER=echo
271   TSORT=cat
272   AC_SUBST(LORDER)dnl
273   AC_SUBST(TSORT)dnl
274 fi
275
276 dnl Look for `ls'
277 pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
278 AC_PATH_PROG(lspath, ls, no, [$pathtmp])
279
280 dnl See how we get ls to display the owner and the group
281 if test "$lspath" != "no"; then
282   AC_CACHE_CHECK(how to get ls to show us the group ownership of a file, 
283                  nmh_cv_ls_grpopt,
284   [if test x"`$lspath -dl / | $AWK '{print $9}'`" = x"/"; then
285     dnl There were 9 parameters, so unless this is a really bizarre, nonstandard
286     dnl ls, it would seem -l gave us both the user and group.  On this type of
287     dnl ls, -g makes _only_ the group be displayed (and not the user).
288     nmh_cv_ls_grpopt="-l"
289   else
290     dnl Looks like -l only gave us the user, so we need -g to get the group too.
291     nmh_cv_ls_grpopt="-lg"
292   fi])
293 fi
294
295 dnl Look for `more'
296 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
297 AC_PATH_PROG(morepath, more, no, [$pathtmp])
298
299 dnl If pager is not specified yet,
300 dnl then use `more' as the default.
301 if test -z "$pagerpath"; then
302   pagerpath="$morepath"
303 fi
304 AC_SUBST(pagerpath)dnl
305
306 dnl Look for `sendmail'
307 pathtmp=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin:/bin
308 AC_PATH_PROG(sendmailpath, sendmail, no, [$pathtmp])
309
310 dnl Look for `vi'
311 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
312 AC_PATH_PROG(vipath, vi, no, [$pathtmp])
313
314 dnl If editor is not specified yet,
315 dnl then use `vi' as the default.
316 if test -z "$editorpath"; then
317   editorpath="$vipath"
318 fi
319 AC_SUBST(editorpath)dnl
320
321 dnl Check for broken vi
322 AC_CACHE_CHECK(for broken vi, nmh_cv_attvibug,
323 [if echo 'r /nonexist-file
324 q' | ex > /dev/null 2>&1
325 then
326         nmh_cv_attvibug=no
327 else
328         nmh_cv_attvibug=yes
329 fi])
330  
331 if test "$nmh_cv_attvibug" = yes; then
332   AC_DEFINE(ATTVIBUG)dnl
333 fi
334
335 dnl ----------------------------------------------------------
336 dnl FIND MAIL SPOOL AND SEE IF WE NEED TO MAKE inc SETGID MAIL
337 dnl ----------------------------------------------------------
338 AC_CACHE_CHECK(where mail spool is located, nmh_cv_mailspool,
339 [for mailspool in /var/mail        dnl
340                   /var/spool/mail  dnl
341                   /usr/spool/mail  dnl
342                   /dev/null;       dnl Just in case we fall through
343 do
344   test -d $mailspool && break
345 done
346 nmh_cv_mailspool=$mailspool
347 ])
348 mailspool=$nmh_cv_mailspool
349 AC_SUBST(mailspool)dnl
350
351 dnl See whether the mail spool directory is world-writable.
352 if test "$lspath" != "no" -a "$cutpath" != "no"; then
353   AC_CACHE_CHECK(whether the mail spool is world-writable, 
354                  nmh_cv_mailspool_world_writable,
355   [if test "`$lspath -dlL $mailspool | $cutpath -c9`" = "-"; then
356     nmh_cv_mailspool_world_writable=no
357   else
358     nmh_cv_mailspool_world_writable=yes
359   fi])
360 fi
361
362 dnl Also, check for liblockfile (as found on Debian systems)
363 AC_CHECK_HEADER(lockfile.h, AC_CHECK_LIB(lockfile, lockfile_create) )
364
365 dnl and whether its companion program dotlockfile is setgid
366 AC_PATH_PROG(dotlockfilepath, dotlockfile, no)
367 if test "$ac_cv_lib_lockfile_lockfile_create" != "no" ; then
368   if test "$ac_cv_path_dotlockfilepath" != "no" ; then
369     AC_CACHE_CHECK(whether dotlockfile is setgid, nmh_cv_dotlockfile_setgid,
370     [ if test -g "$ac_cv_path_dotlockfilepath" ; then
371         nmh_cv_dotlockfile_setgid=yes
372       else
373         nmh_cv_dotlockfile_setgid=no
374       fi])
375   fi
376 fi
377
378 dnl If mailspool is not world-writable and dotlockfile is not setgid,
379 dnl we need to #define MAILGROUP to 1 and make inc setgid.
380 if test x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then
381   dnl do we really need both of these?
382   AC_DEFINE(MAILGROUP)dnl
383   SETGID_MAIL=1
384 fi
385 AC_SUBST(SETGID_MAIL)dnl
386
387 dnl Use ls to see which group owns the mail spool directory.
388 AC_CACHE_CHECK(what group owns the mail spool, nmh_cv_ls_mail_grp,
389 [nmh_cv_ls_mail_grp=`$lspath -dL $nmh_cv_ls_grpopt $mailspool|$AWK '{print $4}'`
390 ])
391 MAIL_SPOOL_GRP=$nmh_cv_ls_mail_grp
392 AC_SUBST(MAIL_SPOOL_GRP)dnl
393
394 dnl ------------------
395 dnl CHECK HEADER FILES
396 dnl ------------------
397 AC_HEADER_DIRENT
398 AC_HEADER_STDC
399 AC_HEADER_TIME
400 AC_HEADER_SYS_WAIT
401 AC_HEADER_STAT
402 AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
403                  limits.h crypt.h termcap.h termio.h termios.h locale.h \
404                  netdb.h sys/param.h sys/time.h sys/utsname.h arpa/inet.h \
405                  arpa/ftp.h)
406
407
408 AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
409 [AC_TRY_LINK([#include <sys/types.h>
410 #include <unistd.h>
411 #include <termios.h>],
412 [/* SunOS 4.0.3 has termios.h but not the library calls.  */
413 tcgetattr(0, 0);],
414   nmh_cv_sys_posix_termios=yes, nmh_cv_sys_posix_termios=no)])
415  
416 if test $nmh_cv_sys_posix_termios = yes; then
417   AC_CACHE_CHECK(TIOCGWINSZ in termios.h,
418   nmh_cv_header_termios_h_tiocgwinsz,
419   [AC_TRY_LINK([#include <sys/types.h>
420 #include <termios.h>],
421   [int x = TIOCGWINSZ;],
422   nmh_cv_header_termios_h_tiocgwinsz=yes,
423   nmh_cv_header_termios_h_tiocgwinsz=no)])
424 else
425   nmh_cv_header_termios_h_tiocgwinsz=no
426 fi
427  
428 if test $nmh_cv_header_termios_h_tiocgwinsz = no; then
429   AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h,
430   nmh_cv_header_sys_ioctl_h_tiocgwinsz,
431   [AC_TRY_LINK([#include <sys/types.h>
432 #include <sys/ioctl.h>],
433   [int x = TIOCGWINSZ;],
434   nmh_cv_header_sys_ioctl_h_tiocgwinsz=yes,
435   nmh_cv_header_sys_ioctl_h_tiocgwinsz=no)])
436   if test $nmh_cv_header_sys_ioctl_h_tiocgwinsz = yes; then
437     AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
438   fi
439 fi
440  
441 dnl
442 dnl Checks for _IO_write_ptr. A Linuxism used by nmh on linux. We
443 dnl really use a whole set of them, but this check should be
444 dnl sufficient.
445 dnl
446 AC_CHECK_HEADER(libio.h, [
447   AC_EGREP_HEADER(_IO_write_ptr, libio.h, [
448     AC_DEFINE(LINUX_STDIO) ]) ]) 
449
450 AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM))
451
452 dnl ---------------
453 dnl CHECK FUNCTIONS
454 dnl ---------------
455 AC_FUNC_VFORK
456 AC_CHECK_LIB(mkstemp,mkstemp)
457 AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
458                sighold sigrelse writev lstat uname tzset killpg mkstemp \
459                sethostent getutent)
460
461 dnl solaris screws this up
462 AC_CHECK_FUNC(gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)],
463   AC_CHECK_LIB(nsl, gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)] ) )
464
465 dnl sigsetjmp may be a macro
466 AC_MSG_CHECKING(for sigsetjmp)
467 AC_TRY_LINK([#include <setjmp.h>], [sigsetjmp((void *)0, 0);],
468         [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)], AC_MSG_RESULT(no))
469
470 AC_REPLACE_FUNCS(snprintf strerror strdup)
471
472 dnl Look for the initgroups() declaration.  On AIX 4.[13], Solaris 4.1.3, and
473 dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in
474 dnl any system header.  
475 dnl
476 dnl On Solaris 2.[456], the declaration is in <grp.h>.  On HP-UX 9-11 and
477 dnl (reportedly) FreeBSD 3.[23], it's in <unistd.h>.  Any other locations we
478 dnl need to check? 
479 AC_EGREP_HEADER(initgroups, grp.h, AC_DEFINE(INITGROUPS_HEADER, <grp.h>),
480                 AC_EGREP_HEADER(initgroups, unistd.h, 
481                                 AC_DEFINE(INITGROUPS_HEADER, <unistd.h>)))
482
483 dnl On AIX 4.1, snprintf() is defined in libc.a but there's no prototype in
484 dnl <stdio.h> or elsewhere.  Apparently it's not officially supported (though it
485 dnl seems to work perfectly and IBM apparently uses it in internal code).
486 dnl Anyhow, if we omit our own snprintf() and vsnprintf() prototypes when we
487 dnl HAVE_SNPRINTF, we get a billion warnings at compile time.  Use the C
488 dnl preprocessor to preprocess stdio.h and make sure that there's actually a 
489 dnl prototype. 
490 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_PROTOTYPE))
491
492 dnl -------------------
493 dnl CHECK FOR LIBRARIES
494 dnl -------------------
495 dnl Check location of modf
496 AC_CHECK_FUNC(modf, , AC_CHECK_LIB(m, modf))
497
498 dnl Checks for network libraries (nsl, socket)
499 AC_CHECK_NETLIBS
500
501 termcap_curses_order="termcap curses ncurses"
502 for lib in $termcap_curses_order; do
503   AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
504 done
505 AC_SUBST(TERMLIB)dnl
506
507 dnl --------------
508 dnl CHECK FOR NDBM
509 dnl --------------
510 dnl Checks for ndbm
511 AC_CHECK_FUNC(dbm_open, ,
512   AC_CHECK_LIB(ndbm, dbm_open, ,
513     AC_CHECK_LIB(dbm, dbm_open)))
514
515 dnl ----------------
516 dnl CHECK FOR NDBM.H
517 dnl ----------------
518 AC_CHECK_HEADERS(db1/ndbm.h)
519
520 dnl ----------------
521 dnl CHECK FOR HESIOD
522 dnl ----------------
523 if test x"$with_hesiod" != x -a x"$with_hesiod" != x"no"; then
524   if test x"$with_hesiod" != x"yes"; then
525     HESIOD_INCLUDES="-I$with_hesiod/include"
526     HESIOD_LIBS="-L$with_hesiod/lib"
527   fi
528   AC_CHECK_FUNC(res_send, ,
529     AC_CHECK_LIB(resolv, res_send))
530   AC_CHECK_LIB(hesiod, hes_resolve, [HESIOD_LIBS="$HESIOD_LIBS -lhesiod"],
531     [AC_MSG_ERROR(Hesiod library not found)], $HESIOD_LIBS)
532 fi
533 AC_SUBST(HESIOD_INCLUDES)dnl
534 AC_SUBST(HESIOD_LIBS)dnl
535
536 dnl ----------------------------------
537 dnl CHECK FOR KRB4 (Kerberos4 support)
538 dnl ----------------------------------
539 if test x"$with_krb4" != x -a x"$with_krb4" != x"no"; then
540   if test x"$with_krb4" != x"yes"; then
541     KRB4_INCLUDES="-I$with_krb4/include"
542     if test -d "$with_krb4/include/kerberosIV"; then
543       KRB4_INCLUDES="$KRB4_INCLUDES -I$with_krb4/include/kerberosIV"
544     fi
545     KRB4_LIBS="-L$with_krb4/lib"
546   elif test -d /usr/include/kerberosIV; then
547     KRB4_INCLUDES="-I/usr/include/kerberosIV"
548   fi
549   AC_CHECK_LIB(krb4, krb_rd_req,
550     [KRB4_LIBS="$KRB4_LIBS -lkrb4 -ldes425 -lkrb5 -lcrypto -lcom_err"],
551     [AC_CHECK_LIB(krb, krb_rd_req,
552       [KRB4_LIBS="$KRB4_LIBS -lkrb -ldes"],
553       [AC_MSG_ERROR(Kerberos 4 libraries not found)],
554       $KRB4_LIBS -ldes)],
555     $KRB4_LIBS -ldes425 -lkrb5 -lcrypto -lcom_err)
556 fi
557 AC_SUBST(KRB4_INCLUDES)dnl
558 AC_SUBST(KRB4_LIBS)dnl
559
560 dnl --------------------
561 dnl CHECK FOR CYRUS SASL
562 dnl --------------------
563 if test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != "no"; then
564   if test x"$with_cyrus_sasl" != x"yes"; then
565     SASL_INCLUDES="-I$with_cyrus_sasl/include"
566     SASL_LIBS="-L$with_cyrus_sasl/lib"
567   fi
568   save_LDFLAGS="$LDFLAGS"
569   LDFLAGS="$LDFLAGS $SASL_LIBS"
570   AC_CHECK_LIB(sasl, sasl_client_new,
571     [SASL_LIBS="$SASL_LIBS -lsasl"],
572     [AC_MSG_ERROR(Cyrus SASL library not found)])
573   LDFLAGS="$save_LDFLAGS"
574 fi
575 AC_SUBST(SASL_INCLUDES)dnl
576 AC_SUBST(SASL_LIBS)dnl
577
578 dnl ---------------------
579 dnl CHECK TERMCAP LIBRARY
580 dnl ---------------------
581
582 dnl Add the termcap library, so that the following configure
583 dnl tests will find it when it tries to link test programs.
584 nmh_save_LIBS="$LIBS"
585 LIBS="$TERMLIB $LIBS"
586
587 dnl Checks for external variable ospeed in the termcap library.
588 AC_CACHE_CHECK(if an include file defines ospeed,
589 nmh_cv_decl_ospeed_include_defines,
590 [AC_TRY_LINK(
591 [#include <sys/types.h>
592 #if HAVE_TERMIOS_H
593 #include <termios.h>
594 #endif
595 #if HAVE_TERMCAP_H
596 #include <termcap.h>
597 #endif], [ospeed = 0;],
598 nmh_cv_decl_ospeed_include_defines=yes,
599 nmh_cv_decl_ospeed_include_defines=no)])
600  
601 if test $nmh_cv_decl_ospeed_include_defines = no; then
602   AC_CACHE_CHECK(if you must define ospeed,
603   nmh_cv_decl_ospeed_must_define,
604   [AC_TRY_LINK( ,[extern short ospeed; ospeed = 0;],
605   nmh_cv_decl_ospeed_must_define=yes,
606   nmh_cv_decl_ospeed_must_define=no)])
607 fi
608  
609 if test $nmh_cv_decl_ospeed_include_defines = yes; then
610   AC_DEFINE(HAVE_OSPEED)
611 elif test $nmh_cv_decl_ospeed_must_define = yes; then
612   AC_DEFINE(HAVE_OSPEED)
613   AC_DEFINE(MUST_DEFINE_OSPEED)
614 fi
615
616 dnl dnl Checks if tgetent accepts NULL and will
617 dnl dnl allocate its own termcap buffer.
618 dnl AC_CACHE_CHECK(if tgetent accepts NULL,
619 dnl nmh_cv_func_tgetent_accepts_null,
620 dnl [AC_TRY_RUN([main(){int i = tgetent((char*)0,"vt100");exit(!i || i == -1);}],
621 dnl   nmh_cv_func_tgetent_accepts_null=yes,
622 dnl   nmh_cv_func_tgetent_accepts_null=no,
623 dnl   nmh_cv_func_tgetent_accepts_null=no)])
624 dnl if test $nmh_cv_func_tgetent_accepts_null = yes; then
625 dnl   AC_DEFINE(TGETENT_ACCEPTS_NULL)
626 dnl fi
627
628 dnl Now put the libraries back to what it was before we
629 dnl starting checking the termcap library.
630 LIBS="$nmh_save_LIBS"
631
632 dnl --------------
633 dnl CHECK TYPEDEFS
634 dnl --------------
635 AC_TYPE_SIGNAL
636 AC_TYPE_PID_T
637 AC_TYPE_OFF_T
638 AC_TYPE_UID_T
639 AC_TYPE_MODE_T
640 AC_TYPE_SIZE_T
641
642 dnl Check for sigset_t.  Currently I'm looking in
643 dnl <sys/types.h> and <signal.h>.  Others might need
644 dnl to be added.
645 AC_CACHE_CHECK(for sigset_t, nmh_cv_type_sigset_t,
646 [AC_TRY_COMPILE(
647 [#include <sys/types.h>
648 #include <signal.h>], [sigset_t tempsigset;],
649   nmh_cv_type_sigset_t=yes, nmh_cv_type_sigset_t=no)])
650 if test $nmh_cv_type_sigset_t = no; then
651   AC_DEFINE(sigset_t, unsigned int)
652 fi
653
654 dnl ----------------
655 dnl CHECK STRUCTURES
656 dnl ----------------
657 AC_STRUCT_ST_BLKSIZE
658
659 AC_CACHE_CHECK(for tm_gmtoff in struct tm, nmh_cv_struct_tm_gmtoff,
660 [AC_TRY_COMPILE(
661 [#ifdef TIME_WITH_SYS_TIME
662 # include <sys/time.h>
663 # include <time.h>
664 #else
665 # ifdef TM_IN_SYS_TIME
666 #  include <sys/time.h>
667 # else
668 #  include <time.h>
669 # endif
670 #endif],
671 [struct tm temptm; temptm.tm_gmtoff = 0;],
672   nmh_cv_struct_tm_gmtoff=yes, nmh_cv_struct_tm_gmtoff=no)])
673 if test $nmh_cv_struct_tm_gmtoff = yes; then
674   AC_DEFINE(HAVE_TM_GMTOFF)
675 fi
676
677 dnl -------------
678 dnl CHECK SIGNALS
679 dnl -------------
680 dnl What style of signal do you have (POSIX, BSD, or SYSV)?
681 AC_MSG_CHECKING(what style of signals to use)
682 if test $ac_cv_func_sigaction = yes -a $ac_cv_func_sigprocmask = yes; then
683   signals_style=POSIX_SIGNALS
684   AC_DEFINE(POSIX_SIGNALS)
685   AC_DEFINE(RELIABLE_SIGNALS)
686 elif test $ac_cv_func_sigblock = yes -a $ac_cv_func_sigsetmask = yes; then
687   signals_style=BSD_SIGNALS
688   AC_DEFINE(BSD_SIGNALS)
689   AC_DEFINE(RELIABLE_SIGNALS)
690 elif test $ac_cv_func_sighold = yes -a $ac_cv_func_sigrelse = yes; then
691   signals_style=SYSV_SIGNALS
692   AC_DEFINE(SYSV_SIGNALS)
693 else
694   signals_style=NO_SIGNAL_BLOCKING
695   AC_DEFINE(NO_SIGNAL_BLOCKING)
696 fi
697
698 AC_MSG_RESULT($signals_style)
699
700 dnl Where is <signal.h> located?  Needed as input for signames.awk
701 AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h,
702 [for SIGNAL_H in /usr/include/bsd/sys/signal.h  dnl Next
703                  /usr/include/asm/signal.h      dnl Linux 1.3.0 and above
704                  /usr/include/asm/signum.h      dnl some versions of Linux/Alpha
705                  /usr/include/linux/signal.h    dnl Linux up to 1.2.11
706                  /usr/include/sys/signal.h      dnl Almost everybody else
707                  /dev/null;                     dnl Just in case we fall through
708 do
709   test -f $SIGNAL_H && \
710   grep '#[      ]*define[       ][      ]*SIG[0-9A-Z]*[         ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \
711   break
712 done
713 nmh_cv_path_signal_h=$SIGNAL_H
714 ])
715 SIGNAL_H=$nmh_cv_path_signal_h
716 AC_SUBST(SIGNAL_H)dnl
717
718 dnl ----------------
719 dnl OS SPECIFIC DEFINES
720 dnl ----------------
721 case "$target_os" in
722
723   solaris2*)
724     AC_DEFINE(SYS5)
725     AC_DEFINE(SVR4)
726     ;;
727   irix*)
728     AC_DEFINE(SYS5)
729     AC_DEFINE(SVR4)
730     ;;
731   osf*)
732     AC_DEFINE(SYS5)
733     AC_DEFINE(SVR4)
734     ;;
735   aix*)
736     AC_DEFINE(SYS5)
737     AC_DEFINE(SVR4)
738     ;;
739   sunos4*)
740     AC_DEFINE(BSD42)
741     ;;
742   freebsd*)  
743     AC_DEFINE(BSD42)
744     AC_DEFINE(BSD44)
745     ;;
746   netbsd*)
747     AC_DEFINE(BSD42)
748     AC_DEFINE(BSD44)
749     ;;
750   openbsd*)
751     AC_DEFINE(BSD42)
752     AC_DEFINE(BSD44)
753     ;;
754   bsd/os*)
755     AC_DEFINE(BSD42)
756     AC_DEFINE(BSD44)
757     ;;
758   sco5*)
759     AC_DEFINE(SYS5)
760     AC_DEFINE(SCO_5_STDIO)
761     ;;
762 esac
763
764
765 dnl ----------------
766 dnl OUTPUT MAKEFILES
767 dnl ----------------
768 AC_OUTPUT(Makefile config/Makefile h/Makefile sbr/Makefile uip/Makefile \
769           zotnet/Makefile zotnet/mts/Makefile \
770           mts/Makefile mts/smtp/Makefile \
771           mts/sendmail/Makefile mts/mmdf/Makefile etc/Makefile \
772           docs/Makefile man/Makefile, \
773           [test -z "$CONFIG_HEADERS" || echo > stamp-h])
774
775 dnl Umm, what's the point of these assignments??  -- <dan-nmh@dilvish.speed.net>
776 eval "nmhbin=${bindir}";         eval "nmhbin2=${nmhbin}"
777 eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf2=${nmhsysconf}"
778 eval "nmhlib=${libdir}";         eval "nmhlib2=${nmhlib}"
779 eval "nmhman=${mandir}"
780
781 pop_kinds=no
782 if test x"$enable_pop" = x"yes"; then
783   pop_kinds="yes ("
784
785   if test x"$enable_apop" = x"yes"; then
786     pop_kinds="${pop_kinds}APOP "
787   fi
788
789   if test x"$with_krb4" != x -a x"$with_krb4" != x"no"; then
790     pop_kinds="${pop_kinds}KPOP "
791   fi
792
793   pop_kinds="${pop_kinds}POP3)"
794 fi
795
796 echo "
797 nmh configuration
798 -----------------
799 nmh version                : ${VERSION}
800 target os                  : ${target}
801 compiler                   : ${CC}
802 compiler flags             : ${CFLAGS}
803 linker flags               : ${LDFLAGS}
804 source code location       : ${srcdir}
805 binary install path        : ${nmhbin2}
806 libary install path        : ${nmhlib2}
807 config files install path  : ${nmhsysconf2}
808 man page install path      : ${nmhman}
809 transport system           : ${MTS}
810 default smtp servers       : ${smtpservers}
811 default editor             : ${editorpath}
812 default pager              : ${pagerpath}
813 email address masquerading : ${masquerade}
814 pop is enabled             : ${pop_kinds}"
815 echo ""
816
817
818