Add check for modf and link with -lm if it's not in libc. Needed for
[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 dnl What version of nmh are we building?
11 VERSION=`sed -e 's/nmh-//' ${srcdir}/VERSION`
12 echo "configuring for nmh-$VERSION"
13 AC_SUBST(VERSION)dnl
14
15 dnl -------------------------
16 dnl CHECK COMMAND LINE OPTION
17 dnl -------------------------
18 dnl What method of posting should post use?
19 undefine([mts])dnl
20 AC_ARG_WITH(mts,
21 [  --with-mts=MTS          specify the mail transport agent])
22
23 if test x$with_mts = xsmtp; then
24   MTS="smtp"
25   MTSLIB="mts/smtp/libsmtp.a"
26   AC_DEFINE(SMTPMTS)dnl
27 elif test x$with_mts = xsendmail; then
28   MTS="sendmail"
29   MTSLIB="mts/sendmail/libsend.a"
30   AC_DEFINE(SENDMTS)dnl
31 else
32   MTS="smtp"
33   MTSLIB="mts/smtp/libsmtp.a"
34   AC_DEFINE(SMTPMTS)dnl
35 fi
36
37 AC_SUBST(MTS)
38 AC_SUBST(MTSLIB)
39
40 dnl What should be the default editor?
41 undefine([editor])dnl
42 AC_ARG_WITH(editor,
43 [  --with-editor=EDITOR    specify the default editor])
44
45 if test -n "$with_editor"; then
46   editorpath="$with_editor"
47 fi
48
49 dnl What should be the default pager?
50 undefine([pager])dnl
51 AC_ARG_WITH(pager,
52 [  --with-pager=PAGER      specify the default pager])
53
54 if test -n "$with_pager"; then
55   pagerpath="$with_pager"
56 fi
57
58 dnl Do you want mhe support?
59 undefine([nmh-mhe])dnl
60 AC_ARG_ENABLE(nmh-mhe,
61 [  --enable-nmh-mhe        enable mhe support (DEFAULT)])
62
63 dnl mhe support is on by default, so define it unless
64 dnl explicitly disabled.
65 if test x$enable_nmh_mhe != xno; then
66   AC_DEFINE(MHE)dnl
67 fi
68
69 dnl Do you want client-side support for pop
70 undefine([nmh-pop])dnl
71 AC_ARG_ENABLE(nmh-pop,
72 [  --enable-nmh-pop        enable client-side support for pop])
73 if test x$enable_nmh_pop = xyes; then
74   AC_DEFINE(POP)dnl
75   POPLIB=popsbr.o
76   POPSED='/^%nmhbeginpop%/d;/^%nmhendpop%/d'
77 else
78   POPSED='/^%nmhbeginpop%/,/^%nmhendpop%/d'
79 fi
80 AC_SUBST(POPLIB)dnl
81 AC_SUBST(POPSED)dnl
82
83 dnl Do you want client-side support for kpop
84 AC_ARG_WITH(krb4,
85 [  --with-krb4=PREFIX      specify location of Kerberos V4 for kpop support])
86 if test x$with_krb4 != x -a x$with_krb4 != xno; then
87   AC_DEFINE(KPOP)dnl
88   AC_DEFINE(KPOP_PRINCIPAL, "pop")dnl
89 fi
90
91 dnl Do you want support for hesiod
92 AC_ARG_WITH(hesiod,
93 [  --with-hesiod=PREFIX    specify location of Hesiod])
94 if test x$with_hesiod != x -a x$with_hesiod != xno; then
95   AC_DEFINE(HESIOD)dnl
96 fi
97
98 dnl Do you want to debug nmh?
99 undefine([nmh-debug])dnl
100 AC_ARG_ENABLE(nmh-debug,
101 [  --enable-nmh-debug      enable nmh code debugging])
102
103 dnl ----------------------------------------------------
104 dnl Default location is /usr/local/nmh/{bin,etc,lib,man}
105 dnl ----------------------------------------------------
106 AC_PREFIX_DEFAULT(/usr/local/nmh)
107
108 dnl ------------------
109 dnl CHECK THE COMPILER
110 dnl ------------------
111 dnl We want these before the checks,
112 dnl so the checks can modify their values.
113 test -z "$CFLAGS" && CFLAGS= auto_cflags=1
114 if test x$enable_nmh_debug = xyes; then
115   test -z "$LDFLAGS" && LDFLAGS=-g
116 fi
117
118 AC_PROG_CC
119
120 dnl if the user hasn't specified CFLAGS, then
121 dnl   if compiler is gcc, then
122 dnl     use -O2 and some warning flags
123 dnl   else use -O
124 if test -n "$auto_cflags"; then
125   if test x$enable_nmh_debug = xyes; then
126     if test -n "$GCC"; then
127       test -z "$CFLAGS" && CFLAGS="-Wall -g" || CFLAGS="$CFLAGS -Wall -g"
128     else
129       test -z "$CFLAGS" && CFLAGS=-g || CFLAGS="$CFLAGS -g"
130     fi
131   else
132     test -z "$LDFLAGS" && LDFLAGS=-s
133     if test -n "$GCC"; then
134       test -z "$CFLAGS" && CFLAGS=-O2 || CFLAGS="$CFLAGS -O2"
135     else
136       test -z "$CFLAGS" && CFLAGS=-O  || CFLAGS="$CFLAGS -O"
137     fi
138   fi
139 fi
140
141 AC_C_CONST              dnl Does compiler support `const'.
142
143 dnl ------------------
144 dnl CHECK FOR PROGRAMS
145 dnl ------------------
146 AC_PROG_MAKE_SET        dnl Does make define $MAKE
147 AC_PROG_INSTALL         dnl Check for BSD compatible `install'
148 AC_PROG_RANLIB          dnl Check for `ranlib'
149 AC_PROG_AWK             dnl Check for mawk,gawk,nawk, then awk
150 AC_PROG_LEX             dnl Check for lex/flex
151
152 dnl Check for lorder and tsort commands
153 AC_CHECK_PROG(LORDER, lorder, lorder, no)dnl
154 AC_CHECK_PROG(TSORT, tsort, tsort, no)dnl
155
156 dnl If either doesn't exist, replace them with echo and cat
157 if test x$ac_cv_prog_LORDER != xlorder -o x$ac_cv_prog_TSORT != xtsort; then
158   LORDER=echo
159   TSORT=cat
160   AC_SUBST(LORDER)dnl
161   AC_SUBST(TSORT)dnl
162 fi
163
164 dnl Look for `sendmail'
165 pathtmp=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin:/bin
166 AC_PATH_PROG(sendmailpath, sendmail, no, [$pathtmp])
167
168 dnl Look for `more'
169 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
170 AC_PATH_PROG(morepath, more, no, [$pathtmp])
171
172 dnl If pager is not specified yet,
173 dnl then use `more' as the default.
174 if test -z "$pagerpath"; then
175   pagerpath="$morepath"
176 fi
177 AC_SUBST(pagerpath)dnl
178
179 dnl Look for `vi'
180 pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
181 AC_PATH_PROG(vipath, vi, no, [$pathtmp])
182
183 dnl If editor is not specified yet,
184 dnl then use `vi' as the default.
185 if test -z "$editorpath"; then
186   editorpath="$vipath"
187 fi
188 AC_SUBST(editorpath)dnl
189
190 dnl Check for broken vi
191 AC_CACHE_CHECK(for broken vi, nmh_cv_attvibug,
192 [if echo 'r /nonexist-file
193 q' | ex > /dev/null 2>&1
194 then
195         nmh_cv_attvibug=no
196 else
197         nmh_cv_attvibug=yes
198 fi])
199  
200 if test "$nmh_cv_attvibug" = yes; then
201   AC_DEFINE(ATTVIBUG)
202 fi
203
204 dnl ---------------
205 dnl FIND MAIL SPOOL
206 dnl ---------------
207 AC_CACHE_CHECK(where mail spool is located, nmh_cv_mailspool,
208 [for mailspool in /var/mail        dnl
209                   /var/spool/mail  dnl
210                   /usr/spool/mail  dnl
211                   /dev/null;       dnl Just in case we fall through
212 do
213   test -d $mailspool && break
214 done
215 nmh_cv_mailspool=$mailspool
216 ])
217 mailspool=$nmh_cv_mailspool
218 AC_SUBST(mailspool)dnl
219
220 dnl ------------------
221 dnl CHECK HEADER FILES
222 dnl ------------------
223 AC_HEADER_DIRENT
224 AC_HEADER_STDC
225 AC_HEADER_TIME
226 AC_HEADER_SYS_WAIT
227 AC_HEADER_STAT
228 AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
229                  limits.h crypt.h termcap.h termio.h termios.h locale.h \
230                  sys/param.h sys/time.h sys/utsname.h arpa/inet.h \
231                  arpa/ftp.h)
232
233 AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
234 [AC_TRY_LINK([#include <sys/types.h>
235 #include <unistd.h>
236 #include <termios.h>],
237 [/* SunOS 4.0.3 has termios.h but not the library calls.  */
238 tcgetattr(0, 0);],
239   nmh_cv_sys_posix_termios=yes, nmh_cv_sys_posix_termios=no)])
240  
241 if test $nmh_cv_sys_posix_termios = yes; then
242   AC_CACHE_CHECK(TIOCGWINSZ in termios.h,
243   nmh_cv_header_termios_h_tiocgwinsz,
244   [AC_TRY_LINK([#include <sys/types.h>
245 #include <termios.h>],
246   [int x = TIOCGWINSZ;],
247   nmh_cv_header_termios_h_tiocgwinsz=yes,
248   nmh_cv_header_termios_h_tiocgwinsz=no)])
249 else
250   nmh_cv_header_termios_h_tiocgwinsz=no
251 fi
252  
253 if test $nmh_cv_header_termios_h_tiocgwinsz = no; then
254   AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h,
255   nmh_cv_header_sys_ioctl_h_tiocgwinsz,
256   [AC_TRY_LINK([#include <sys/types.h>
257 #include <sys/ioctl.h>],
258   [int x = TIOCGWINSZ;],
259   nmh_cv_header_sys_ioctl_h_tiocgwinsz=yes,
260   nmh_cv_header_sys_ioctl_h_tiocgwinsz=no)])
261   if test $nmh_cv_header_sys_ioctl_h_tiocgwinsz = yes; then
262     AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
263   fi
264 fi
265  
266 AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM))
267
268 dnl ---------------
269 dnl CHECK FUNCTIONS
270 dnl ---------------
271 AC_FUNC_VFORK
272 AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
273                sighold sigrelse writev lstat uname tzset killpg \
274                sigsetjmp)
275
276 AC_REPLACE_FUNCS(snprintf strerror strdup)
277
278 dnl -------------------
279 dnl CHECK FOR LIBRARIES
280 dnl -------------------
281 dnl Check location of modf
282 AC_CHECK_FUNC(modf, , AC_CHECK_LIB(m, modf))
283
284 dnl Checks for network libraries (nsl, socket)
285 AC_CHECK_NETLIBS
286
287 dnl Check for bug in libraries such that ruserpass
288 dnl needs to be linked as _ruserpass.
289 AC_CHECK_RUSERPASS
290
291 termcap_curses_order="termcap curses ncurses"
292 for lib in $termcap_curses_order; do
293   AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
294 done
295 AC_SUBST(TERMLIB)dnl
296
297 dnl --------------
298 dnl CHECK FOR NDBM
299 dnl --------------
300 dnl Checks for ndbm
301 AC_CHECK_FUNC(dbm_open, ,
302   AC_CHECK_LIB(ndbm, dbm_open, ,
303     AC_CHECK_LIB(dbm, dbm_open)))
304
305 dnl ----------------
306 dnl CHECK FOR HESIOD
307 dnl ----------------
308 if test x$with_hesiod != x -a x$with_hesiod != xno; then
309   if test x$with_hesiod != xyes; then
310     HESIOD_INCLUDES="-I$with_hesiod/include"
311     HESIOD_LIBS="-L$with_hesiod/lib"
312   fi
313   AC_CHECK_FUNC(res_send, ,
314     AC_CHECK_LIB(resolv, res_send))
315   AC_CHECK_LIB(hesiod, hes_resolve, [HESIOD_LIBS="$HESIOD_LIBS -lhesiod"],
316     [AC_MSG_ERROR(Hesiod library not found)], $HESIOD_LIBS)
317 fi
318 AC_SUBST(HESIOD_INCLUDES)dnl
319 AC_SUBST(HESIOD_LIBS)dnl
320
321 dnl ----------------------------------
322 dnl CHECK FOR KRB4 (Kerberos4 support)
323 dnl ----------------------------------
324 if test x$with_krb4 != x -a x$with_krb4 != xno; then
325   if test x$with_krb4 != xyes; then
326     KRB4_INCLUDES="-I$with_krb4/include"
327     if test -d "$with_krb4/include/kerberosIV"; then
328       KRB4_INCLUDES="$KRB4_INCLUDES -I$with_krb4/include/kerberosIV"
329     fi
330     KRB4_LIBS="-L$with_krb4/lib"
331   elif test -d /usr/include/kerberosIV; then
332     KRB4_INCLUDES="-I/usr/include/kerberosIV"
333   fi
334   AC_CHECK_LIB(krb4, krb_rd_req,
335     [KRB4_LIBS="$KRB4_LIBS -lkrb4 -ldes425 -lkrb5 -lcrypto -lcom_err"],
336     [AC_CHECK_LIB(krb, krb_rd_req,
337       [KRB4_LIBS="$KRB4_LIBS -lkrb -ldes"],
338       [AC_MSG_ERROR(Kerberos 4 libraries not found)],
339       $KRB4_LIBS -ldes)],
340     $KRB4_LIBS -ldes425 -lkrb5 -lcrypto -lcom_err)
341 fi
342 AC_SUBST(KRB4_INCLUDES)dnl
343 AC_SUBST(KRB4_LIBS)dnl
344
345 dnl ---------------------
346 dnl CHECK TERMCAP LIBRARY
347 dnl ---------------------
348
349 dnl Add the termcap library, so that the following configure
350 dnl tests will find it when it tries to link test programs.
351 nmh_save_LIBS="$LIBS"
352 LIBS="$TERMLIB $LIBS"
353
354 dnl Checks for external variable ospeed in the termcap library.
355 AC_CACHE_CHECK(if an include file defines ospeed,
356 nmh_cv_decl_ospeed_include_defines,
357 [AC_TRY_LINK(
358 [#include <sys/types.h>
359 #if HAVE_TERMIOS_H
360 #include <termios.h>
361 #endif
362 #if HAVE_TERMCAP_H
363 #include <termcap.h>
364 #endif], [ospeed = 0;],
365 nmh_cv_decl_ospeed_include_defines=yes,
366 nmh_cv_decl_ospeed_include_defines=no)])
367  
368 if test $nmh_cv_decl_ospeed_include_defines = no; then
369   AC_CACHE_CHECK(if you must define ospeed,
370   nmh_cv_decl_ospeed_must_define,
371   [AC_TRY_LINK( ,[extern short ospeed; ospeed = 0;],
372   nmh_cv_decl_ospeed_must_define=yes,
373   nmh_cv_decl_ospeed_must_define=no)])
374 fi
375  
376 if test $nmh_cv_decl_ospeed_include_defines = yes; then
377   AC_DEFINE(HAVE_OSPEED)
378 elif test $nmh_cv_decl_ospeed_must_define = yes; then
379   AC_DEFINE(HAVE_OSPEED)
380   AC_DEFINE(MUST_DEFINE_OSPEED)
381 fi
382
383 dnl dnl Checks if tgetent accepts NULL and will
384 dnl dnl allocate its own termcap buffer.
385 dnl AC_CACHE_CHECK(if tgetent accepts NULL,
386 dnl nmh_cv_func_tgetent_accepts_null,
387 dnl [AC_TRY_RUN([main(){int i = tgetent((char*)0,"vt100");exit(!i || i == -1);}],
388 dnl   nmh_cv_func_tgetent_accepts_null=yes,
389 dnl   nmh_cv_func_tgetent_accepts_null=no,
390 dnl   nmh_cv_func_tgetent_accepts_null=no)])
391 dnl if test $nmh_cv_func_tgetent_accepts_null = yes; then
392 dnl   AC_DEFINE(TGETENT_ACCEPTS_NULL)
393 dnl fi
394
395 dnl Now put the libraries back to what it was before we
396 dnl starting checking the termcap library.
397 LIBS="$nmh_save_LIBS"
398
399 dnl --------------
400 dnl CHECK TYPEDEFS
401 dnl --------------
402 AC_TYPE_SIGNAL
403 AC_TYPE_PID_T
404 AC_TYPE_OFF_T
405 AC_TYPE_UID_T
406 AC_TYPE_MODE_T
407 AC_TYPE_SIZE_T
408
409 dnl Check for sigset_t.  Currently I'm looking in
410 dnl <sys/types.h> and <signal.h>.  Others might need
411 dnl to be added.
412 AC_CACHE_CHECK(for sigset_t, nmh_cv_type_sigset_t,
413 [AC_TRY_COMPILE(
414 [#include <sys/types.h>
415 #include <signal.h>], [sigset_t tempsigset;],
416   nmh_cv_type_sigset_t=yes, nmh_cv_type_sigset_t=no)])
417 if test $nmh_cv_type_sigset_t = no; then
418   AC_DEFINE(sigset_t, unsigned int)
419 fi
420
421 dnl ----------------
422 dnl CHECK STRUCTURES
423 dnl ----------------
424 AC_STRUCT_ST_BLKSIZE
425
426 AC_CACHE_CHECK(for tm_gmtoff in struct tm, nmh_cv_struct_tm_gmtoff,
427 [AC_TRY_COMPILE(
428 [#ifdef TIME_WITH_SYS_TIME
429 # include <sys/time.h>
430 # include <time.h>
431 #else
432 # ifdef TM_IN_SYS_TIME
433 #  include <sys/time.h>
434 # else
435 #  include <time.h>
436 # endif
437 #endif],
438 [struct tm temptm; temptm.tm_gmtoff = 0;],
439   nmh_cv_struct_tm_gmtoff=yes, nmh_cv_struct_tm_gmtoff=no)])
440 if test $nmh_cv_struct_tm_gmtoff = yes; then
441   AC_DEFINE(HAVE_TM_GMTOFF)
442 fi
443
444 dnl -------------
445 dnl CHECK SIGNALS
446 dnl -------------
447 dnl What style of signal do you have (POSIX, BSD, or SYSV)?
448 AC_MSG_CHECKING(what style of signals to use)
449 if test $ac_cv_func_sigaction = yes -a $ac_cv_func_sigprocmask = yes; then
450   signals_style=POSIX_SIGNALS
451   AC_DEFINE(POSIX_SIGNALS)
452   AC_DEFINE(RELIABLE_SIGNALS)
453 elif test $ac_cv_func_sigblock = yes -a $ac_cv_func_sigsetmask = yes; then
454   signals_style=BSD_SIGNALS
455   AC_DEFINE(BSD_SIGNALS)
456   AC_DEFINE(RELIABLE_SIGNALS)
457 elif test $ac_cv_func_sighold = yes -a $ac_cv_func_sigrelse = yes; then
458   signals_style=SYSV_SIGNALS
459   AC_DEFINE(SYSV_SIGNALS)
460 else
461   signals_style=NO_SIGNAL_BLOCKING
462   AC_DEFINE(NO_SIGNAL_BLOCKING)
463 fi
464
465 AC_MSG_RESULT($signals_style)
466
467 dnl Where is <signal.h> located?  Needed as input for signames.awk
468 AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h,
469 [for SIGNAL_H in /usr/include/bsd/sys/signal.h  dnl Next
470                  /usr/include/asm/signal.h      dnl Linux 1.3.0 and above
471                  /usr/include/asm/signum.h      dnl some versions of Linux/Alpha
472                  /usr/include/linux/signal.h    dnl Linux up to 1.2.11
473                  /usr/include/sys/signal.h      dnl Almost everybody else
474                  /dev/null;                     dnl Just in case we fall through
475 do
476   test -f $SIGNAL_H && \
477   grep '#[      ]*define[       ][      ]*SIG[0-9A-Z]*[         ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \
478   break
479 done
480 nmh_cv_path_signal_h=$SIGNAL_H
481 ])
482 SIGNAL_H=$nmh_cv_path_signal_h
483 AC_SUBST(SIGNAL_H)dnl
484
485 dnl ----------------
486 dnl OUTPUT MAKEFILES
487 dnl ----------------
488 AC_OUTPUT(Makefile config/Makefile h/Makefile sbr/Makefile uip/Makefile \
489           zotnet/Makefile zotnet/mts/Makefile zotnet/tws/Makefile \
490           zotnet/mf/Makefile zotnet/bboards/Makefile mts/Makefile \
491           mts/smtp/Makefile mts/sendmail/Makefile mts/mmdf/Makefile \
492           etc/Makefile man/Makefile, \
493           [test -z "$CONFIG_HEADERS" || echo > stamp-h])
494
495 eval "nmhbin=${bindir}";         eval "nmhbin2=${nmhbin}"
496 eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf2=${nmhsysconf}"
497 eval "nmhlib=${libdir}";         eval "nmhlib2=${nmhlib}"
498 eval "nmhman=${mandir}"
499
500 echo "
501 nmh configuration
502 -----------------
503 nmh version               : ${VERSION}
504 compiler                  : ${CC}
505 compiler flags            : ${CFLAGS}
506 linker flags              : ${LDFLAGS}
507 source code location      : ${srcdir}
508 binary install path       : ${nmhbin2}
509 libary install path       : ${nmhlib2}
510 config files install path : ${nmhsysconf2}
511 man page install path     : ${nmhman}
512 transport system          : ${MTS}
513 default editor            : ${editorpath}
514 default pager             : ${pagerpath}"
515 echo ""