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