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