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