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