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