2 dnl configure.in -- autoconf template for nmh
8 AC_CONFIG_HEADER(config.h)
12 dnl ---------------------
13 dnl define a macro or two
14 dnl ---------------------
16 AC_DEFUN(NMH_PROG_GNU_LIBTOOL, [
17 tmptest=`$LIBTOOL --version 2>&1 | grep GNU`
18 if test x"$tmptest" != x ; then
20 AC_SUBST(GNU_LIBTOOL)dnl
25 dnl What version of nmh are we building?
26 VERSION=`sed -e 's/nmh-//' ${srcdir}/VERSION`
27 echo "configuring for nmh-$VERSION"
30 dnl -------------------------
31 dnl CHECK COMMAND LINE OPTION
32 dnl -------------------------
33 dnl What method of posting should post use?
36 [ --with-mts=MTS specify the mail transport agent])
38 if test x$with_mts = xsmtp; then
40 MTSLIB="mts/smtp/libsmtp.a"
42 elif test x$with_mts = xsendmail; then
44 MTSLIB="mts/sendmail/libsend.a"
48 MTSLIB="mts/smtp/libsmtp.a"
55 dnl What should be the default editor?
58 [ --with-editor=EDITOR specify the default editor])
60 if test -n "$with_editor"; then
61 editorpath="$with_editor"
64 dnl What should be the default pager?
67 [ --with-pager=PAGER specify the default pager])
69 if test -n "$with_pager"; then
70 pagerpath="$with_pager"
73 dnl Do you want mhe support?
74 undefine([nmh-mhe])dnl
75 AC_ARG_ENABLE(nmh-mhe,
76 [ --enable-nmh-mhe enable mhe support (DEFAULT)])
78 dnl mhe support is on by default, so define it unless
79 dnl explicitly disabled.
80 if test x$enable_nmh_mhe != xno; then
84 dnl Do you want client-side support for pop
85 undefine([nmh-pop])dnl
86 AC_ARG_ENABLE(nmh-pop,
87 [ --enable-nmh-pop enable client-side support for pop])
88 if test x$enable_nmh_pop = xyes; then
91 POPSED='/^%nmhbeginpop%/d;/^%nmhendpop%/d'
93 POPSED='/^%nmhbeginpop%/,/^%nmhendpop%/d'
98 dnl Do you want client-side support for kpop
100 [ --with-krb4=PREFIX specify location of Kerberos V4 for kpop support])
101 if test x$with_krb4 != x -a x$with_krb4 != xno; then
103 AC_DEFINE(KPOP_PRINCIPAL, "pop")dnl
106 dnl Do you want support for hesiod
108 [ --with-hesiod=PREFIX specify location of Hesiod])
109 if test x$with_hesiod != x -a x$with_hesiod != xno; then
113 dnl Do you want to debug nmh?
114 undefine([nmh-debug])dnl
115 AC_ARG_ENABLE(nmh-debug,
116 [ --enable-nmh-debug enable nmh code debugging])
118 dnl ----------------------------------------------------
119 dnl Default location is /usr/local/nmh/{bin,etc,lib,man}
120 dnl ----------------------------------------------------
121 AC_PREFIX_DEFAULT(/usr/local/nmh)
123 dnl ------------------
124 dnl CHECK THE COMPILER
125 dnl ------------------
126 dnl We want these before the checks,
127 dnl so the checks can modify their values.
128 test -z "$CFLAGS" && CFLAGS= auto_cflags=1
129 if test x$enable_nmh_debug = xyes; then
130 test -z "$LDFLAGS" && LDFLAGS=-g
135 dnl if the user hasn't specified CFLAGS, then
136 dnl if compiler is gcc, then
137 dnl use -O2 and some warning flags
139 if test -n "$auto_cflags"; then
140 if test x$enable_nmh_debug = xyes; then
141 if test -n "$GCC"; then
142 test -z "$CFLAGS" && CFLAGS="-Wall -g" || CFLAGS="$CFLAGS -Wall -g"
144 test -z "$CFLAGS" && CFLAGS=-g || CFLAGS="$CFLAGS -g"
147 test -z "$LDFLAGS" && LDFLAGS=-s
148 if test -n "$GCC"; then
149 test -z "$CFLAGS" && CFLAGS=-O2 || CFLAGS="$CFLAGS -O2"
151 test -z "$CFLAGS" && CFLAGS=-O || CFLAGS="$CFLAGS -O"
156 AC_C_CONST dnl Does compiler support `const'.
158 dnl ------------------
159 dnl CHECK FOR PROGRAMS
160 dnl ------------------
161 AC_PROG_MAKE_SET dnl Does make define $MAKE
162 AC_PROG_INSTALL dnl Check for BSD compatible `install'
163 AC_PROG_RANLIB dnl Check for `ranlib'
164 AC_PROG_AWK dnl Check for mawk,gawk,nawk, then awk
165 AC_PROG_LEX dnl Check for lex/flex
168 pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
169 AC_PATH_PROG(cutpath, cut, no, [$pathtmp])
172 dnl try to figure out which one we've got
173 AC_CHECK_PROG(LIBTOOL, libtool, libtool, , [$pathtmp])
176 dnl Check for lorder and tsort commands
177 AC_CHECK_PROG(LORDER, lorder, lorder, no)dnl
178 AC_CHECK_PROG(TSORT, tsort, tsort, no)dnl
180 dnl If either doesn't exist, replace them with echo and cat
181 if test x$ac_cv_prog_LORDER != xlorder -o x$ac_cv_prog_TSORT != xtsort; then
186 dnl Mac OS X has lorder, but sh is too broken for it to work
187 dnl elif test -z "`lorder config/config.c 2>&1 | grep config/config.c`" ; then
190 dnl AC_SUBST(LORDER)dnl
191 dnl AC_SUBST(TSORT)dnl
195 pathtmp=/usr/bin:/bin:/usr/local/bin:/usr/xpg4/bin:/usr/ucb
196 AC_PATH_PROG(lspath, ls, no, [$pathtmp])
198 dnl See how we get ls to display the owner and the group
199 if test "$lspath" != "no"; then
200 AC_CACHE_CHECK(how to get ls to show us the group ownership of a file,
202 [if test x"`$lspath -dl / | $AWK '{print $9}'`" = x"/"; then
203 dnl There were 9 parameters, so unless this is a really bizarre, nonstandard
204 dnl ls, it would seem -l gave us both the user and group. On this type of
205 dnl ls, -g makes _only_ the group be displayed (and not the user).
206 nmh_cv_ls_grpopt="-l"
208 dnl Looks like -l only gave us the user, so we need -g to get the group too.
209 nmh_cv_ls_grpopt="-lg"
214 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
215 AC_PATH_PROG(morepath, more, no, [$pathtmp])
217 dnl If pager is not specified yet,
218 dnl then use `more' as the default.
219 if test -z "$pagerpath"; then
220 pagerpath="$morepath"
222 AC_SUBST(pagerpath)dnl
224 dnl Look for `sendmail'
225 pathtmp=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin:/bin
226 AC_PATH_PROG(sendmailpath, sendmail, no, [$pathtmp])
229 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
230 AC_PATH_PROG(vipath, vi, no, [$pathtmp])
232 dnl If editor is not specified yet,
233 dnl then use `vi' as the default.
234 if test -z "$editorpath"; then
237 AC_SUBST(editorpath)dnl
239 dnl Check for broken vi
240 AC_CACHE_CHECK(for broken vi, nmh_cv_attvibug,
241 [if echo 'r /nonexist-file
242 q' | ex > /dev/null 2>&1
249 if test "$nmh_cv_attvibug" = yes; then
250 AC_DEFINE(ATTVIBUG)dnl
253 dnl ----------------------------------------------------------
254 dnl FIND MAIL SPOOL AND SEE IF WE NEED TO MAKE inc SETGID MAIL
255 dnl ----------------------------------------------------------
256 AC_CACHE_CHECK(where mail spool is located, nmh_cv_mailspool,
257 [for mailspool in /var/mail dnl
260 /dev/null; dnl Just in case we fall through
262 test -d $mailspool && break
264 nmh_cv_mailspool=$mailspool
266 mailspool=$nmh_cv_mailspool
267 AC_SUBST(mailspool)dnl
269 dnl See whether the mail spool directory is world-writable.
270 if test "$lspath" != "no" -a "$cutpath" != "no"; then
271 AC_CACHE_CHECK(whether the mail spool is world-writable,
272 nmh_cv_mailspool_world_writable,
273 [if test "`$lspath -dlL $mailspool | $cutpath -c9`" = "-"; then
274 nmh_cv_mailspool_world_writable=no
276 nmh_cv_mailspool_world_writable=yes
280 dnl ...If it's not, we need to #define MAILGROUP to 1 and make inc setgid.
281 if test x"$nmh_cv_mailspool_world_writable" = x"no"; then
282 dnl do we really need both of these?
283 AC_DEFINE(MAILGROUP)dnl
286 AC_SUBST(SETGID_MAIL)dnl
288 dnl Use ls to see which group owns the mail spool directory.
289 AC_CACHE_CHECK(what group owns the mail spool, nmh_cv_ls_mail_grp,
290 [nmh_cv_ls_mail_grp=`$lspath -dL $nmh_cv_ls_grpopt $mailspool|$AWK '{print $4}'`
292 MAIL_SPOOL_GRP=$nmh_cv_ls_mail_grp
293 AC_SUBST(MAIL_SPOOL_GRP)dnl
295 dnl ------------------
296 dnl CHECK HEADER FILES
297 dnl ------------------
303 AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
304 limits.h crypt.h termcap.h termio.h termios.h locale.h \
305 netdb.h sys/param.h sys/time.h sys/utsname.h arpa/inet.h \
309 AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
310 [AC_TRY_LINK([#include <sys/types.h>
312 #include <termios.h>],
313 [/* SunOS 4.0.3 has termios.h but not the library calls. */
315 nmh_cv_sys_posix_termios=yes, nmh_cv_sys_posix_termios=no)])
317 if test $nmh_cv_sys_posix_termios = yes; then
318 AC_CACHE_CHECK(TIOCGWINSZ in termios.h,
319 nmh_cv_header_termios_h_tiocgwinsz,
320 [AC_TRY_LINK([#include <sys/types.h>
321 #include <termios.h>],
322 [int x = TIOCGWINSZ;],
323 nmh_cv_header_termios_h_tiocgwinsz=yes,
324 nmh_cv_header_termios_h_tiocgwinsz=no)])
326 nmh_cv_header_termios_h_tiocgwinsz=no
329 if test $nmh_cv_header_termios_h_tiocgwinsz = no; then
330 AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h,
331 nmh_cv_header_sys_ioctl_h_tiocgwinsz,
332 [AC_TRY_LINK([#include <sys/types.h>
333 #include <sys/ioctl.h>],
334 [int x = TIOCGWINSZ;],
335 nmh_cv_header_sys_ioctl_h_tiocgwinsz=yes,
336 nmh_cv_header_sys_ioctl_h_tiocgwinsz=no)])
337 if test $nmh_cv_header_sys_ioctl_h_tiocgwinsz = yes; then
338 AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
343 dnl Checks for _IO_write_ptr. A Linuxism used by nmh on linux. We
344 dnl really use a whole set of them, but this check should be
347 AC_CHECK_HEADER(libio.h, [
348 AC_EGREP_HEADER(_IO_write_ptr, libio.h, [
349 AC_DEFINE(LINUX_STDIO) ]) ])
351 AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM))
357 AC_CHECK_LIB(mkstemp,mkstemp)
358 AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
359 sighold sigrelse writev lstat uname tzset killpg mkstemp \
362 dnl solaris screws this up
363 AC_CHECK_FUNC(gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)],
364 AC_CHECK_LIB(nsl, gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)] ) )
366 dnl sigsetjmp may be a macro
367 AC_MSG_CHECKING(for sigsetjmp)
368 AC_TRY_LINK([#include <setjmp.h>], [sigsetjmp((void *)0, 0);],
369 [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)], AC_MSG_RESULT(no))
371 AC_REPLACE_FUNCS(snprintf strerror strdup)
373 dnl Look for the initgroups() declaration. On AIX 4.[13], Solaris 4.1.3, and
374 dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in
375 dnl any system header.
377 dnl On Solaris 2.[456], the declaration is in <grp.h>. On HP-UX 9-11 and
378 dnl (reportedly) FreeBSD 3.[23], it's in <unistd.h>. Any other locations we
380 AC_EGREP_HEADER(initgroups, grp.h, AC_DEFINE(INITGROUPS_HEADER, <grp.h>),
381 AC_EGREP_HEADER(initgroups, unistd.h,
382 AC_DEFINE(INITGROUPS_HEADER, <unistd.h>)))
384 dnl On AIX 4.1, snprintf() is defined in libc.a but there's no prototype in
385 dnl <stdio.h> or elsewhere. Apparently it's not officially supported (though it
386 dnl seems to work perfectly and IBM apparently uses it in internal code).
387 dnl Anyhow, if we omit our own snprintf() and vsnprintf() prototypes when we
388 dnl HAVE_SNPRINTF, we get a billion warnings at compile time. Use the C
389 dnl preprocessor to preprocess stdio.h and make sure that there's actually a
391 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_PROTOTYPE))
393 dnl -------------------
394 dnl CHECK FOR LIBRARIES
395 dnl -------------------
396 dnl Check location of modf
397 AC_CHECK_FUNC(modf, , AC_CHECK_LIB(m, modf))
399 dnl Checks for network libraries (nsl, socket)
402 dnl Check for bug in libraries such that ruserpass
403 dnl needs to be linked as _ruserpass.
406 termcap_curses_order="termcap curses ncurses"
407 for lib in $termcap_curses_order; do
408 AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
417 AC_CHECK_FUNC(dbm_open, ,
418 AC_CHECK_LIB(ndbm, dbm_open, ,
419 AC_CHECK_LIB(dbm, dbm_open)))
424 AC_CHECK_HEADERS(db1/ndbm.h)
429 if test x$with_hesiod != x -a x$with_hesiod != xno; then
430 if test x$with_hesiod != xyes; then
431 HESIOD_INCLUDES="-I$with_hesiod/include"
432 HESIOD_LIBS="-L$with_hesiod/lib"
434 AC_CHECK_FUNC(res_send, ,
435 AC_CHECK_LIB(resolv, res_send))
436 AC_CHECK_LIB(hesiod, hes_resolve, [HESIOD_LIBS="$HESIOD_LIBS -lhesiod"],
437 [AC_MSG_ERROR(Hesiod library not found)], $HESIOD_LIBS)
439 AC_SUBST(HESIOD_INCLUDES)dnl
440 AC_SUBST(HESIOD_LIBS)dnl
442 dnl ----------------------------------
443 dnl CHECK FOR KRB4 (Kerberos4 support)
444 dnl ----------------------------------
445 if test x$with_krb4 != x -a x$with_krb4 != xno; then
446 if test x$with_krb4 != xyes; then
447 KRB4_INCLUDES="-I$with_krb4/include"
448 if test -d "$with_krb4/include/kerberosIV"; then
449 KRB4_INCLUDES="$KRB4_INCLUDES -I$with_krb4/include/kerberosIV"
451 KRB4_LIBS="-L$with_krb4/lib"
452 elif test -d /usr/include/kerberosIV; then
453 KRB4_INCLUDES="-I/usr/include/kerberosIV"
455 AC_CHECK_LIB(krb4, krb_rd_req,
456 [KRB4_LIBS="$KRB4_LIBS -lkrb4 -ldes425 -lkrb5 -lcrypto -lcom_err"],
457 [AC_CHECK_LIB(krb, krb_rd_req,
458 [KRB4_LIBS="$KRB4_LIBS -lkrb -ldes"],
459 [AC_MSG_ERROR(Kerberos 4 libraries not found)],
461 $KRB4_LIBS -ldes425 -lkrb5 -lcrypto -lcom_err)
463 AC_SUBST(KRB4_INCLUDES)dnl
464 AC_SUBST(KRB4_LIBS)dnl
466 dnl ---------------------
467 dnl CHECK TERMCAP LIBRARY
468 dnl ---------------------
470 dnl Add the termcap library, so that the following configure
471 dnl tests will find it when it tries to link test programs.
472 nmh_save_LIBS="$LIBS"
473 LIBS="$TERMLIB $LIBS"
475 dnl Checks for external variable ospeed in the termcap library.
476 AC_CACHE_CHECK(if an include file defines ospeed,
477 nmh_cv_decl_ospeed_include_defines,
479 [#include <sys/types.h>
485 #endif], [ospeed = 0;],
486 nmh_cv_decl_ospeed_include_defines=yes,
487 nmh_cv_decl_ospeed_include_defines=no)])
489 if test $nmh_cv_decl_ospeed_include_defines = no; then
490 AC_CACHE_CHECK(if you must define ospeed,
491 nmh_cv_decl_ospeed_must_define,
492 [AC_TRY_LINK( ,[extern short ospeed; ospeed = 0;],
493 nmh_cv_decl_ospeed_must_define=yes,
494 nmh_cv_decl_ospeed_must_define=no)])
497 if test $nmh_cv_decl_ospeed_include_defines = yes; then
498 AC_DEFINE(HAVE_OSPEED)
499 elif test $nmh_cv_decl_ospeed_must_define = yes; then
500 AC_DEFINE(HAVE_OSPEED)
501 AC_DEFINE(MUST_DEFINE_OSPEED)
504 dnl dnl Checks if tgetent accepts NULL and will
505 dnl dnl allocate its own termcap buffer.
506 dnl AC_CACHE_CHECK(if tgetent accepts NULL,
507 dnl nmh_cv_func_tgetent_accepts_null,
508 dnl [AC_TRY_RUN([main(){int i = tgetent((char*)0,"vt100");exit(!i || i == -1);}],
509 dnl nmh_cv_func_tgetent_accepts_null=yes,
510 dnl nmh_cv_func_tgetent_accepts_null=no,
511 dnl nmh_cv_func_tgetent_accepts_null=no)])
512 dnl if test $nmh_cv_func_tgetent_accepts_null = yes; then
513 dnl AC_DEFINE(TGETENT_ACCEPTS_NULL)
516 dnl Now put the libraries back to what it was before we
517 dnl starting checking the termcap library.
518 LIBS="$nmh_save_LIBS"
530 dnl Check for sigset_t. Currently I'm looking in
531 dnl <sys/types.h> and <signal.h>. Others might need
533 AC_CACHE_CHECK(for sigset_t, nmh_cv_type_sigset_t,
535 [#include <sys/types.h>
536 #include <signal.h>], [sigset_t tempsigset;],
537 nmh_cv_type_sigset_t=yes, nmh_cv_type_sigset_t=no)])
538 if test $nmh_cv_type_sigset_t = no; then
539 AC_DEFINE(sigset_t, unsigned int)
547 AC_CACHE_CHECK(for tm_gmtoff in struct tm, nmh_cv_struct_tm_gmtoff,
549 [#ifdef TIME_WITH_SYS_TIME
550 # include <sys/time.h>
553 # ifdef TM_IN_SYS_TIME
554 # include <sys/time.h>
559 [struct tm temptm; temptm.tm_gmtoff = 0;],
560 nmh_cv_struct_tm_gmtoff=yes, nmh_cv_struct_tm_gmtoff=no)])
561 if test $nmh_cv_struct_tm_gmtoff = yes; then
562 AC_DEFINE(HAVE_TM_GMTOFF)
568 dnl What style of signal do you have (POSIX, BSD, or SYSV)?
569 AC_MSG_CHECKING(what style of signals to use)
570 if test $ac_cv_func_sigaction = yes -a $ac_cv_func_sigprocmask = yes; then
571 signals_style=POSIX_SIGNALS
572 AC_DEFINE(POSIX_SIGNALS)
573 AC_DEFINE(RELIABLE_SIGNALS)
574 elif test $ac_cv_func_sigblock = yes -a $ac_cv_func_sigsetmask = yes; then
575 signals_style=BSD_SIGNALS
576 AC_DEFINE(BSD_SIGNALS)
577 AC_DEFINE(RELIABLE_SIGNALS)
578 elif test $ac_cv_func_sighold = yes -a $ac_cv_func_sigrelse = yes; then
579 signals_style=SYSV_SIGNALS
580 AC_DEFINE(SYSV_SIGNALS)
582 signals_style=NO_SIGNAL_BLOCKING
583 AC_DEFINE(NO_SIGNAL_BLOCKING)
586 AC_MSG_RESULT($signals_style)
588 dnl Where is <signal.h> located? Needed as input for signames.awk
589 AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h,
590 [for SIGNAL_H in /usr/include/bsd/sys/signal.h dnl Next
591 /usr/include/asm/signal.h dnl Linux 1.3.0 and above
592 /usr/include/asm/signum.h dnl some versions of Linux/Alpha
593 /usr/include/linux/signal.h dnl Linux up to 1.2.11
594 /usr/include/sys/signal.h dnl Almost everybody else
595 /dev/null; dnl Just in case we fall through
597 test -f $SIGNAL_H && \
598 grep '#[ ]*define[ ][ ]*SIG[0-9A-Z]*[ ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \
601 nmh_cv_path_signal_h=$SIGNAL_H
603 SIGNAL_H=$nmh_cv_path_signal_h
604 AC_SUBST(SIGNAL_H)dnl
607 dnl OS SPECIFIC DEFINES
648 AC_DEFINE(SCO_5_STDIO)
656 AC_OUTPUT(Makefile config/Makefile h/Makefile sbr/Makefile uip/Makefile \
657 zotnet/Makefile zotnet/mts/Makefile zotnet/tws/Makefile \
658 zotnet/mf/Makefile zotnet/bboards/Makefile mts/Makefile \
659 mts/smtp/Makefile mts/sendmail/Makefile mts/mmdf/Makefile \
660 etc/Makefile man/Makefile, \
661 [test -z "$CONFIG_HEADERS" || echo > stamp-h])
663 eval "nmhbin=${bindir}"; eval "nmhbin2=${nmhbin}"
664 eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf2=${nmhsysconf}"
665 eval "nmhlib=${libdir}"; eval "nmhlib2=${nmhlib}"
666 eval "nmhman=${mandir}"
671 nmh version : ${VERSION}
672 target os : ${target}
674 compiler flags : ${CFLAGS}
675 linker flags : ${LDFLAGS}
676 source code location : ${srcdir}
677 binary install path : ${nmhbin2}
678 libary install path : ${nmhlib2}
679 config files install path : ${nmhsysconf2}
680 man page install path : ${nmhman}
681 transport system : ${MTS}
682 default editor : ${editorpath}
683 default pager : ${pagerpath}"