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