bug #15212: remove configure test for broken AT&T vi. This test was broken
[mmh] / configure.in
1 dnl
2 dnl configure.in -- autoconf template for nmh
3 dnl
4 dnl $Id$
5 dnl
6
7 dnl 2.13 definitely chokes; 2.53 is the earliest version I've tested.
8 dnl 2.58 needed for help string macro but that only affects help output
9 dnl 2.50 is the major breakpoint between the old autoconf and the new,
10 dnl so require that. If there are bug reports about 2.50-2.52 not working
11 dnl we can always move this up a little.
12 AC_PREREQ(2.50)
13
14 AC_INIT(nmh, m4_normalize(m4_include([VERSION])))
15 AC_CONFIG_SRCDIR(h/nmh.h)
16 AC_CONFIG_HEADER(config.h)
17
18 AC_CANONICAL_TARGET
19
20 dnl ---------------------
21 dnl define a macro or two
22 dnl ---------------------
23
24 AC_DEFUN(NMH_PROG_GNU_LIBTOOL, [
25 if test -n "$LIBTOOL" ; then
26   tmptest=`$LIBTOOL --version 2>&1 | grep GNU`
27   if test x"$tmptest" != x  ; then
28     GNU_LIBTOOL=1
29     AC_SUBST(GNU_LIBTOOL)dnl
30   fi
31 fi
32 ] )
33   
34 echo "configuring for AC_PACKAGE_NAME-AC_PACKAGE_VERSION"
35 AC_SUBST(VERSION,AC_PACKAGE_VERSION)dnl
36
37 dnl What date of nmh are we building?
38 DATE=`cat ${srcdir}/DATE`
39 echo "configuring for nmh dated $DATE"
40 AC_SUBST(DATE)dnl
41
42 dnl --------------------------
43 dnl CHECK COMMAND LINE OPTIONS
44 dnl --------------------------
45
46 dnl Do you want client-side support for apop?
47 AC_ARG_ENABLE(apop, AS_HELP_STRING([--enable-apop],
48   [enable client-side support for POP3 and APOP]))
49 if test x"$enable_apop" = x"yes"; then
50   AC_DEFINE(APOP)dnl
51   APOPLIB=md5.o
52   enable_pop=yes
53 fi
54 AC_SUBST(APOPLIB)dnl
55
56 dnl Do you want to debug nmh?
57 AC_ARG_ENABLE(debug,
58   AS_HELP_STRING([--enable-debug],[enable nmh code debugging]))
59 dnl The old redundant --enable-nmh-debug is deprecated and undocumented.
60 if test x"$enable_nmh_debug" = x"yes"; then
61   enable_debug=yes
62 fi
63
64 dnl Allow users to send email from addresses other than their default?
65 AC_ARG_ENABLE(masquerade,
66   AS_HELP_STRING([--enable-masquerade='draft_from mmailid username_extension'],
67     [enable up to 3 types of address masquerading]),
68   [if test x"$enable_masquerade" = x"yes"; then
69     masquerade="draft_from mmailid username_extension"
70   else
71     masquerade="$enable_masquerade"
72   fi])
73 AC_SUBST(masquerade)dnl
74
75 dnl Do you want mhe support?
76 AC_ARG_ENABLE(mhe,
77   AS_HELP_STRING([--disable-mhe],[disable mhe support]))
78
79 dnl mhe support is on by default, so define it unless --disable-mhe or the
80 dnl deprecated, undocumented --disable-nmh-mhe are specified.
81 if test x"$enable_mhe" != x"no" -a x"$enable_nmh_mhe" != x"no"; then
82   AC_DEFINE(MHE)dnl
83 fi
84
85 dnl Do you want client-side support for pop?
86 AC_ARG_ENABLE(pop,
87   AS_HELP_STRING([--enable-pop], [enable client-side support for plain POP3]))
88 dnl The old redundant --enable-nmh-pop is deprecated and undocumented.
89 if test x"$enable_nmh_pop" = x"yes"; then
90   enable_pop=yes
91 fi
92
93 dnl Do you want client-side support for using SASL for authentication?
94 dnl Note that this code will be enabled for both POP and SMTP
95 AC_ARG_WITH(cyrus-sasl, AS_HELP_STRING([--with-cyrus-sasl=DIR],
96   [specify location of Cyrus SASL library]))
97 if test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != x"no"; then
98   AC_DEFINE(CYRUS_SASL)dnl
99   sasl_support=yes
100 else
101   sasl_support=no
102 fi
103
104 dnl What should be the default editor?
105 AC_ARG_WITH(editor,
106   AS_HELP_STRING([--with-editor=EDITOR],[specify the default editor]))
107
108 if test -n "$with_editor"; then
109   editorpath="$with_editor"
110 fi
111
112 dnl Set the backup prefix
113 AC_ARG_WITH([hash-backup],
114   AS_HELP_STRING([--with-hash-backup],[use # as the backup prefix (default: ,)]))
115 if test x"$with_hash_backup" != x -a x"$with_hash_backup" != x"no"; then
116   backup_prefix="#"
117 else
118   backup_prefix=","
119 fi
120 AC_DEFINE_UNQUOTED(BACKUP_PREFIX, "$backup_prefix")dnl
121
122 dnl Do you want support for hesiod
123 AC_ARG_WITH(hesiod,
124   AS_HELP_STRING([--with-hesiod=DIR],[specify location of Hesiod]))
125 if test x"$with_hesiod" != x -a x"$with_hesiod" != x"no"; then
126   AC_DEFINE(HESIOD)dnl
127 fi
128
129 dnl Do you want client-side support for kpop
130 AC_ARG_WITH(krb4, AS_HELP_STRING([--with-krb4=DIR],
131   [specify location of Kerberos V4 for KPOP support]))
132 if test x"$with_krb4" != x -a x"$with_krb4" != x"no"; then
133   enable_pop=yes
134   AC_DEFINE(KPOP)dnl
135   AC_DEFINE(KPOP_PRINCIPAL, "pop")dnl
136 fi
137
138 dnl After we know if we're including apop and kpop support, do pop stuff
139 if test x"$enable_pop" = x"yes"; then
140   AC_DEFINE(POP)dnl
141   POPLIB=popsbr.o
142   POPSED='/^%nmhbeginpop%/d;/^%nmhendpop%/d'
143 else
144   POPSED='/^%nmhbeginpop%/,/^%nmhendpop%/d'
145 fi
146 AC_SUBST(POPLIB)dnl
147 AC_SUBST(POPSED)dnl
148
149 dnl What method of locking to use?
150 AC_ARG_WITH(locking,
151   AS_HELP_STRING([--with-locking=@<:@dot|fcntl|flock|lockf@:>@],
152   [specify the file locking method]))
153
154 if test x"$with_locking" = x"dot"; then
155   LOCKTYPE="dot"
156   AC_DEFINE(DOT_LOCKING)dnl
157 elif test x"$with_locking" = x"flock"; then
158   LOCKTYPE="flock"
159   AC_DEFINE(FLOCK_LOCKING)dnl
160 elif test x"$with_locking" = x"lockf"; then
161   LOCKTYPE="lockf"
162   AC_DEFINE(LOCKF_LOCKING)dnl
163 elif test x"$with_locking" = x"fcntl"; then
164   LOCKTYPE="fcntl"
165   AC_DEFINE(FCNTL_LOCKING)dnl
166 else
167   LOCKTYPE="dot"
168   AC_DEFINE(DOT_LOCKING)dnl
169 fi
170
171 dnl What method of posting should post use?
172 AC_ARG_WITH(mts,
173   AS_HELP_STRING([--with-mts=@<:@smtp|sendmail@:>@],
174   [specify the default mail transport agent/service]))
175
176 if test x"$with_mts" = x"smtp"; then
177   MTS="smtp"
178 elif test x"$with_mts" = x"sendmail"; then
179   MTS="sendmail"
180 else
181   MTS="smtp"
182 fi
183 AC_SUBST(MTS)dnl
184
185 dnl Both the smtp and sendmail mail transport services use the smtp code
186 AC_DEFINE(SMTPMTS)dnl
187
188 dnl What should be the default pager?
189 AC_ARG_WITH(pager,
190   AS_HELP_STRING([--with-pager=PAGER],[specify the default pager]))
191
192 if test -n "$with_pager"; then
193   pagerpath="$with_pager"
194 fi
195
196 dnl What should be the default mail server(s)?
197 AC_ARG_WITH(smtpservers,
198   AS_HELP_STRING([--with-smtpservers='SMTPSERVER1@<:@ SMTPSERVER2...@:>@'],
199   [specify the default SMTP server(s) @<:@localhost@:>@]))
200 if test -n "$with_smtpservers"; then
201   smtpservers="$with_smtpservers"
202 else
203   smtpservers="localhost"
204 fi
205 AC_SUBST(smtpservers)dnl
206
207 dnl ----------------------------------------------------
208 dnl Default location is /usr/local/nmh/{bin,etc,lib,man}
209 dnl ----------------------------------------------------
210 AC_PREFIX_DEFAULT(/usr/local/nmh)
211
212 dnl ------------------
213 dnl CHECK THE COMPILER
214 dnl ------------------
215 dnl We want these before the checks,
216 dnl so the checks can modify their values.
217 test -z "$CFLAGS" && CFLAGS= auto_cflags=1
218 if test x"$enable_debug" = x"yes"; then
219   test -z "$LDFLAGS" && LDFLAGS=-g
220 fi
221
222 AC_PROG_CC
223
224 dnl if the user hasn't specified CFLAGS, then
225 dnl   if compiler is gcc, then
226 dnl     use -O2 and some warning flags
227 dnl   else use -O
228 if test -n "$auto_cflags"; then
229   if test x"$enable_debug" = x"yes"; then
230     if test -n "$GCC"; then
231       test -z "$CFLAGS" && CFLAGS="-Wall -g" || CFLAGS="$CFLAGS -Wall -g"
232     else
233       test -z "$CFLAGS" && CFLAGS=-g || CFLAGS="$CFLAGS -g"
234     fi
235   else
236     if test -z "$LDFLAGS"; then
237       case "$build_os" in
238         darwin*)
239           LDFLAGS=
240           ;;
241         *)
242           LDFLAGS=-s
243           ;;
244       esac
245     fi
246     if test -n "$GCC"; then
247       test -z "$CFLAGS" && CFLAGS="-Wall -O2" || CFLAGS="$CFLAGS -Wall -O2"
248     else
249       test -z "$CFLAGS" && CFLAGS=-O  || CFLAGS="$CFLAGS -O"
250     fi
251   fi
252 fi
253
254 AC_C_CONST              dnl Does compiler support `const'.
255
256 dnl ------------------
257 dnl CHECK FOR PROGRAMS
258 dnl ------------------
259 AC_PROG_MAKE_SET        dnl Does make define $MAKE
260 AC_PROG_INSTALL         dnl Check for BSD compatible `install'
261 AC_PROG_RANLIB          dnl Check for `ranlib'
262 AC_PROG_AWK             dnl Check for mawk,gawk,nawk, then awk
263 AC_PROG_LEX             dnl Check for lex/flex
264
265 dnl Look for `cut'
266 pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
267 AC_PATH_PROG(cutpath, cut, no, [$pathtmp])
268
269 dnl ----------------------------------------------
270 dnl check for lclint, and lint if it doesn't exist
271 dnl ----------------------------------------------
272 AC_CHECK_PROG(linttmp1, lclint, lclint, no)dnl
273 if test x$ac_cv_prog_linttmp1 != xno ; then
274   LINT=$ac_cv_prog_linttmp1
275   LINTFLAGS="-weak +posixlib -macrovarprefixexclude"
276 else
277   AC_CHECK_PROG(linttmp2, lint, lint, no)dnl
278   if test x$ac_cv_prog_linttmp2 != xno ; then
279     LINT=$ac_cv_prog_linttmp2
280     LINTFLAGS=""
281   else
282     LINT="echo 'No lint program found'"
283     LINTFLAGS=""
284   fi
285 fi
286 AC_SUBST(LINT)dnl
287 AC_SUBST(LINTFLAGS)dnl
288
289 dnl try to figure out which one we've got
290 AC_CHECK_PROG(LIBTOOL, libtool, libtool, , [$pathtmp])
291 NMH_PROG_GNU_LIBTOOL
292
293 dnl Check for lorder and tsort commands
294 AC_CHECK_PROG(LORDER, lorder, lorder, no)dnl
295 AC_CHECK_PROG(TSORT, tsort, tsort, no)dnl
296
297 dnl If either doesn't exist, replace them with echo and cat
298 if test x$ac_cv_prog_LORDER != xlorder -o x$ac_cv_prog_TSORT != xtsort; then
299   LORDER=echo
300   TSORT=cat
301   AC_SUBST(LORDER)dnl
302   AC_SUBST(TSORT)dnl
303 dnl Mac OS X has lorder, but sh is too broken for it to work
304 dnl elif test -z "`lorder config/config.c 2>&1 | grep config/config.c`" ; then
305 dnl   LORDER=echo
306 dnl   TSORT=cat
307 dnl   AC_SUBST(LORDER)dnl
308 dnl   AC_SUBST(TSORT)dnl
309 fi
310
311 dnl Check whether tsort can deal with loops
312 AC_CACHE_CHECK(whether tsort can deal with loops, nmh_cv_tsort_loop,
313   [if test -z "`echo a b b a | tsort 2>/dev/null | grep a`" ; then
314     nmh_cv_tsort_loop=no
315   else
316     nmh_cv_tsort_loop=yes
317   fi])
318 if test x$nmh_cv_tsort_loop = xno ; then
319   LORDER=echo
320   TSORT=cat
321   AC_SUBST(LORDER)dnl
322   AC_SUBST(TSORT)dnl
323 fi
324
325 dnl Look for `ls'
326 pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
327 AC_PATH_PROG(lspath, ls, no, [$pathtmp])
328
329 dnl See how we get ls to display the owner and the group
330 if test "$lspath" != "no"; then
331   AC_CACHE_CHECK(how to get ls to show us the group ownership of a file, 
332                  nmh_cv_ls_grpopt,
333   [if test x"`$lspath -dl / | $AWK '{print $9}'`" = x"/"; then
334     dnl There were 9 parameters, so unless this is a really bizarre, nonstandard
335     dnl ls, it would seem -l gave us both the user and group.  On this type of
336     dnl ls, -g makes _only_ the group be displayed (and not the user).
337     nmh_cv_ls_grpopt="-l"
338   else
339     dnl Looks like -l only gave us the user, so we need -g to get the group too.
340     nmh_cv_ls_grpopt="-lg"
341   fi])
342 fi
343
344 dnl Look for `more'
345 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
346 AC_PATH_PROG(morepath, more, no, [$pathtmp])
347
348 dnl If pager is not specified yet,
349 dnl then use `more' as the default.
350 if test -z "$pagerpath"; then
351   pagerpath="$morepath"
352 fi
353 AC_SUBST(pagerpath)dnl
354
355 dnl Look for `sendmail'
356 pathtmp=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin:/bin
357 AC_PATH_PROG(sendmailpath, sendmail, /usr/sbin/sendmail, [$pathtmp])
358
359 dnl Look for `vi'
360 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
361 AC_PATH_PROG(vipath, vi, /bin/vi, [$pathtmp])
362
363 dnl If editor is not specified yet,
364 dnl then use `vi' as the default.
365 if test -z "$editorpath"; then
366   editorpath="$vipath"
367 fi
368 AC_SUBST(editorpath)dnl
369
370 dnl ----------------------------------------------------------
371 dnl FIND MAIL SPOOL AND SEE IF WE NEED TO MAKE inc SETGID MAIL
372 dnl ----------------------------------------------------------
373 AC_CACHE_CHECK(where mail spool is located, nmh_cv_mailspool,
374 [for mailspool in /var/mail        dnl
375                   /var/spool/mail  dnl
376                   /usr/spool/mail  dnl
377                   /dev/null;       dnl Just in case we fall through
378 do
379   test -d $mailspool && break
380 done
381 nmh_cv_mailspool=$mailspool
382 ])
383 mailspool=$nmh_cv_mailspool
384 AC_SUBST(mailspool)dnl
385
386 dnl See whether the mail spool directory is world-writable.
387 if test "$lspath" != "no" -a "$cutpath" != "no"; then
388   AC_CACHE_CHECK(whether the mail spool is world-writable, 
389                  nmh_cv_mailspool_world_writable,
390   [if test "`$lspath -dlL $mailspool | $cutpath -c9`" = "-"; then
391     nmh_cv_mailspool_world_writable=no
392   else
393     nmh_cv_mailspool_world_writable=yes
394   fi])
395 fi
396
397 dnl Also, check for liblockfile (as found on Debian systems)
398 AC_CHECK_HEADER(lockfile.h, AC_CHECK_LIB(lockfile, lockfile_create) )
399
400 dnl and whether its companion program dotlockfile is setgid
401 AC_PATH_PROG(dotlockfilepath, dotlockfile, no)
402 if test "$ac_cv_lib_lockfile_lockfile_create" != "no" ; then
403   if test "$ac_cv_path_dotlockfilepath" != "no" ; then
404     AC_CACHE_CHECK(whether dotlockfile is setgid, nmh_cv_dotlockfile_setgid,
405     [ if test -g "$ac_cv_path_dotlockfilepath" ; then
406         nmh_cv_dotlockfile_setgid=yes
407       else
408         nmh_cv_dotlockfile_setgid=no
409       fi])
410   fi
411 fi
412
413 dnl If mailspool is not world-writable and dotlockfile is not setgid,
414 dnl we need to #define MAILGROUP to 1 and make inc setgid.
415 if test x"$LOCKTYPE" = x"dot" -a x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then
416   dnl do we really need both of these?
417   AC_DEFINE(MAILGROUP)dnl
418   SETGID_MAIL=1
419 fi
420 AC_SUBST(SETGID_MAIL)dnl
421
422 dnl Use ls to see which group owns the mail spool directory.
423 AC_CACHE_CHECK(what group owns the mail spool, nmh_cv_ls_mail_grp,
424 [nmh_cv_ls_mail_grp=`$lspath -dL $nmh_cv_ls_grpopt $mailspool|$AWK '{print $4}'`
425 ])
426 MAIL_SPOOL_GRP=$nmh_cv_ls_mail_grp
427 AC_SUBST(MAIL_SPOOL_GRP)dnl
428
429 dnl ------------------
430 dnl CHECK HEADER FILES
431 dnl ------------------
432 AC_HEADER_DIRENT
433 AC_HEADER_STDC
434 AC_HEADER_TIME
435 AC_HEADER_SYS_WAIT
436 AC_HEADER_STAT
437 AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
438                  limits.h crypt.h termcap.h termio.h termios.h locale.h \
439                  langinfo.h wchar.h wctype.h iconv.h netdb.h \
440                  sys/param.h sys/time.h sys/utsname.h sys/stream.h \
441                  arpa/inet.h arpa/ftp.h)
442
443 AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
444 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
445 #include <unistd.h>
446 #include <termios.h>]],
447 [[/* SunOS 4.0.3 has termios.h but not the library calls.  */
448 tcgetattr(0, 0);]])],
449 nmh_cv_sys_posix_termios=yes, nmh_cv_sys_posix_termios=no)])
450  
451 if test $nmh_cv_sys_posix_termios = yes; then
452   AC_CACHE_CHECK(TIOCGWINSZ in termios.h,
453   nmh_cv_header_termios_h_tiocgwinsz,
454   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
455 #include <termios.h>]],
456   [[int x = TIOCGWINSZ;]])],
457   nmh_cv_header_termios_h_tiocgwinsz=yes,nmh_cv_header_termios_h_tiocgwinsz=no)])
458 else
459   nmh_cv_header_termios_h_tiocgwinsz=no
460 fi
461  
462 if test $nmh_cv_header_termios_h_tiocgwinsz = no; then
463   AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h,
464   nmh_cv_header_sys_ioctl_h_tiocgwinsz,
465   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
466 #include <sys/ioctl.h>]],
467   [[int x = TIOCGWINSZ;]])],
468   nmh_cv_header_sys_ioctl_h_tiocgwinsz=yes,nmh_cv_header_sys_ioctl_h_tiocgwinsz=no)])
469   if test $nmh_cv_header_sys_ioctl_h_tiocgwinsz = yes; then
470     AC_DEFINE(GWINSZ_IN_SYS_IOCTL)dnl
471   fi
472 fi
473  
474 dnl
475 dnl Checks for _IO_write_ptr. A Linuxism used by nmh on linux. We
476 dnl really use a whole set of them, but this check should be
477 dnl sufficient.
478 dnl
479 AC_CHECK_HEADER(libio.h, [
480   AC_EGREP_HEADER(_IO_write_ptr, libio.h, [
481     AC_DEFINE(LINUX_STDIO) ]) ]) 
482
483 AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM),,
484 [[#if HAVE_SYS_STREAM_H
485 #  include <sys/stream.h>
486 #endif
487 ]])
488
489 dnl ---------------
490 dnl CHECK FUNCTIONS
491 dnl ---------------
492 AC_FUNC_VFORK
493 AC_CHECK_LIB(mkstemp,mkstemp)
494 AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
495                sighold sigrelse writev lstat uname tzset killpg mkstemp \
496                sethostent getutent nl_langinfo mbtowc wcwidth)
497
498 dnl solaris screws this up
499 AC_CHECK_FUNC(gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)],
500   AC_CHECK_LIB(nsl, gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)] ) )
501
502 dnl sigsetjmp may be a macro
503 AC_MSG_CHECKING(for sigsetjmp)
504 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <setjmp.h>]],
505   [[sigsetjmp((void *)0, 0);]])],[AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
506   [AC_MSG_RESULT(no)])
507
508 AC_REPLACE_FUNCS(snprintf strdup)
509
510 dnl Look for the initgroups() declaration.  On AIX 4.[13], Solaris 4.1.3, and
511 dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in
512 dnl any system header.  
513 dnl
514 dnl On Solaris 2.[456], the declaration is in <grp.h>.  On HP-UX 9-11 and
515 dnl (reportedly) FreeBSD 3.[23], it's in <unistd.h>.  Any other locations we
516 dnl need to check? 
517 AC_EGREP_HEADER(initgroups, grp.h, AC_DEFINE(INITGROUPS_HEADER, <grp.h>),
518                 AC_EGREP_HEADER(initgroups, unistd.h, 
519                                 AC_DEFINE(INITGROUPS_HEADER, <unistd.h>)))
520
521 dnl On AIX 4.1, snprintf() is defined in libc.a but there's no prototype in
522 dnl <stdio.h> or elsewhere.  Apparently it's not officially supported (though it
523 dnl seems to work perfectly and IBM apparently uses it in internal code).
524 dnl Anyhow, if we omit our own snprintf() and vsnprintf() prototypes when we
525 dnl HAVE_SNPRINTF, we get a billion warnings at compile time.  Use the C
526 dnl preprocessor to preprocess stdio.h and make sure that there's actually a 
527 dnl prototype. 
528 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_PROTOTYPE))
529
530 dnl Check for multibyte character set support
531 if test "x$ac_cv_header_wchar_h" = "xyes" -a "x$ac_cv_header_wctype_h" = "xyes" \
532     -a "x$ac_cv_func_wcwidth" = "xyes" -a "x$ac_cv_func_mbtowc" = "xyes"; then
533   AC_DEFINE(MULTIBYTE_SUPPORT, 1,
534     [Define to enable support for multibyte character sets])
535 fi
536
537 dnl -------------------
538 dnl CHECK FOR LIBRARIES
539 dnl -------------------
540 dnl Check location of modf
541 AC_CHECK_FUNC(modf, , AC_CHECK_LIB(m, modf))
542
543 dnl Checks for network libraries (nsl, socket)
544 AC_CHECK_NETLIBS
545
546 termcap_curses_order="termcap curses ncurses"
547 for lib in $termcap_curses_order; do
548   AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
549 done
550 AC_SUBST(TERMLIB)dnl
551
552 dnl ---------------
553 dnl CHECK FOR ICONV
554 dnl ---------------
555
556 dnl Find iconv. It may be in libiconv and may be iconv() or libiconv()
557 if test "x$ac_cv_header_iconv_h" = "xyes"; then
558   AC_CHECK_FUNC(iconv, ac_found_iconv=yes, ac_found_iconv=no)
559   if test "x$ac_found_iconv" = "xno"; then
560     AC_CHECK_LIB(iconv, iconv, ac_found_iconv=yes)
561     if test "x$ac_found_iconv" = "xno"; then
562       AC_CHECK_LIB(iconv, libiconv, ac_found_iconv=yes)
563     fi
564     if test "x$ac_found_iconv" != "xno"; then
565       LIBS="-liconv $LIBS"
566     fi
567   else
568     dnl Handle case where there is a native iconv but iconv.h is from libiconv
569     AC_CHECK_DECL(_libiconv_version,
570       [ AC_CHECK_LIB(iconv, libiconv, LIBS="-liconv $LIBS") ],,
571       [ #include <iconv.h> ])
572   fi
573 fi
574 if test "x$ac_found_iconv" = xyes; then
575   AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
576 fi
577
578 dnl Check if iconv uses const in prototype declaration
579 if test "x$ac_found_iconv" = "xyes"; then
580   AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const,
581     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
582         #include <iconv.h>]],
583         [[#ifdef __cplusplus
584           "C"
585           #endif
586           #if defined(__STDC__) || defined(__cplusplus)
587           size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
588           #else
589           size_t iconv();
590           #endif]])],
591       [ac_cv_iconv_const=],
592       [ac_cv_iconv_const=const])])
593   AC_DEFINE_UNQUOTED([ICONV_CONST], $ac_cv_iconv_const,
594     [Define as const if the declaration of iconv() needs const.])
595 fi
596
597 dnl --------------
598 dnl CHECK FOR NDBM
599 dnl --------------
600
601 AC_ARG_WITH([ndbm],AS_HELP_STRING([--with-ndbm=ARG],[use -lARG to link with ndbm]),
602             [nmh_ndbm=$withval],[nmh_ndbm=autodetect])
603 AC_ARG_WITH([ndbmheader],AS_HELP_STRING([--with-ndbmheader=ARG],[#include <ARG> to use ndbm]),
604             [nmh_ndbmheader=$withval],[nmh_ndbmheader=autodetect])
605
606 if test "$nmh_ndbm" = "autodetect"; then
607   if test "$nmh_ndbmheader" != "autodetect"; then
608     AC_MSG_ERROR([must specify both --with-ndbm and --with-ndbmheader or neither])
609   else
610
611     dnl There are at least four implementations of ndbm, and
612     dnl several of those can be in different places at the whim
613     dnl of the system integrator. A good summary of this mess
614     dnl can be found at http://www.unixpapa.com/incnote/dbm.html
615
616     dnl Classic ndbm with no library required (eg NetBSD): try this
617     dnl first so we don't accidentally link in a pointless but harmless
618     dnl library in one of the later ndbm.h+libfoo tests:
619     NMH_CHECK_NDBM(ndbm.h,,,
620     dnl Berkeley DBv2 emulating ndbm: header in db.h:
621       NMH_CHECK_NDBM(db.h,db,,
622     dnl Berkeley DBv1 emulating ndbm:
623         NMH_CHECK_NDBM(ndbm.h,db,,
624           NMH_CHECK_NDBM(ndbm.h,db1,,
625     dnl Classic ndbm:
626             NMH_CHECK_NDBM(ndbm.h,ndbm,,
627     dnl glibc2.1 systems put db1 in a subdir:
628               NMH_CHECK_NDBM(db1/ndbm.h,db1,,
629     dnl GNU gdbm emulating ndbm, with header possibly in gdbm/
630     dnl and possibly needing gbdm_compat library:
631                 NMH_CHECK_NDBM(gdbm/ndbm.h,gdbm,,
632                   NMH_CHECK_NDBM(gdbm/ndbm.h,gdbm_compat -lgdbm,,
633                     NMH_CHECK_NDBM(ndbm.h,gdbm,,
634                       NMH_CHECK_NDBM(ndbm.h,gdbm_compat -lgdbm))))))))))
635
636   fi
637 else
638   dnl We don't really need to check that the user-specified values work,
639   dnl but it is a convenience to the user to bomb out early rather than
640   dnl after configure and half the compile process.
641   NMH_CHECK_NDBM([$nmh_ndbmheader],[$nmh_ndbm])
642 fi
643
644 if test "$nmh_ndbm_found" = "no"; then
645   AC_MSG_ERROR([could not find a working ndbm library/header combination])
646 else
647   dnl Now export the lib/header to our makefile/config.h:
648   if test x"$nmh_ndbmheader" != x; then
649     AC_DEFINE_UNQUOTED(NDBM_HEADER, <$nmh_ndbmheader>)
650   fi
651   if test x"$nmh_ndbm" != x; then
652     NDBM_LIBS="-l$nmh_ndbm"
653   else
654     NDBM_LIBS=
655   fi
656   AC_SUBST(NDBM_LIBS)
657 fi
658
659
660 dnl ----------------
661 dnl CHECK FOR HESIOD
662 dnl ----------------
663 if test x"$with_hesiod" != x -a x"$with_hesiod" != x"no"; then
664   if test x"$with_hesiod" != x"yes"; then
665     HESIOD_INCLUDES="-I$with_hesiod/include"
666     HESIOD_LIBS="-L$with_hesiod/lib"
667   fi
668   AC_CHECK_FUNC(res_send,
669         [AC_CHECK_LIB(hesiod, hes_resolve,
670                 [HESIOD_LIBS="$HESIOD_LIBS -lhesiod"],
671                 [AC_MSG_ERROR(Hesiod library not found)],
672                 $HESIOD_LIBS)],
673         [AC_CHECK_LIB(hesiod, hes_resolve,
674                 [HESIOD_LIBS="$HESIOD_LIBS -lhesiod -lresolv"],
675                 [AC_MSG_ERROR(Hesiod library not found)],
676                 $HESIOD_LIBS -lresolv)])
677
678 fi
679 AC_SUBST(HESIOD_INCLUDES)dnl
680 AC_SUBST(HESIOD_LIBS)dnl
681
682 dnl ----------------------------------
683 dnl CHECK FOR KRB4 (Kerberos4 support)
684 dnl ----------------------------------
685 if test x"$with_krb4" != x -a x"$with_krb4" != x"no"; then
686   if test x"$with_krb4" != x"yes"; then
687     KRB4_INCLUDES="-I$with_krb4/include"
688     if test -d "$with_krb4/include/kerberosIV"; then
689       KRB4_INCLUDES="$KRB4_INCLUDES -I$with_krb4/include/kerberosIV"
690     fi
691     KRB4_LIBS="-L$with_krb4/lib"
692   elif test -d /usr/include/kerberosIV; then
693     KRB4_INCLUDES="-I/usr/include/kerberosIV"
694   fi
695 dnl First, check if we have -lk5crypto, since that means we have a recent krb5
696
697   AC_CHECK_LIB(k5crypto, krb5_encrypt,
698         [AC_CHECK_LIB(krb4, krb_rd_req,
699                 [KRB4_LIBS="$KRB4_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"],
700                 [AC_MSG_ERROR(Kerberos 4 compatibility libraries not found)],
701                 $KRB4_LIBS -ldes425 -lkrb5 -lk5crypto -lcom_err)],
702
703         [AC_CHECK_LIB(krb4, krb_rd_req,
704             [KRB4_LIBS="$KRB4_LIBS -lkrb4 -ldes425 -lkrb5 -lcrypto -lcom_err"],
705             [AC_CHECK_LIB(krb, krb_rd_req,
706               [KRB4_LIBS="$KRB4_LIBS -lkrb -ldes"],
707               [AC_MSG_ERROR(Kerberos 4 libraries not found)],
708               $KRB4_LIBS -ldes)],
709             $KRB4_LIBS -ldes425 -lkrb5 -lcrypto -lcom_err)],
710         $KRB4_LIBS)
711
712 fi
713 AC_SUBST(KRB4_INCLUDES)dnl
714 AC_SUBST(KRB4_LIBS)dnl
715
716 dnl --------------------
717 dnl CHECK FOR CYRUS SASL
718 dnl --------------------
719 if test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != x"no"; then
720   if test x"$with_cyrus_sasl" != x"yes"; then
721     SASL_INCLUDES="-I$with_cyrus_sasl/include"
722     SASL_LIBS="-L$with_cyrus_sasl/lib"
723
724     dnl Do OS-specific hardcoding of SASL shared library path into executables,
725     dnl so user isn't forced to set environment variables like Solaris'
726     dnl LD_LIBRARY_PATH.
727     case "$target_os" in
728       solaris*)
729         SASL_LIBS="$SASL_LIBS -R$with_cyrus_sasl/lib"
730         ;;
731     esac
732   fi
733   save_LDFLAGS="$LDFLAGS"
734   LDFLAGS="$LDFLAGS $SASL_LIBS"
735   AC_CHECK_LIB(sasl2, sasl_client_new,
736     [SASL_LIBS="$SASL_LIBS -lsasl2"],
737     [AC_MSG_ERROR(Cyrus SASL library not found)])
738   LDFLAGS="$save_LDFLAGS"
739 fi
740 AC_SUBST(SASL_INCLUDES)dnl
741 AC_SUBST(SASL_LIBS)dnl
742
743 dnl ---------------------
744 dnl CHECK TERMCAP LIBRARY
745 dnl ---------------------
746
747 dnl Add the termcap library, so that the following configure
748 dnl tests will find it when it tries to link test programs.
749 nmh_save_LIBS="$LIBS"
750 LIBS="$TERMLIB $LIBS"
751
752 dnl Checks for external variable ospeed in the termcap library.
753 AC_CACHE_CHECK(if an include file defines ospeed,
754 nmh_cv_decl_ospeed_include_defines,
755 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
756 #if HAVE_TERMIOS_H
757 #include <termios.h>
758 #endif
759 #if HAVE_TERMCAP_H
760 #include <termcap.h>
761 #endif]], [[ospeed = 0;]])],
762 nmh_cv_decl_ospeed_include_defines=yes,nmh_cv_decl_ospeed_include_defines=no)])
763  
764 if test $nmh_cv_decl_ospeed_include_defines = no; then
765   AC_CACHE_CHECK(if you must define ospeed,
766   nmh_cv_decl_ospeed_must_define,
767   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
768   [[extern short ospeed; ospeed = 0;]])],
769   nmh_cv_decl_ospeed_must_define=yes,nmh_cv_decl_ospeed_must_define=no)])
770 fi
771  
772 if test $nmh_cv_decl_ospeed_include_defines = yes; then
773   AC_DEFINE(HAVE_OSPEED)dnl
774 elif test $nmh_cv_decl_ospeed_must_define = yes; then
775   AC_DEFINE(HAVE_OSPEED)
776   AC_DEFINE(MUST_DEFINE_OSPEED)
777 fi
778
779 dnl dnl Checks if tgetent accepts NULL and will
780 dnl dnl allocate its own termcap buffer.
781 dnl AC_CACHE_CHECK(if tgetent accepts NULL,
782 dnl nmh_cv_func_tgetent_accepts_null,
783 dnl [AC_TRY_RUN([main(){int i = tgetent((char*)0,"vt100");exit(!i || i == -1);}],
784 dnl   nmh_cv_func_tgetent_accepts_null=yes,
785 dnl   nmh_cv_func_tgetent_accepts_null=no,
786 dnl   nmh_cv_func_tgetent_accepts_null=no)])
787 dnl if test $nmh_cv_func_tgetent_accepts_null = yes; then
788 dnl   AC_DEFINE(TGETENT_ACCEPTS_NULL)
789 dnl fi
790
791 dnl Now put the libraries back to what it was before we
792 dnl starting checking the termcap library.
793 LIBS="$nmh_save_LIBS"
794
795 dnl --------------
796 dnl CHECK TYPEDEFS
797 dnl --------------
798 AC_TYPE_SIGNAL
799 AC_TYPE_PID_T
800 AC_TYPE_OFF_T
801 AC_TYPE_UID_T
802 AC_TYPE_MODE_T
803 AC_TYPE_SIZE_T
804
805 dnl Check for sigset_t.  Currently I'm looking in
806 dnl <sys/types.h> and <signal.h>.  Others might need
807 dnl to be added.
808 AC_CACHE_CHECK(for sigset_t, nmh_cv_type_sigset_t,
809 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
810 #include <signal.h>]], [[sigset_t tempsigset;]])],
811 nmh_cv_type_sigset_t=yes,nmh_cv_type_sigset_t=no)])
812 if test $nmh_cv_type_sigset_t = no; then
813   AC_DEFINE(sigset_t, unsigned int)
814 fi
815
816 dnl ----------------
817 dnl CHECK STRUCTURES
818 dnl ----------------
819 AC_CHECK_MEMBERS(struct stat.st_blksize)
820
821 AC_CACHE_CHECK(for tm_gmtoff in struct tm, nmh_cv_struct_tm_gmtoff,
822 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef TIME_WITH_SYS_TIME
823 # include <sys/time.h>
824 # include <time.h>
825 #else
826 # ifdef TM_IN_SYS_TIME
827 #  include <sys/time.h>
828 # else
829 #  include <time.h>
830 # endif
831 #endif]], [[struct tm temptm; temptm.tm_gmtoff = 0;]])],
832 nmh_cv_struct_tm_gmtoff=yes,nmh_cv_struct_tm_gmtoff=no)])
833 if test $nmh_cv_struct_tm_gmtoff = yes; then
834   AC_DEFINE(HAVE_TM_GMTOFF)
835 fi
836
837 AC_CACHE_CHECK(for ut_type in struct utmp, nmh_cv_struct_utmp_ut_type,
838 [AC_TRY_COMPILE(
839 [#include <utmp.h>],
840 [struct utmp temputmp; temputmp.ut_type = 0;],
841   nmh_cv_struct_utmp_ut_type=yes, nmh_cv_struct_utmp_ut_type=no)])
842 if test $nmh_cv_struct_utmp_ut_type = yes; then
843   AC_DEFINE(HAVE_UTMP_UT_TYPE)
844 fi
845
846 dnl -------------
847 dnl CHECK SIGNALS
848 dnl -------------
849 dnl What style of signal do you have (POSIX, BSD, or SYSV)?
850 AC_MSG_CHECKING(what style of signals to use)
851 if test $ac_cv_func_sigaction = yes -a $ac_cv_func_sigprocmask = yes; then
852   signals_style=POSIX_SIGNALS
853   AC_DEFINE(POSIX_SIGNALS)
854   AC_DEFINE(RELIABLE_SIGNALS)
855 elif test $ac_cv_func_sigblock = yes -a $ac_cv_func_sigsetmask = yes; then
856   signals_style=BSD_SIGNALS
857   AC_DEFINE(BSD_SIGNALS)
858   AC_DEFINE(RELIABLE_SIGNALS)
859 elif test $ac_cv_func_sighold = yes -a $ac_cv_func_sigrelse = yes; then
860   signals_style=SYSV_SIGNALS
861   AC_DEFINE(SYSV_SIGNALS)
862 else
863   signals_style=NO_SIGNAL_BLOCKING
864   AC_DEFINE(NO_SIGNAL_BLOCKING)
865 fi
866
867 AC_MSG_RESULT($signals_style)
868
869 dnl Where is <signal.h> located?  Needed as input for signames.awk
870 AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h,
871 [for SIGNAL_H in /usr/include/bsd/sys/signal.h  dnl Next
872                  /usr/include/asm/signal.h      dnl Linux 1.3.0 and above
873                  /usr/include/asm/signum.h      dnl some versions of Linux/Alpha
874                  /usr/include/linux/signal.h    dnl Linux up to 1.2.11
875                  /usr/include/sys/signal.h      dnl Almost everybody else
876                  /dev/null;                     dnl Just in case we fall through
877 do
878   test -f $SIGNAL_H && \
879   grep '#[      ]*define[       ][      ]*SIG[0-9A-Z]*[         ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \
880   break
881 done
882 nmh_cv_path_signal_h=$SIGNAL_H
883 ])
884 SIGNAL_H=$nmh_cv_path_signal_h
885 AC_SUBST(SIGNAL_H)dnl
886
887 dnl ----------------
888 dnl OS SPECIFIC DEFINES
889 dnl ----------------
890 case "$target_os" in
891
892   solaris2*)
893     AC_DEFINE(SYS5)
894     AC_DEFINE(SVR4)
895     ;;
896   irix*)
897     AC_DEFINE(SYS5)
898     AC_DEFINE(SVR4)
899     ;;
900   osf*)
901     AC_DEFINE(SYS5)
902     AC_DEFINE(SVR4)
903     ;;
904   aix*)
905     AC_DEFINE(SYS5)
906     AC_DEFINE(SVR4)
907     ;;
908   sunos4*)
909     AC_DEFINE(BSD42)
910     ;;
911   freebsd*)  
912     AC_DEFINE(BSD42)
913     AC_DEFINE(BSD44)
914     ;;
915   netbsd*)
916     AC_DEFINE(BSD42)
917     AC_DEFINE(BSD44)
918     ;;
919   openbsd*)
920     AC_DEFINE(BSD42)
921     AC_DEFINE(BSD44)
922     ;;
923   bsd/os*)
924     AC_DEFINE(BSD42)
925     AC_DEFINE(BSD44)
926     ;;
927   sco5*)
928     AC_DEFINE(SYS5)
929     AC_DEFINE(SCO_5_STDIO)
930     ;;
931 esac
932
933
934 dnl ----------------
935 dnl OUTPUT MAKEFILES
936 dnl ----------------
937 AC_CONFIG_FILES(Makefile config/Makefile h/Makefile sbr/Makefile uip/Makefile \
938                 mts/Makefile mts/smtp/Makefile \
939                 etc/Makefile docs/Makefile man/Makefile)
940 AC_CONFIG_COMMANDS([stamp],[test -z "$CONFIG_HEADERS" || echo > stamp-h])
941 AC_OUTPUT
942
943 dnl Umm, what's the point of these assignments??  -- <dan-nmh@dilvish.speed.net>
944 eval "nmhbin=${bindir}";         eval "nmhbin2=${nmhbin}"
945 eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf2=${nmhsysconf}"
946 eval "nmhlib=${libdir}";         eval "nmhlib2=${nmhlib}"
947 eval "nmhman=${mandir}"
948
949 pop_kinds=no
950 if test x"$enable_pop" = x"yes"; then
951   pop_kinds="yes ("
952
953   if test x"$enable_apop" = x"yes"; then
954     pop_kinds="${pop_kinds}APOP "
955   fi
956
957   if test x"$with_krb4" != x -a x"$with_krb4" != x"no"; then
958     pop_kinds="${pop_kinds}KPOP "
959   fi
960
961   pop_kinds="${pop_kinds}POP3)"
962 fi
963
964 echo "
965 nmh configuration
966 -----------------
967 nmh version                : AC_PACKAGE_VERSION
968 target os                  : ${target}
969 compiler                   : ${CC}
970 compiler flags             : ${CFLAGS}
971 linker flags               : ${LDFLAGS}
972 source code location       : ${srcdir}
973 binary install path        : ${nmhbin2}
974 libary install path        : ${nmhlib2}
975 config files install path  : ${nmhsysconf2}
976 man page install path      : ${nmhman}
977 backup prefix              : ${backup_prefix}
978 transport system           : ${MTS}
979 file locking type          : ${LOCKTYPE}
980 default smtp servers       : ${smtpservers}
981 default editor             : ${editorpath}
982 default pager              : ${pagerpath}
983 email address masquerading : ${masquerade}
984 pop is enabled             : ${pop_kinds}
985 SASL support               : ${sasl_support}"
986 echo ""