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