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