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