xref: /netbsd-src/external/bsd/ntp/dist/configure.ac (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1dnl -*-fundamental-*-
2dnl Process this file with autoconf to produce a configure script.
3m4_include([version.m4])
4AC_PREREQ(2.61)
5AC_INIT([ntp], [VERSION_NUMBER])
6AC_CONFIG_MACRO_DIR([m4])
7AC_CONFIG_AUX_DIR([.])
8
9# Increment ntp_configure_cache_version by one for each change to
10# configure.ac or .m4 files which invalidates cached values from
11# previous versions.
12#
13# If the change affects cache variables used only by the main NTP
14# configure.ac, then only its version number should be bumped, while
15# the subdir configure.ac version numbers should be unchanged.  The
16# same is true for a test/variable that is used only by one subdir
17# being changed incompatibly; only that subdir's cache version needs
18# bumping.
19#
20# If a change affects variables shared by all NTP configure scripts,
21# please bump the version numbers of all three.  If you are not sure,
22# the safe choice is to bump all three on any cache-invalidating change.
23#
24# In order to avoid the risk of version stamp collision between -stable
25# and -dev branches, do not simply increment the version, instead use
26# the date YYYYMMDD optionally with -HHMM if there is more than one
27# bump in a day.
28
29ntp_configure_cache_version=20091117
30
31# When the cache version of config.cache and configure do not
32# match, NTP_CACHEVERSION will flush the cache.
33
34NTP_CACHEVERSION([main], [$ntp_configure_cache_version])
35
36AM_INIT_AUTOMAKE
37AC_CANONICAL_BUILD
38AC_CANONICAL_HOST
39dnl the 'build' machine is where we run configure and compile
40dnl the 'host' machine is where the resulting stuff runs.
41AC_DEFINE_UNQUOTED(STR_SYSTEM, "$host", [canonical system (cpu-vendor-os) of where we should run])
42AM_CONFIG_HEADER([config.h])
43dnl AC_ARG_PROGRAM
44
45ac_cv_var_atom_ok=no
46ac_cv_var_oncore_ok=no
47ac_cv_var_parse_ok=no
48ac_cv_var_ripe_ncc_ok=no
49ac_cv_var_jupiter_ok=no
50
51dnl Grab any initial CFLAGS so we can pick better defaults.
52iCFLAGS="$CFLAGS"
53
54dnl check these early to avoid autoconf warnings
55AC_AIX
56AC_MINIX
57
58# So far, the only shared library we might use is libopts.
59# It's a small library - we might as well use a static version of it.
60AC_DISABLE_SHARED
61
62dnl  we need to check for cross compile tools for vxWorks here
63AC_PROG_CC
64# Ralf Wildenhues: With per-target flags we need CC_C_O
65# AM_PROG_CC_C_O supersets AC_PROG_CC_C_O
66AM_PROG_CC_C_O
67AC_PROG_CPP
68AC_PROG_YACC
69
70# AC_PROG_CC_STDC has two functions.  It attempts to find a compiler
71# capable of C99, or failing that, for C89.  CC is set afterward with
72# the selected invocation, such as "gcc --std=gnu99".  Also, the
73# ac_cv_prog_cc_stdc variable is no if the compiler selected for CC
74# does not accept C89.
75
76AC_PROG_CC_STDC
77
78case "$ac_cv_prog_cc_stdc" in
79 no)
80    AC_MSG_WARN([ANSI C89/ISO C90 is the minimum to compile NTP ]
81		[version 4.2.5 and higher.])
82esac
83
84# HMS: These need to be moved to AM_CPPFLAGS and/or AM_CFLAGS
85case "$host" in
86 *-*-amigaos)
87    CFLAGS="$CFLAGS -Dfork=vfork -DSYS_AMIGA"
88    ;;
89 *-*-hpux10.*)	# at least for hppa2.0-hp-hpux10.20
90    case "$GCC" in
91     yes)
92	;;
93     *) CFLAGS="$CFLAGS -Wp,-H18816"
94	;;
95    esac
96    ;;
97 *-pc-cygwin*)
98    CFLAGS="$CFLAGS -DSYS_CYGWIN32"
99    ;;
100 i386-sequent-sysv4)
101    case "$CC" in
102     cc)
103	CFLAGS="$CFLAGS -Wc,+abi-socket"
104	;;
105    esac
106    ;;
107 *-*-mpeix*)
108    CPPFLAGS="$CPPFLAGS -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB"
109    LDFLAGS="$LDFLAGS -L/SYSLOG/PUB"
110    LIBS="$LIBS -lcurses"
111    ;;
112 *-*-solaris*)
113    # see "man standards".
114    # -D_XOPEN_SOURCE=500 is probably OK for c89 and before
115    # -D_XOPEN_SOURCE=600 seems OK for c99
116    #CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
117    CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
118    libxnet=-lxnet
119    ;;
120esac
121
122AMU_OS_CFLAGS
123NTP_DIR_SEP
124NTP_VPATH_HACK
125
126# NTP has (so far) been relying on leading-edge autogen.
127# Therefore, by default:
128# - use the version we ship with
129# - do not install it
130# - build a static copy (AC_DISABLE_SHARED - done earlier)
131case "${enable_local_libopts+set}" in
132 set) ;;
133 *) enable_local_libopts=yes ;;
134esac
135case "${enable_libopts_install+set}" in
136 set) ;;
137 *) enable_libopts_install=no ;;
138esac
139LIBOPTS_CHECK(libopts)
140
141AC_FUNC_FORK
142
143AC_CACHE_CHECK(
144    [if $CC can handle @%:@warning],
145    ac_cv_cpp_warning,
146    [
147	AC_COMPILE_IFELSE(
148	    AC_LANG_PROGRAM([], [#warning foo]),
149	    [ac_cv_cpp_warning=yes],
150	    [ac_cv_cpp_warning=no],
151	)
152    ]
153)
154
155case "$ac_cv_cpp_warning" in
156 no)
157    AC_DEFINE([NO_OPTION_NAME_WARNINGS], [1], [Should we avoid @%:@warning on option name collisions?])
158esac
159
160case "$GCC" in
161 yes)
162    SAVED_CFLAGS_AC="$CFLAGS"
163    CFLAGS="$CFLAGS -Wstrict-overflow"
164    AC_CACHE_CHECK(
165	[if $CC can handle -Wstrict-overflow],
166	ac_cv_gcc_Wstrict_overflow,
167	[
168	    AC_COMPILE_IFELSE(
169		[AC_LANG_PROGRAM([], [])],
170		[ac_cv_gcc_Wstrict_overflow=yes],
171		[ac_cv_gcc_Wstrict_overflow=no]
172	    )
173	]
174    )
175    CFLAGS="$SAVED_CFLAGS_AC"
176    $as_unset SAVED_CFLAGS_AC
177    #
178    # $ac_cv_gcc_Wstrict_overflow is tested later to add the
179    # flag to CFLAGS.
180    #
181esac
182
183
184case "$GCC" in
185 yes)
186    SAVED_CFLAGS_AC="$CFLAGS"
187    CFLAGS="$CFLAGS -Winit-self"
188    AC_CACHE_CHECK(
189	[if $CC can handle -Winit-self],
190	ac_cv_gcc_Winit_self,
191	[
192	    AC_COMPILE_IFELSE(
193		[AC_LANG_PROGRAM([], [])],
194		[ac_cv_gcc_Winit_self=yes],
195		[ac_cv_gcc_Winit_self=no]
196	    )
197	]
198    )
199    CFLAGS="$SAVED_CFLAGS_AC"
200    $as_unset SAVED_CFLAGS_AC
201    #
202    # $ac_cv_gcc_Winit_self is tested later to add the
203    # flag to CFLAGS.
204    #
205esac
206
207# Expose a cross-compilation indicator to makefiles
208AM_CONDITIONAL(NTP_CROSSCOMPILE, test $build != $host)
209
210AC_MSG_CHECKING([for bin subdirectory])
211AC_ARG_WITH(binsubdir,
212	AC_HELP_STRING([--with-binsubdir], [bin ={bin,sbin}]),
213	use_binsubdir="$withval", use_binsubdir="bin")
214
215case "$use_binsubdir" in
216 bin)
217    ;;
218 sbin)
219    ;;
220 *)
221    AC_MSG_ERROR([<$use_binsubdir> is illegal - must be "bin" or "sbin"])
222    ;;
223esac
224AC_MSG_RESULT($use_binsubdir)
225BINSUBDIR=$use_binsubdir
226AC_SUBST(BINSUBDIR)
227
228AC_MSG_CHECKING([if we want to use arlib])
229AC_ARG_WITH(arlib,
230	AC_HELP_STRING([--with-arlib], [- Compile the async resolver library?]),
231	[ans=$withval], [ans=no])
232AC_MSG_RESULT([$ans])
233
234if test -d $srcdir/arlib
235then
236    case "$ans" in
237     yes)
238	ARLIB_DIR=arlib
239	AC_CONFIG_SUBDIRS(arlib)
240	;;
241    esac
242fi
243AC_SUBST(ARLIB_DIR)
244
245AC_ARG_WITH(rpath,
246	AC_HELP_STRING([--without-rpath], [s Disable auto-added -R linker paths]),
247[ans=$withval], [ans=x])
248case "$ans" in
249 no)
250    need_dash_r=
251    ;;
252 yes)
253    need_dash_r=1
254    ;;
255esac
256# HMS: Why isn't this $build?
257# Well, that depends on if we need this for the build toolchain or
258# for info in the host executable...
259# I still have no idea which way this should go, but nobody has complained.
260case "$host" in
261 *-*-netbsd*)
262    case "$need_dash_r" in
263     no) ;;
264     *)  need_dash_r=1
265	 ;;
266    esac
267    ;;
268 *-*-solaris*)
269    case "$need_dash_r" in
270     no) ;;
271     *)  need_dash_r=1
272	 ;;
273    esac
274    ;;
275esac
276
277case "$build" in
278 $host)
279    ;;
280 *) case "$host" in
281     *-*-vxworks*)
282	# Quick and dirty sanity check
283	case "$VX_KERNEL" in
284	 '') AC_MSG_ERROR(Please follow the directions in html/build/hints/vxworks.html!)
285	    ;;
286	esac
287        CFLAGS="$CFLAGS -DSYS_VXWORKS"
288        ;;
289    esac
290    ;;
291esac
292
293dnl  we need to check for cross compile tools for vxWorks here
294AC_PROG_AWK
295AC_PROG_MAKE_SET
296
297rm -f conftest*
298
299case "$GCC" in
300 yes)
301    CFLAGS="$CFLAGS -Wall"
302    # CFLAGS="$CFLAGS -Wcast-align"
303    CFLAGS="$CFLAGS -Wcast-qual"
304    # CFLAGS="$CFLAGS -Wconversion"
305    # CFLAGS="$CFLAGS -Werror"
306    # CFLAGS="$CFLAGS -Wextra"
307    # CFLAGS="$CFLAGS -Wfloat-equal"
308    CFLAGS="$CFLAGS -Wmissing-prototypes"
309    CFLAGS="$CFLAGS -Wpointer-arith"
310    CFLAGS="$CFLAGS -Wshadow"
311    # CFLAGS="$CFLAGS -Wtraditional"
312    # CFLAGS="$CFLAGS -Wwrite-strings"
313    case "$ac_cv_gcc_Winit_self" in
314     yes)
315	CFLAGS="$CFLAGS -Winit-self"
316    esac
317    case "$ac_cv_gcc_Wstrict_overflow" in
318     yes)
319	CFLAGS="$CFLAGS -Wstrict-overflow"
320    esac
321    # if building with OpenSSL, -Wno-strict-prototypes is added later
322esac
323
324case "$host" in
325 *-next-nextstep3)
326    CFLAGS="$CFLAGS -posix"
327    ;;
328dnl This is currently commented out by bor.
329dnl The new versions of ReliantUNIX round adjtime() interval down
330dnl to 1/100s (system tick). This makes tickadj actually useless.
331dnl So, I'd better not use additional flags.
332dnl I leave it here just in case anybody has better idea
333dnl  mips-sni-sysv4* )
334dnl     #
335dnl     # Add flags for 64 bit file access to enable tickadj to access /dev/kmem
336dnl     #
337dnl     if getconf _LFS_CFLAGS > /dev/null 2>&1 ; then
338dnl       CFLAGS="$CFLAGS `getconf _LFS_CFLAGS`"
339dnl     fi
340dnl     ;;
341esac
342
343ac_busted_vpath_in_make=no
344
345case "$build" in
346 *-*-irix6.1*)	# 64 bit only
347    # busted vpath?
348    ;;
349 *-*-irix6*)	# 6.2 (and later?)
350    ac_busted_vpath_in_make=yes
351    ;;
352 *-*-solaris2.5.1)
353    ac_busted_vpath_in_make=yes
354    ;;
355 *-*-unicosmp*)
356    ac_busted_vpath_in_make=yes
357    ;;
358esac
359
360case "$ac_busted_vpath_in_make$srcdir" in
361 no*) ;;
362 yes.) ;;
363 *) case "`${MAKE-make} -v -f /dev/null 2>/dev/null | sed -e 's/GNU Make version \(1-9.]*\).*/\1/' -e q`" in
364     '')
365	AC_MSG_ERROR([building outside of the main directory requires GNU make])
366	;;
367     *) ;;
368    esac
369    ;;
370esac
371
372AC_SUBST(CFLAGS)dnl
373AC_SUBST(LDFLAGS)dnl
374
375m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
376m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
377
378AC_PROG_LIBTOOL
379
380AC_PROG_LN_S
381AC_PROG_GCC_TRADITIONAL
382AC_C_VOLATILE
383AC_ISC_POSIX
384AC_PATH_PROG(PATH_SH, sh)
385AC_PATH_PROG(PATH_PERL, perl)
386
387AC_ARG_WITH(net-snmp-config,
388	AC_HELP_STRING([--with-net-snmp-config], [+ =net-snmp-config]),
389[ans=$withval], [ans=yes])
390case "$ans" in
391 no) ;;
392 yes)
393    ans=net-snmp-config
394    ;;
395 /*) ;;
396 */*)
397    AC_MSG_ERROR([--with-net-snmp-config takes either a name or an absolute path])
398    ;;
399 *)
400    ;;
401esac
402PROG_NET_SNMP_CONFIG=$ans
403AC_MSG_CHECKING([for net-snmp-config path])
404case "$PROG_NET_SNMP_CONFIG" in
405 no) ;;
406 /*)
407    PATH_NET_SNMP_CONFIG=$PROG_NET_SNMP_CONFIG
408    ;;
409 *) AC_PATH_PROG([PATH_NET_SNMP_CONFIG], [$PROG_NET_SNMP_CONFIG])
410    ;;
411esac
412AC_MSG_RESULT([$PATH_NET_SNMP_CONFIG])
413
414case "$host" in
415 *-*-vxworks*)
416    ac_link="$ac_link $VX_KERNEL"
417    ;;
418esac
419
420AC_PROG_INSTALL
421
422case "$host" in
423 *-pc-cygwin*)
424    AC_CHECK_LIB(advapi32, main)
425    ;;
426esac
427
428AC_CHECK_FUNC([gethostent], ,
429  AC_SEARCH_LIBS([gethostent], [nsl], , , [$libxnet -lsocket]))
430AC_CHECK_FUNC([openlog], ,
431  AC_SEARCH_LIBS([openlog], [gen], ,
432  AC_SEARCH_LIBS([openlog], [syslog], , , [$libxnet -lsocket])))
433AC_SEARCH_LIBS([MD5Init], [md5 md])
434AC_CHECK_FUNCS(MD5Init)
435
436NTP_LINEEDITLIBS
437
438dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt
439dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt,
440dnl so only use one of them.  Linux (glibc-2.1.2 and -2.2.2, at least)
441dnl does Strange Things with extra processes using the Posix-compatibility
442dnl real-time library, so we don't want to use it.
443dnl
444dnl 081118 Harlan got tired of looking for a way to get the sched*()
445dnl functions to link OK with either cc or gcc.
446
447case "$host" in
448 *-*-*linux*) ;;
449 *-*-osf4*) ;;
450 *-*-osf5*) ;;
451 *)
452    AC_CHECK_LIB(rt, sched_setscheduler, ,
453	AC_CHECK_LIB(posix4, sched_setscheduler))
454    ;;
455esac
456
457AC_SEARCH_LIBS([setsockopt], [socket xnet])
458AC_SEARCH_LIBS([res_init], [resolv], , , [-lsocket -lnsl])
459AC_CHECK_FUNCS(res_init __res_init)
460
461AC_HEADER_STDC
462AC_CHECK_HEADERS(bstring.h)
463AC_CHECK_HEADER(dns_sd.h,
464	[AC_CHECK_LIB(dns_sd,
465			DNSServiceRegister,
466			[AC_DEFINE(HAVE_DNSREGISTRATION, 1,
467				[Use Rendezvous/DNS-SD registration])])])
468case "$ac_cv_lib_dns_sd_DNSServiceRegister" in
469 yes) LIBS="-ldns_sd $LIBS" ;;
470esac
471AC_CHECK_HEADERS(errno.h fcntl.h ieeefp.h kvm.h math.h)
472
473AC_CHECK_HEADERS(md5.h, [], [],
474[#if HAVE_SYS_TYPES_H
475#include <sys/types.h>
476#endif
477])
478AC_CHECK_HEADERS(memory.h netdb.h poll.h)
479AC_CHECK_HEADERS(sched.h sgtty.h stdlib.h string.h termio.h)
480AC_CHECK_HEADERS(termios.h timepps.h timex.h unistd.h)
481
482case "$host" in
483 *-*-aix*)
484    AC_CHECK_HEADERS(utmpx.h)
485    case "$ac_cv_header_utmpx_h" in
486     yes) ;;
487     *) AC_CHECK_HEADERS(utmp.h) ;;
488    esac
489    ;;
490 *) AC_CHECK_HEADERS(utmp.h utmpx.h) ;;
491esac
492
493#
494# On Suns only (so far) getpass() truncates the typed password to 8
495# characters, but getpassphrase() allows up to 257.  Most systems'
496# getpass() does not truncate, at least not so as to affect ntpq and
497# ntpdc password prompts.
498#
499# So check for getpassphrase(), but only on Sun operating systems.
500#
501
502case "$host" in
503 *-*-sunos*|*-*-solaris*)
504    AC_CHECK_FUNCS(getpassphrase)
505esac
506
507AC_CHECK_HEADERS(arpa/nameser.h)
508AC_CHECK_HEADERS(sys/socket.h)
509AC_CHECK_HEADERS(net/if.h, [], [],
510[#if HAVE_SYS_SOCKET_H
511#include <sys/socket.h>
512#endif
513])
514AC_CHECK_HEADERS(net/if6.h)
515AC_CHECK_HEADERS(net/route.h, [], [], [
516#include <sys/types.h>
517#include <sys/socket.h>
518#include <net/if.h>
519])
520AC_CHECK_HEADERS(netinet/in_system.h netinet/in_systm.h)
521AC_CHECK_HEADERS(netinet/in.h)
522AC_CHECK_HEADERS(netinet/ip.h, [], [],
523[#if HAVE_SYS_TYPES_H
524#include <sys/types.h>
525#endif
526#if HAVE_NETINET_IN_H
527#include <netinet/in.h>
528#endif
529#if HAVE_NETINET_IN_SYSTM_H
530#include <netinet/in_systm.h>
531#endif
532])
533
534# Check for IPTOS_PREC
535AC_CACHE_CHECK(
536    [IPPROTO_IP IP_TOS IPTOS_LOWDELAY],
537    ac_cv_ip_tos,
538    [
539	AC_EGREP_CPP(
540	    [yes],
541	    [
542		#if HAVE_SYS_TYPES_H
543		#include <sys/types.h>
544		#endif
545		#if HAVE_NETINET_IP_H
546		#include <netinet/in.h>
547		#include <netinet/ip.h>
548		#endif
549		#if defined(IPPROTO_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY)
550		  yes
551		#endif
552	    ],
553	    [ac_cv_ip_tos=yes],
554	    [ac_cv_ip_tos=no]
555	)
556    ]
557)
558
559case "$ac_cv_ip_tos" in
560 yes)
561    AC_DEFINE(HAVE_IPTOS_SUPPORT, 1, [Do we have IPTOS support?])
562esac
563
564AC_CHECK_HEADERS(netinfo/ni.h, [AC_DEFINE(HAVE_NETINFO, 1, [NetInfo support?])])
565AC_CHECK_HEADERS(sun/audioio.h sys/audioio.h)
566dnl AC_CHECK_HEADERS(sys/chudefs.h)
567AC_CHECK_HEADERS(sys/clkdefs.h sys/file.h)
568case "$host" in
569 *-*-sunos4*) ;;
570 *) AC_CHECK_HEADERS(sys/ioctl.h)
571    ;;
572esac
573AC_CHECK_HEADERS(sys/ipc.h)
574AC_CHECK_HEADERS(sys/lock.h sys/mman.h sys/modem.h sys/param.h sys/ppsclock.h)
575# HMS: Check sys/proc.h and sys/resource.h after some others
576AC_CHECK_HEADERS(sys/ppstime.h)
577case "$ac_cv_header_sched_h" in
578 yes) ;;
579 *) AC_CHECK_HEADERS(sys/sched.h) ;;
580esac
581case "$host" in
582 *-*-sco*)
583    AC_CHECK_HEADERS(sys/sio.h)
584    ;;
585esac
586# HMS: Check sys/shm.h after some others
587AC_CHECK_HEADERS(sys/select.h sys/signal.h sys/sockio.h)
588# HMS: Checked sys/socket.h earlier
589case "$host" in
590 *-*-netbsd*) ;;
591 *) AC_CHECK_HEADERS(machine/soundcard.h sys/soundcard.h)
592    ;;
593esac
594AC_CHECK_HEADERS(sys/stat.h sys/stream.h)
595AC_CHECK_HEADERS(sys/stropts.h sys/sysctl.h sys/syssgi.h sys/systune.h)
596AC_CHECK_HEADERS(sys/termios.h sys/time.h sys/signal.h)
597AC_EGREP_CPP(yes,
598[#if HAVE_SYS_TIME_H
599# include <sys/time.h>
600#endif
601#if HAVE_ERRNO_H
602# include <errno.h>
603#endif
604#include <sys/timepps.h>
605#ifdef PPS_API_VERS_1
606yes
607#endif
608], [AC_CHECK_HEADERS(sys/timepps.h, [], [],
609[#if HAVE_SYS_TIME_H
610# include <sys/time.h>
611#endif
612#if HAVE_ERRNO_H
613# include <errno.h>
614#endif
615])
616])
617AC_CHECK_HEADERS(sys/timers.h sys/tpro.h sys/types.h sys/wait.h)
618AC_HEADER_TIME
619case "$host" in
620*-convex-*)
621  AC_CHECK_HEADERS(/sys/sync/queue.h /sys/sync/sema.h)
622  ;;
623*-*-bsdi*)
624  AC_CHECK_HEADERS(machine/inline.h sys/pcl720.h sys/i8253.h)
625  ;;
626esac
627
628case "$host" in
629 *-*-*linux*)
630    AC_CHECK_FUNCS(__adjtimex __ntp_gettime)
631    ;;
632esac
633case "$ac_cv_func___adjtimex" in
634 yes) ;;
635 *)
636    AC_CHECK_LIB(elf, nlist)	dnl Only needed for tickadj...
637    dnl AC_CHECK_LIB(kvm, main, , , -lelf)
638    AC_CHECK_LIB(kvm, main)		dnl We already know about -lelf here...
639    AC_CHECK_LIB(ld, nlist)
640    AC_CHECK_LIB(mld, nlist)
641    AC_CHECK_HEADER(nlist.h,
642    [AC_DEFINE(NLIST_STRUCT, 1, [nlist stuff])
643     AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
644      [AC_TRY_COMPILE([#include <nlist.h>],
645       [struct nlist n; n.n_un.n_name = 0;],
646       ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
647     if test $ac_cv_struct_nlist_n_un = yes; then
648       AC_DEFINE(NLIST_NAME_UNION, 1, [does struct nlist use a name union?])
649     fi
650    ])dnl
651    ;;
652esac
653
654dnl AC_CHECK_HEADERS(net/if.h, [], [],
655dnl [#if HAVE_SYS_TYPES_H
656dnl # include <sys/types.h>
657dnl #endif
658dnl #if HAVE_SYS_SOCKET_H
659dnl # include <sys/socket.h>
660dnl #endif
661dnl ])
662
663AC_CHECK_HEADERS(sys/proc.h, [], [],
664[#if HAVE_SYS_TYPES_H
665# include <sys/types.h>
666#endif
667#if HAVE_SYS_TIME_H
668# include <sys/time.h>
669#endif
670])
671
672AC_CHECK_HEADERS(sys/resource.h, [], [],
673[#if HAVE_SYS_TIME_H
674# include <sys/time.h>
675#endif
676])
677
678AC_CHECK_HEADERS(sys/shm.h, [], [],
679[#if HAVE_SYS_TYPES_H
680# include <sys/types.h>
681#endif
682#if HAVE_SYS_IPC_H
683# include <sys/ipc.h>
684#endif
685])
686
687AC_CHECK_HEADERS(sys/timex.h, [], [],
688[#if HAVE_SYS_TIME_H
689# include <sys/time.h>
690#endif
691])
692
693AC_CHECK_HEADERS(resolv.h, [], [],
694[#if HAVE_SYS_TYPES_H
695#include <sys/types.h>
696#endif
697#if HAVE_NETINET_IN_H
698#include <netinet/in.h>
699#endif
700#if HAVE_ARPA_NAMESER_H
701#include <arpa/nameser.h>
702#endif
703])
704
705AC_CACHE_CHECK([for basic volatile support], ac_cv_c_volatile,
706[AC_TRY_COMPILE([],[
707volatile int x;],
708	ac_cv_c_volatile=yes,
709	ac_cv_c_volatile=no)
710])
711case "$ac_cv_c_volatile" in
712 yes)
713    ;;
714 *) AC_DEFINE(volatile, , [Does the compiler like "volatile"?])
715    ;;
716esac
717
718AC_C_CONST
719AC_C_BIGENDIAN
720AC_TYPE_SIGNAL
721AC_TYPE_OFF_T
722AC_TYPE_SIZE_T
723AC_CHECK_TYPE(time_t, long)
724AC_CHECK_SIZEOF(time_t)
725AC_CHECK_TYPES(uintptr_t)
726
727AH_VERBATIM([TYPEDEF_UINTPTR_T],
728[/* Provide a typedef for uintptr_t? */
729#ifndef HAVE_UINTPTR_T
730typedef unsigned int	uintptr_t;
731#define HAVE_UINTPTR_T	1
732#endif])
733
734AC_STRUCT_TM
735
736AC_CACHE_CHECK([for u_int8_t], ac_cv_type_u_int8_t,
737[AC_TRY_COMPILE([#include <sys/types.h>],
738	[u_int8_t len = 42; return 0;],
739	ac_cv_type_u_int8_t=yes,
740	ac_cv_type_u_int8_t=no)
741])
742if test $ac_cv_type_u_int8_t = yes; then
743	AC_DEFINE(HAVE_TYPE_U_INT8_T, 1, [Does u_int8_t exist?])
744fi
745
746AC_CACHE_CHECK([for u_int64_t], ac_cv_type_u_int64_t,
747[AC_TRY_COMPILE([#include <sys/types.h>],
748	[u_int64_t len = 42; return 0;],
749	ac_cv_type_u_int64_t=yes,
750	ac_cv_type_u_int64_t=no)
751])
752if test $ac_cv_type_u_int64_t = yes; then
753	AC_DEFINE(HAVE_TYPE_U_INT64_T, 1, [Does u_int64_t exist?])
754fi
755
756AC_CACHE_CHECK([for a fallback value for HZ], ac_cv_var_default_hz,
757[ac_cv_var_default_hz=100
758case "$host" in
759 alpha*-dec-osf4*|alpha*-dec-osf5*)
760    ac_cv_var_default_hz=1024
761    ;;
762 mips-dec-ultrix4*)
763    ac_cv_var_default_hz=256
764    ;;
765esac])
766AC_DEFINE_UNQUOTED(DEFAULT_HZ, $ac_cv_var_default_hz, [What is the fallback value for HZ?])
767
768AC_CACHE_CHECK([if we need to override the system's value for HZ], ac_cv_var_override_hz,
769[ac_cv_var_override_hz=no
770case "$host" in
771 alpha*-dec-osf4*|alpha*-dec-osf5*)
772    ac_cv_var_override_hz=yes
773    ;;
774 mips-dec-ultrix4*)
775    ac_cv_var_override_hz=yes
776    ;;
777 *-*-freebsd*)
778    ac_cv_var_override_hz=yes
779    ;;
780 *-*-sunos4*)
781    ac_cv_var_override_hz=yes
782    ;;
783esac])
784case "$ac_cv_var_override_hz" in
785 yes)
786    AC_DEFINE(OVERRIDE_HZ, 1, [Do we need to override the system's idea of HZ?])
787    ;;
788esac
789
790dnl AC_CACHE_CHECK(ut_host in struct utmp, ac_cv_func_ut_host_in_utmp,
791dnl [AC_TRY_LINK([#include <sys/types.h>
792dnl #include <utmp.h>], [struct utmp ut; ut.ut_host;],
793dnl ac_cv_func_ut_host_in_utmp=yes, ac_cv_func_ut_host_in_utmp=no)])
794dnl if test $su_cv_func_ut_host_in_utmp = yes; then
795dnl   AC_DEFINE(HAVE_UT_HOST)
796dnl fi
797
798dnl AC_MSG_CHECKING(if we can get the system boot time)
799dnl AC_CACHE_VAL(su_cv_have_boot_time,
800dnl [AC_EGREP_CPP(yes,
801dnl [#ifdef HAVE_UTMPX_H
802dnl #include <utmpx.h>
803dnl #else
804dnl #include <utmp.h>
805dnl #endif
806dnl #ifdef BOOT_TIME
807dnl yes
808dnl #endif
809dnl ], su_cv_have_boot_time=yes, su_cv_have_boot_time=no)])
810dnl AC_MSG_RESULT($su_cv_have_boot_time)
811
812AC_CACHE_CHECK([for struct rt_msghdr], ac_cv_struct_rt_msghdr,
813[AC_TRY_COMPILE([
814#include <sys/types.h>
815#include <sys/socket.h>
816#include <net/if.h>
817#include <net/route.h>],
818[struct rt_msghdr p;],
819	ac_cv_struct_rt_msghdr=yes,
820	ac_cv_struct_rt_msghdr=no)
821])
822
823AC_CACHE_CHECK([for struct rtattr], ac_cv_struct_rtattr,
824[AC_TRY_COMPILE([
825#include <linux/rtnetlink.h>],
826[struct rtattr p;],
827	ac_cv_struct_rtattr=yes,
828	ac_cv_struct_rtattr=no)
829])
830
831if test $ac_cv_struct_rt_msghdr = yes -o $ac_cv_struct_rtattr = yes; then
832    AC_DEFINE(HAS_ROUTING_SOCKET, 1, [Do we have a routing socket (struct rt_msghdr)?])
833    if test $ac_cv_struct_rtattr = yes; then
834        AC_DEFINE(HAVE_RTNETLINK, 1, [Do we have Linux routing socket?])
835    fi
836fi
837
838AC_CACHE_CHECK(
839  [struct sigaction for sa_sigaction],
840  ac_cv_struct_sigaction_has_sa_sigaction,
841  [
842    AC_TRY_COMPILE(
843      [#include <signal.h>],
844      [struct sigaction act; act.sa_sigaction = 0;],
845      ac_cv_struct_sigaction_has_sa_sigaction=yes,
846      ac_cv_struct_sigaction_has_sa_sigaction=no
847    )
848  ]
849)
850if test $ac_cv_struct_sigaction_has_sa_sigaction = yes; then
851  AC_DEFINE(HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION, 1, [Obvious...])
852fi
853
854AC_CACHE_CHECK([for struct ppsclockev], ac_cv_struct_ppsclockev,
855[AC_TRY_COMPILE([
856#include <sys/types.h>
857#ifdef HAVE_SYS_TERMIOS_H
858# include <sys/termios.h>
859#endif
860#ifdef HAVE_SYS_TIME_H
861# include <sys/time.h>
862#endif
863#ifdef HAVE_SYS_PPSCLOCK_H
864# include <sys/ppsclock.h>
865#endif],[
866extern struct ppsclockev *pce;
867return pce->serial;],
868	ac_cv_struct_ppsclockev=yes,
869	ac_cv_struct_ppsclockev=no)
870])
871if test $ac_cv_struct_ppsclockev = yes; then
872    AC_DEFINE(HAVE_STRUCT_PPSCLOCKEV, 1, [Does a system header define struct ppsclockev?])
873fi
874
875AC_CACHE_CHECK(
876    [for struct sockaddr_storage],
877    ntp_cv_sockaddr_storage,
878    [
879	AC_TRY_COMPILE(
880	    [
881		#ifdef HAVE_SYS_TYPES_H
882		# include <sys/types.h>
883		#endif
884		#ifdef HAVE_SYS_SOCKET_H
885		# include <sys/socket.h>
886		#endif
887		#ifdef HAVE_NETINET_IN_H
888		# include <netinet/in.h>
889		#endif
890	    ],
891	    [
892		struct sockaddr_storage n;
893	    ],
894	    [ntp_cv_sockaddr_storage="yes"],
895	    [ntp_cv_sockaddr_storage="no"]
896	)
897    ]
898)
899case "$ntp_cv_sockaddr_storage" in
900 yes)
901    AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Does a system header define struct sockaddr_storage?])
902esac
903
904AC_CACHE_CHECK(
905    [for sockaddr_storage.ss_family],
906    ntp_cv_have_ss_family,
907    [
908	AC_TRY_COMPILE(
909	    [
910		#ifdef HAVE_SYS_TYPES_H
911		# include <sys/types.h>
912		#endif
913		#ifdef HAVE_SYS_SOCKET_H
914		# include <sys/socket.h>
915		#endif
916		#ifdef HAVE_NETINET_IN_H
917		# include <netinet/in.h>
918		#endif
919	    ],
920	    [
921		struct sockaddr_storage s;
922		s.ss_family = 1;
923	    ],
924	    [ntp_cv_have_ss_family="yes"],
925	    [ntp_cv_have_ss_family="no"]
926	)
927    ]
928)
929
930case "$ntp_cv_have_ss_family" in
931 no)
932    AC_CACHE_CHECK(
933	[for sockaddr_storage.__ss_family],
934	ntp_cv_have___ss_family,
935	[
936	    AC_TRY_COMPILE(
937		[
938		    #ifdef HAVE_SYS_TYPES_H
939		    # include <sys/types.h>
940		    #endif
941		    #ifdef HAVE_SYS_SOCKET_H
942		    # include <sys/socket.h>
943		    #endif
944		    #ifdef HAVE_NETINET_IN_H
945		    # include <netinet/in.h>
946		    #endif
947		],
948		[
949		    struct sockaddr_storage s;
950		    s.__ss_family = 1;
951		],
952		[ntp_cv_have___ss_family="yes"],
953		[ntp_cv_have___ss_family="no"]
954	    )
955	]
956    )
957    case "$ntp_cv_have___ss_family" in
958     yes)
959	AC_DEFINE(HAVE___SS_FAMILY_IN_SS, 1, [Does struct sockaddr_storage have __ss_family?])
960    esac
961esac
962
963AH_VERBATIM(
964    [HAVE___SS_FAMILY_IN_SS_VERBATIM],
965    [
966	/* Handle sockaddr_storage.__ss_family */
967	#ifdef HAVE___SS_FAMILY_IN_SS
968	# define ss_family __ss_family
969	#endif /* HAVE___SS_FAMILY_IN_SS */
970    ]
971)
972
973AC_CACHE_CHECK(
974    [for sockaddr_storage.ss_len],
975    ntp_cv_have_ss_len,
976    [
977	AC_TRY_COMPILE(
978	    [
979		#ifdef HAVE_SYS_TYPES_H
980		# include <sys/types.h>
981		#endif
982		#ifdef HAVE_SYS_SOCKET_H
983		# include <sys/socket.h>
984		#endif
985		#ifdef HAVE_NETINET_IN_H
986		# include <netinet/in.h>
987		#endif
988	    ],
989	    [
990		struct sockaddr_storage s;
991		s.ss_len = 1;
992	    ],
993	    [ntp_cv_have_ss_len="yes"],
994	    [ntp_cv_have_ss_len="no"]
995	)
996    ]
997)
998
999case "$ntp_cv_have_ss_len" in
1000 no)
1001    AC_CACHE_CHECK(
1002	[for sockaddr_storage.__ss_len],
1003	ntp_cv_have___ss_len,
1004	[
1005	    AC_TRY_COMPILE(
1006		[
1007		    #ifdef HAVE_SYS_TYPES_H
1008		    # include <sys/types.h>
1009		    #endif
1010		    #ifdef HAVE_SYS_SOCKET_H
1011		    # include <sys/socket.h>
1012		    #endif
1013		    #ifdef HAVE_NETINET_IN_H
1014		    # include <netinet/in.h>
1015		    #endif
1016		],
1017		[
1018		    struct sockaddr_storage s;
1019		    s.__ss_len = 1;
1020		],
1021		[ntp_cv_have___ss_len="yes"],
1022		[ntp_cv_have___ss_len="no"]
1023	    )
1024	]
1025    )
1026    case "$ntp_cv_have___ss_len" in
1027     yes)
1028	AC_DEFINE(HAVE___SS_LEN_IN_SS, 1, [Does struct sockaddr_storage have __ss_len?])
1029    esac
1030esac
1031
1032AH_VERBATIM(
1033    [HAVE___SS_LEN_IN_SS_VERBATIM],
1034    [
1035	/* Handle sockaddr_storage.__ss_len */
1036	#ifdef HAVE___SS_LEN_IN_SS
1037	# define ss_len __ss_len
1038	#endif /* HAVE___SS_LEN_IN_SS */
1039    ]
1040)
1041
1042#
1043# Look for in_port_t.
1044#
1045AC_CACHE_CHECK(
1046    [for in_port_t],
1047    isc_cv_have_in_port_t,
1048    [
1049	AC_TRY_COMPILE(
1050	    [
1051		#include <sys/types.h>
1052		#include <netinet/in.h>
1053	    ],
1054	    [
1055		in_port_t port = 25;
1056		return (0);
1057	    ],
1058	    [isc_cv_have_in_port_t=yes],
1059	    [isc_cv_have_in_port_t=no]
1060	)
1061    ]
1062)
1063case "$isc_cv_have_in_port_t" in
1064 no)
1065	AC_DEFINE(ISC_PLATFORM_NEEDPORTT, 1, [Declare in_port_t?])
1066esac
1067
1068case "$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
1069  *yes*)
1070    AC_CACHE_CHECK([for struct snd_size], ac_cv_struct_snd_size,
1071[AC_TRY_COMPILE([
1072#ifdef HAVE_MACHINE_SOUNDCARD_H
1073# include <machine/soundcard.h>
1074#endif
1075#ifdef HAVE_SYS_SOUNDCARD_H
1076# include <sys/soundcard.h>
1077#endif],[
1078extern struct snd_size *ss;
1079return ss->rec_size;],
1080    ac_cv_struct_snd_size=yes,
1081    ac_cv_struct_snd_size=no)
1082])
1083    case "$ac_cv_struct_snd_size" in
1084     yes) AC_DEFINE(HAVE_STRUCT_SND_SIZE, 1,[Do we have struct snd_size?]) ;;
1085    esac
1086    ;;
1087esac
1088
1089AC_CACHE_CHECK([struct clockinfo for hz], ac_cv_struct_clockinfo_has_hz,
1090[AC_TRY_COMPILE([
1091#include <sys/time.h>],[
1092extern struct clockinfo *pc;
1093return pc->hz;],
1094	ac_cv_struct_clockinfo_has_hz=yes,
1095	ac_cv_struct_clockinfo_has_hz=no)
1096])
1097if test $ac_cv_struct_clockinfo_has_hz = yes; then
1098    AC_DEFINE(HAVE_HZ_IN_STRUCT_CLOCKINFO, 1, [Obvious...])
1099fi
1100
1101AC_CACHE_CHECK([struct clockinfo for tickadj], ac_cv_struct_clockinfo_has_tickadj,
1102[AC_TRY_COMPILE([
1103#include <sys/time.h>],[
1104extern struct clockinfo *pc;
1105return pc->tickadj;],
1106	ac_cv_struct_clockinfo_has_tickadj=yes,
1107	ac_cv_struct_clockinfo_has_tickadj=no)
1108])
1109if test $ac_cv_struct_clockinfo_has_tickadj = yes; then
1110    AC_DEFINE(HAVE_TICKADJ_IN_STRUCT_CLOCKINFO, 1, [Obvious...])
1111fi
1112
1113AC_CACHE_CHECK([for struct timespec], ac_cv_struct_timespec,
1114[AC_TRY_COMPILE([
1115#include <sys/time.h>
1116/* Under SunOS, timespec is in sys/timepps.h, which needs errno.h and FRAC */
1117#ifdef HAVE_ERRNO_H
1118# include <errno.h>
1119#endif
1120#ifdef HAVE_SYS_TIMEPPS_H
1121# define FRAC 4294967296
1122# include <sys/timepps.h>
1123#endif],
1124[struct timespec n;],
1125ac_cv_struct_timespec=yes, ac_cv_struct_timespec=no)])
1126if test $ac_cv_struct_timespec = yes; then
1127  AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [Do we have struct timespec?])
1128fi
1129
1130AC_CACHE_CHECK([for struct ntptimeval], ac_cv_struct_ntptimeval,
1131[AC_TRY_COMPILE([
1132#include <sys/time.h>
1133#include <sys/timex.h>],
1134[struct ntptimeval n;],
1135ac_cv_struct_ntptimeval=yes, ac_cv_struct_ntptimeval=no)])
1136if test $ac_cv_struct_ntptimeval = yes; then
1137  AC_DEFINE(HAVE_STRUCT_NTPTIMEVAL, 1, [Do we have struct ntptimeval?])
1138fi
1139
1140AC_CHECK_MEMBERS([struct ntptimeval.time.tv_nsec], , ,
1141[#ifdef HAVE_SYS_TIME_H
1142#include <sys/time.h>
1143#else
1144# ifdef HAVE_TIME_H
1145# include <time.h>
1146# endif
1147#endif
1148#ifdef HAVE_SYS_TIMEX_H
1149#include <sys/timex.h>
1150#else
1151# ifdef HAVE_TIMEX_H
1152# include <timex.h>
1153# endif
1154#endif])
1155
1156AC_C_INLINE
1157
1158case "$ac_cv_c_inline" in
1159 '')
1160    ;;
1161 *)
1162    AC_DEFINE(HAVE_INLINE,1,[inline keyword or macro available])
1163    AC_SUBST(HAVE_INLINE)
1164esac
1165
1166AC_C_CHAR_UNSIGNED		dnl CROSS_COMPILE?
1167AC_CHECK_SIZEOF(signed char)
1168AC_CHECK_SIZEOF(int)
1169AC_CHECK_SIZEOF(long)
1170
1171AC_CHECK_TYPES([s_char])
1172case "$ac_cv_c_char_unsigned$ac_cv_sizeof_signed_char$ac_cv_type_s_char" in
1173 *yes)
1174    # We have a typedef for s_char.  Might as well believe it...
1175    ;;
1176 no0no)
1177    # We have signed chars, can't say 'signed char', no s_char typedef.
1178    AC_DEFINE(NEED_S_CHAR_TYPEDEF, 1, [Do we need an s_char typedef?])
1179    ;;
1180 no1no)
1181    # We have signed chars, can say 'signed char', no s_char typedef.
1182    AC_DEFINE(NEED_S_CHAR_TYPEDEF)
1183    ;;
1184 yes0no)
1185    # We have unsigned chars, can't say 'signed char', no s_char typedef.
1186    AC_MSG_ERROR(No way to specify a signed character!)
1187    ;;
1188 yes1no)
1189    # We have unsigned chars, can say 'signed char', no s_char typedef.
1190    AC_DEFINE(NEED_S_CHAR_TYPEDEF)
1191    ;;
1192esac
1193AC_TYPE_UID_T
1194
1195case "$host" in
1196 *-*-aix[[456]]*)
1197	# (prr) aix 4.1 doesn't have clock_settime, but in aix 4.3 it's a stub
1198	# (returning ENOSYS).  I didn't check 4.2.  If, in the future,
1199	# IBM pulls its thumbs out long enough to implement clock_settime,
1200	# this conditional will need to change.  Maybe use AC_TRY_RUN
1201	# instead to try to set the time to itself and check errno.
1202    ;;
1203 *)
1204    AC_SEARCH_LIBS([clock_gettime], [rt])
1205    AC_CHECK_FUNCS([clock_gettime clock_settime])
1206    ;;
1207esac
1208AC_CHECK_FUNCS(daemon)
1209AC_CHECK_FUNCS(finite, ,
1210  [AC_CHECK_FUNCS(isfinite, ,
1211    [AC_MSG_CHECKING([for isfinite with <math.h>])
1212    _libs=$LIBS
1213    LIBS="$LIBS -lm"
1214    AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
1215      [AC_MSG_RESULT(yes)
1216      AC_DEFINE(HAVE_ISFINITE)],
1217      AC_MSG_RESULT(no))
1218    LIBS=$_libs])])
1219AC_CHECK_FUNCS(getbootfile getclock getdtablesize)
1220
1221AC_ARG_ENABLE(getifaddrs,
1222    AC_HELP_STRING([--enable-getifaddrs],
1223	[s Enable the use of getifaddrs() [[yes|no|glibc]].
1224glibc: Use getifaddrs() in glibc if you know it supports IPv6.]),
1225    want_getifaddrs="$enableval",  want_getifaddrs="yes")
1226
1227case $want_getifaddrs in
1228yes|glibc)
1229#
1230# Do we have getifaddrs() ?
1231#
1232case $host in
1233*-*linux*)
1234	# Some recent versions of glibc support getifaddrs() which does not
1235	# provide AF_INET6 addresses while the function provided by the USAGI
1236	# project handles the AF_INET6 case correctly.  We need to avoid
1237	# using the former but prefer the latter unless overridden by
1238	# --enable-getifaddrs=glibc.
1239	if test $want_getifaddrs = glibc
1240	then
1241		AC_CHECK_FUNCS(getifaddrs)
1242	else
1243		save_LIBS="$LIBS"
1244		LIBS="-L/usr/local/v6/lib $LIBS"
1245		AC_CHECK_LIB(inet6, getifaddrs,
1246			LIBS="$LIBS -linet6"
1247			AC_DEFINE(HAVE_GETIFADDRS),
1248			LIBS=${save_LIBS})
1249	fi
1250	;;
1251*)
1252	AC_CHECK_FUNCS(getifaddrs)
1253	;;
1254esac
1255;;
1256no)
1257;;
1258esac
1259
1260AC_MSG_CHECKING([type of socklen arg for getsockname()])
1261AC_CACHE_VAL(ac_cv_func_getsockname_arg2,dnl
1262[AC_CACHE_VAL(ac_cv_func_getsockname_socklen_type,dnl
1263 [for ac_cv_func_getsockname_arg2 in 'struct sockaddr *' 'void *'; do
1264  for ac_cv_func_getsockname_socklen_type in 'socklen_t' 'size_t' 'unsigned int' 'int'; do
1265   AC_TRY_COMPILE(dnl
1266[#ifdef HAVE_SYS_TYPES_H
1267#include <sys/types.h>
1268#endif
1269#ifdef HAVE_SYS_SOCKET_H
1270#include <sys/socket.h>
1271#endif
1272extern getsockname (int, $ac_cv_func_getsockname_arg2, $ac_cv_func_getsockname_socklen_type *);],,dnl
1273    [ac_not_found=no ; break 2], ac_not_found=yes)
1274   done
1275  done
1276 ])dnl AC_CACHE_VAL
1277])dnl AC_CACHE_VAL
1278if test "$ac_not_found" = yes; then
1279 ac_cv_func_getsockname_socklen_type='socklen_t'
1280fi
1281AC_MSG_RESULT([$ac_cv_func_getsockname_socklen_type])
1282AC_DEFINE_UNQUOTED([GETSOCKNAME_SOCKLEN_TYPE],
1283		   $ac_cv_func_getsockname_socklen_type,
1284		   [What is getsockname()'s socklen type?])
1285
1286AC_CHECK_FUNCS(getrusage)
1287AC_CHECK_FUNC(gettimeofday, ,[
1288case "$host" in
1289  *-*-mpeix*) ac_cv_func_gettimeofday=yes
1290    ;;
1291esac])
1292case "$host" in
1293 *-pc-cygwin*)
1294    ;;
1295 *) AC_CHECK_FUNCS(getuid)
1296    ;;
1297esac
1298AC_CHECK_FUNCS(hstrerror)
1299
1300#
1301# Check for if_nametoindex() for IPv6 scoped addresses support
1302#
1303AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
1304		ac_cv_have_if_nametoindex=no)
1305case $ac_cv_have_if_nametoindex in
1306 no)
1307	case "$host" in
1308  	*-hp-hpux*)
1309  		AC_CHECK_LIB(ipv6, if_nametoindex,
1310				ac_cv_have_if_nametoindex=yes
1311				LIBS="-lipv6 $LIBS",)
1312  	;;
1313	esac
1314esac
1315case $ac_cv_have_if_nametoindex in
1316 yes)
1317	AC_DEFINE(ISC_PLATFORM_HAVEIFNAMETOINDEX, 1, [ISC: do we have if_nametoindex()?])
1318	;;
1319esac
1320
1321AC_SEARCH_LIBS([inet_ntop], [resolv], , , [-lsocket -lnsl])
1322AC_CHECK_FUNC(inet_ntop, [], [AC_DEFINE(ISC_PLATFORM_NEEDNTOP, 1, [ISC: provide inet_ntop()])])
1323AC_CHECK_FUNC(inet_pton, [], [AC_DEFINE(ISC_PLATFORM_NEEDPTON, 1, [ISC: provide inet_pton()])])
1324case "$ac_cv_header_kvm_h" in
1325 yes)
1326    AC_CHECK_FUNCS(kvm_open)
1327    ;;
1328esac
1329AC_CHECK_FUNCS(memcpy memmove memset)
1330case "$host" in
1331 *-*-sco3.2v5.0.*)
1332    # Just stubs.  Idiots.
1333    ;;
1334 *) AC_CHECK_FUNCS(mkstemp)
1335    ;;
1336esac
1337AC_CHECK_FUNCS(mktime)
1338case "$host" in
1339 *-*-aix[[456]]*)
1340    # Just a stub.  Idiots.
1341    ;;
1342 *-*-irix[[45]]*)
1343    # Just a stub in "old" Irix.  Idiots.
1344    ;;
1345 *-*-*linux*)
1346    # there, but more trouble than it is worth for now (resolver problems)
1347    ;;
1348 *-*-qnx*)
1349    # Apparently there but not working in QNX.  Idiots?
1350    ;;
1351 *-*-sco3.2v5.0.*)
1352    # Just a stub.  Idiots.
1353    ;;
1354 alpha*-dec-osf4*|alpha*-dec-osf5*)
1355    # mlockall is there, as a #define calling memlk via <sys/mman.h>
1356    # Not easy to test for - cheat.
1357    AC_CHECK_FUNCS(memlk, [ac_cv_func_mlockall='yes'])
1358    AC_CHECK_FUNCS(mlockall)
1359    ;;
1360 *) AC_CHECK_FUNCS(mlockall)
1361    ;;
1362esac
1363AC_CHECK_FUNCS(nice nlist)
1364case "$host" in
1365 *-*-solaris2.6)
1366    # Broken...
1367    ;;
1368 *) AC_CHECK_FUNCS(ntp_adjtime ntp_gettime)
1369    ;;
1370esac
1371AC_CHECK_FUNCS(plock pututline pututxline readlink recvmsg rtprio)
1372case "$host" in
1373 *-*-aix[[456]]*)
1374    # Just a stub in AIX 4.  Idiots.
1375    ;;
1376 *-*-solaris2.5*)
1377    # Just stubs in solaris2.5.  Idiots.
1378    ;;
1379 *) AC_CHECK_FUNCS(sched_setscheduler)
1380    ;;
1381esac
1382AC_CHECK_FUNCS(setlinebuf setpgid setpriority setsid)
1383AC_CHECK_FUNCS(setrlimit)
1384AC_CHECK_FUNCS(settimeofday, ,[
1385case "$host" in
1386  *-*-mpeix*) ac_cv_func_settimeofday=yes
1387    ;;
1388esac])
1389AC_CHECK_FUNCS(setvbuf sigaction)
1390AC_CHECK_FUNCS(sigvec sigset sigsuspend stime strchr sysconf sysctl)
1391AC_CHECK_FUNCS(snprintf strdup strerror strstr)
1392AC_CHECK_FUNCS(timegm)
1393case "$host" in
1394 *-*-aix[[456]]*)
1395    # Just stubs.  Idiots.
1396    ;;
1397 *-*-netbsd1*)
1398    # Just stubs.  Idiots.
1399    ;;
1400 *-*-netbsdelf1*)
1401    # Just stubs.  Idiots.
1402    ;;
1403 *-*-openbsd*)
1404    # Just stubs.  Idiots.
1405    ;;
1406 *) AC_CHECK_FUNCS(timer_create timer_settime)
1407    ;;
1408esac
1409case "$host" in
1410 *-pc-cygwin*)
1411    # I have no idea...
1412    ;;
1413 *) AC_CHECK_FUNCS(umask)
1414    ;;
1415esac
1416AC_CHECK_FUNCS(uname updwtmp updwtmpx vsnprintf vsprintf)
1417
1418###
1419
1420# http://bugs.ntp.org/737
1421case "$ac_cv_func_recvmsg" in
1422 yes)
1423 AC_MSG_CHECKING([if we need extra help to define struct iovec])
1424 AC_CACHE_VAL(ac_cv_struct_iovec_help,dnl
1425 [for ac_cv_struct_iovec_help in '0' '1'; do
1426   AC_TRY_COMPILE(dnl
1427[#ifdef HAVE_SYS_TYPES_H
1428#include <sys/types.h>
1429#endif
1430#ifdef HAVE_SYS_SOCKET_H
1431#include <sys/socket.h>
1432#endif
1433#if $ac_cv_struct_iovec_help
1434#include <sys/uio.h>
1435#endif
1436
1437void foo();
1438void foo() {
1439	ssize_t x;
1440	int s = 0;
1441	struct iovec iov;
1442	struct msghdr mh;
1443	int flags = 0;
1444
1445	mh.msg_iov = &iov;
1446	x = recvmsg(s, &mh, flags);
1447}],,dnl
1448  [ac_worked=yes ; break 1], ac_worked=no)
1449  done
1450])dnl AC_CACHE_VAL
1451    case "$ac_worked$ac_cv_struct_iovec_help" in
1452     yes1)
1453	AC_DEFINE(HAVE_SYS_UIO_H, 1, [Use sys/uio.h for struct iovec help])
1454	ans=yes
1455	;;
1456     *) ans=no
1457    esac
1458    AC_MSG_RESULT([$ans])
1459    ;;
1460esac
1461
1462case "$host" in
1463 *-*-sunos4*)
1464    AC_DEFINE(SPRINTF_CHAR, 1, [*s*printf() functions are char*])
1465    ;;
1466esac
1467
1468AC_CACHE_CHECK([number of arguments to gettimeofday()], ac_cv_func_Xettimeofday_nargs,
1469[AC_TRY_COMPILE([#include <sys/time.h>],[
1470gettimeofday((struct timeval*)0,(struct timezone*)0);
1471settimeofday((struct timeval*)0,(struct timezone*)0);
1472],
1473	ac_cv_func_Xettimeofday_nargs=2, ac_cv_func_Xettimeofday_nargs=1)
1474])
1475if test $ac_cv_func_Xettimeofday_nargs = 1; then
1476	AC_DEFINE(SYSV_TIMEOFDAY, 1, [Does Xettimeofday take 1 arg?])
1477fi
1478
1479AC_CACHE_CHECK([number of arguments taken by setpgrp()], ac_cv_func_setpgrp_nargs,
1480[AC_TRY_COMPILE([
1481#ifdef HAVE_SYS_TYPES_H
1482# include <sys/types.h>
1483#endif
1484#ifdef HAVE_UNISTD_H
1485# include <unistd.h>
1486#endif
1487],[setpgrp(0,0);],
1488        ac_cv_func_setpgrp_nargs=2, ac_cv_func_setpgrp_nargs=0)
1489])
1490if test $ac_cv_func_setpgrp_nargs = 0; then
1491        AC_DEFINE(HAVE_SETPGRP_0, 1, [define if setpgrp takes 0 arguments])
1492fi
1493
1494save_CFLAGS=$CFLAGS
1495CFLAGS="$CFLAGS -I$srcdir/include"
1496
1497AC_CACHE_CHECK([argument pointer type of qsort()'s compare function and base],
1498ac_cv_func_qsort_argtype,
1499[AC_TRY_COMPILE([
1500#include "l_stdlib.h"
1501
1502extern void *base;
1503extern sortfunc (const void *, const void *);
1504int sortfunc(a, b)
1505  const void *a;
1506  const void *b; { return 0; }
1507],[
1508qsort(base, 2, sizeof(char *), sortfunc);
1509],
1510	ac_cv_func_qsort_argtype=void, ac_cv_func_qsort_argtype=char)
1511])
1512case "$ac_cv_func_qsort_argtype" in
1513 void)
1514    AC_DEFINE(QSORT_USES_VOID_P, 1, [Does qsort expect to work on "void *" stuff?])
1515    ;;
1516esac
1517
1518CFLAGS=$save_CFLAGS
1519
1520AC_CACHE_CHECK([if we need to declare 'errno'], ac_cv_decl_errno,
1521[AC_TRY_COMPILE([#ifdef HAVE_ERRNO_H
1522#include <errno.h>
1523#endif],
1524  [errno = 0;],
1525  ac_cv_decl_errno=no, ac_cv_decl_errno=yes)])
1526case "$ac_cv_decl_errno" in
1527 yes) AC_DEFINE(DECL_ERRNO, 1, [Declare errno?]) ;;
1528esac
1529
1530dnl FIXME: from ntpd/ntp_intres.c, but there's no info which header produces
1531dnl the clash.  <resolv.h> isn't currently used.
1532dnl
1533dnl (prr) aix 4.3 defines h_errno as (*(int *)h_errno_which()) for
1534dnl MT purposes.  This makes the line "extern int h_errno" choke
1535dnl the compiler.  Hopefully adding !defined(h_errno) fixes this
1536dnl without breaking any other platforms.
1537dnl
1538AC_CACHE_CHECK([if we may declare 'h_errno'], ac_cv_decl_h_errno,
1539[AC_TRY_COMPILE([#include <sys/types.h>
1540#ifdef HAVE_NETINET_IN_H
1541#include <netinet/in.h>
1542#endif
1543#ifdef HAVE_ARPA_NAMESER_H
1544#include <arpa/nameser.h>
1545#endif
1546#ifdef HAVE_NETDB_H
1547#include <netdb.h>
1548#endif
1549#ifdef HAVE_RESOLV_H
1550#include <resolv.h>
1551#endif],
1552  [extern int h_errno;],
1553  ac_cv_decl_h_errno=yes, ac_cv_decl_h_errno=no)])
1554case "$ac_cv_decl_h_errno" in
1555 yes) AC_DEFINE(DECL_H_ERRNO, 1, [Declare h_errno?]) ;;
1556esac
1557
1558dnl See if char *sys_errlist[] is OK.
1559AC_CACHE_CHECK([[if declaring 'char *sys_errlist[]' is ok]], ac_cv_decl_sys_errlist,
1560[AC_TRY_COMPILE([#include <stdio.h>
1561#ifdef HAVE_ERRNO_H
1562#include <errno.h>
1563#endif],
1564  [extern char *sys_errlist[];
1565],
1566  ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])
1567case "$ac_cv_decl_sys_errlist" in
1568 yes) AC_DEFINE(CHAR_SYS_ERRLIST, 1, [Declare char *sys_errlist array]) ;;
1569esac
1570
1571AC_CACHE_CHECK([if declaring 'syscall()' is ok], ac_cv_decl_syscall,
1572[AC_TRY_COMPILE([
1573#ifdef HAVE_SYS_TYPES_H
1574# include <sys/types.h>
1575#endif
1576#ifdef HAVE_UNISTD_H
1577# include <unistd.h>
1578#endif
1579],
1580  [extern int syscall (int, ...);],
1581  ac_cv_decl_syscall=yes, ac_cv_decl_syscall=no)])
1582case "$ac_cv_decl_syscall" in
1583 yes) AC_DEFINE(DECL_SYSCALL, 1, [Declare syscall()?]) ;;
1584esac
1585
1586case "$host" in
1587 *-*-aix4.3.*)
1588    AC_DEFINE(DECL_HSTRERROR_0, 1, [Declaration style])		# Needed for XLC under AIX 4.3.2
1589    ;;
1590 *-*-mpeix*)
1591    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
1592    AC_DEFINE(DECL_INET_NTOA_0, 1, [Declaration style])
1593    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
1594    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
1595    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
1596    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
1597    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
1598    ;;
1599 *-*-osf[[45]]*)
1600    AC_DEFINE(DECL_PLOCK_0, 1, [Declaration style])
1601    AC_DEFINE(DECL_STIME_1, 1, [Declaration style])
1602    ;;
1603 *-*-qnx*)
1604    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
1605    ;;
1606 *-*-riscos4*)
1607    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
1608    AC_DEFINE(DECL_BZERO_0, 1, [Declaration style])
1609    AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
1610    AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
1611    AC_DEFINE(DECL_MEMMOVE_0, 1, [Declaration style])
1612    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
1613    AC_DEFINE(DECL_RENAME_0, 1, [Declaration style])
1614    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
1615    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
1616    AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
1617    AC_DEFINE(DECL_STDIO_0, 1, [Declaration style])
1618    AC_DEFINE(DECL_STRTOL_0, 1, [Declaration style])
1619    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
1620    AC_DEFINE(DECL_TIME_0, 1, [Declaration style])
1621    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
1622    AC_DEFINE(DECL_TOLOWER_0, 1, [Declaration style])
1623    ;;
1624 *-*-solaris2*)
1625    AC_DEFINE(DECL_MKSTEMP_0, 1, [Declaration style])
1626    AC_DEFINE(DECL_SETPRIORITY_1, 1, [Declaration style])
1627    case "$host" in
1628     *-*-solaris2.4)
1629        AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
1630	;;
1631    esac
1632    ;;
1633 *-*-sunos4*)
1634    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
1635    AC_DEFINE(DECL_BCOPY_0, 1, [Declaration style])
1636    AC_DEFINE(DECL_BZERO_0, 1, [Declaration style])
1637    AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
1638    AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
1639    AC_DEFINE(DECL_MEMMOVE_0, 1, [Declaration style])
1640    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
1641    AC_DEFINE(DECL_MKSTEMP_0, 1, [Declaration style])
1642    AC_DEFINE(DECL_RENAME_0, 1, [Declaration style])
1643    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
1644    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
1645    AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
1646    AC_DEFINE(DECL_SIGVEC_0, 1, [Declaration style])
1647    case "`basename $ac_cv_prog_CC`" in
1648     acc*) ;;
1649     *) AC_DEFINE(DECL_STDIO_0, 1, [Declaration style])
1650	;;
1651    esac
1652    AC_DEFINE(DECL_STRTOL_0, 1, [Declaration style])
1653    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
1654    AC_DEFINE(DECL_TIME_0, 1, [Declaration style])
1655    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
1656    AC_DEFINE(DECL_TOLOWER_0, 1, [Declaration style])
1657    AC_DEFINE(DECL_TOUPPER_0, 1, [Declaration style])
1658    AC_DEFINE(DECL_STRERROR_0, 1, [Declaration style])
1659    ;;
1660 *-*-ultrix4*)
1661    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
1662    AC_DEFINE(DECL_BZERO_0, 1, [Declaration style])
1663    AC_DEFINE(DECL_CFSETISPEED_0, 1, [Declaration style])
1664    AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
1665    AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
1666    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
1667    AC_DEFINE(DECL_NLIST_0, 1, [Declaration style])
1668    AC_DEFINE(DECL_PLOCK_0, 1, [Declaration style])
1669    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
1670    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
1671    AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
1672    AC_DEFINE(DECL_STIME_0, 1, [Declaration style])
1673    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
1674    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
1675    ;;
1676esac
1677
1678case "$host" in
1679 *-*-sco3.2*)
1680    AC_DEFINE(TERMIOS_NEEDS__SVID3, 1, [Do we need to #define _SVID3 when we #include <termios.h>?])
1681    ;;
1682esac
1683
1684AC_CACHE_CHECK([if we need extra room for SO_RCVBUF], ac_cv_var_rcvbuf_slop,
1685[ans=no
1686case "$host" in
1687 *-*-hpux[[567]]*)
1688    ans=yes
1689    ;;
1690esac
1691ac_cv_var_rcvbuf_slop=$ans])
1692case "$ac_cv_var_rcvbuf_slop" in
1693 yes) AC_DEFINE(NEED_RCVBUF_SLOP, 1, [Do we need extra room for SO_RCVBUF? (HPUX <8)]) ;;
1694esac
1695
1696AC_CACHE_CHECK([if we will open the broadcast socket], ac_cv_var_open_bcast_socket,
1697[ans=yes
1698case "$host" in
1699 *-*-domainos)
1700    ans=no
1701    ;;
1702esac
1703ac_cv_var_open_bcast_socket=$ans])
1704case "$ac_cv_var_open_bcast_socket" in
1705 yes) AC_DEFINE(OPEN_BCAST_SOCKET, 1, [Should we open the broadcast socket?]) ;;
1706esac
1707
1708AC_CACHE_CHECK([if we want the HPUX version of FindConfig()], ac_cv_var_hpux_findconfig,
1709[ans=no
1710case "$host" in
1711 *-*-hpux*)
1712    ans=yes
1713    ;;
1714esac
1715ac_cv_var_hpux_findconfig=$ans])
1716case "$ac_cv_var_hpux_findconfig" in
1717 yes) AC_DEFINE(NEED_HPUX_FINDCONFIG, 1, [Do we want the HPUX FindConfig()?]) ;;
1718esac
1719
1720AC_CACHE_CHECK([if process groups are set with -pid], ac_cv_arg_setpgrp_negpid,
1721[case "$host" in
1722 *-*-hpux[[567]]*)
1723    ans=no
1724    ;;
1725 *-*-hpux*)
1726    ans=yes
1727    ;;
1728 *-*-*linux*)
1729    ans=yes
1730    ;;
1731 *-*-sunos3*)
1732    ans=yes
1733    ;;
1734 *-*-ultrix2*)
1735    ans=yes
1736    ;;
1737 *)
1738    ans=no
1739    ;;
1740esac
1741ac_cv_arg_setpgrp_negpid=$ans])
1742case "$ac_cv_arg_setpgrp_negpid" in
1743 yes) AC_DEFINE(UDP_BACKWARDS_SETOWN, 1, [Do we set process groups with -pid?]) ;;
1744esac
1745
1746AC_CACHE_CHECK(
1747    [if we need a ctty for F_SETOWN],
1748    ntp_cv_func_ctty_for_f_setown,
1749    [
1750	case "$host" in
1751	 *-*-bsdi[23]*)
1752	    ans=yes
1753	    ;;
1754	 *-*-freebsd*)
1755	    ans=yes
1756	    ;;
1757	# NetBSD versions prior to 3.99.8 require a CTTY for F_SETOWN,
1758	# while later versions will fail a ioctl(TIOCSCTTY, 0) call in
1759	# some cases and so should not have USE_FSETOWNCTTY.  "netbsd"
1760	# in $host may be followed by "aout", "ecoff", or "elf".
1761	 *-*-netbsd*[a-z]3.[0-8]*|*-*-netbsd*[a-z][0-2].*|*-*-netbsd*[a-z]3.99.[0-7])
1762	    ans=yes
1763	    ;;
1764	 *-*-netbsd3.[0-8]*|*-*-netbsd[0-2].*|*-*-netbsd3.99.[0-7])
1765	    ans=yes
1766	    ;;
1767	 *-*-openbsd*)
1768	    ans=yes
1769	    ;;
1770	 *-*-osf*)
1771	    ans=yes
1772	    ;;
1773	 *-*-darwin*)
1774	    ans=yes
1775	    ;;
1776	 *)
1777	    ans=no
1778	esac
1779	ntp_cv_func_ctty_for_f_setown=$ans
1780    ]
1781)
1782case "$ntp_cv_func_ctty_for_f_setown" in
1783 yes)
1784    AC_DEFINE(USE_FSETOWNCTTY, 1, [Must we have a CTTY for fsetown?])
1785esac
1786
1787AC_CACHE_CHECK([if the OS fails to clear cached routes when more specific routes become available], ac_cv_os_routeupdates,
1788[[case "$host" in
1789 *-*-netbsd*)
1790    ans=yes
1791    ;;
1792 *) ans=no
1793    ;;
1794esac
1795ac_cv_os_routeupdates=$ans]])
1796case "$ac_cv_os_routeupdates" in
1797 yes) AC_DEFINE(OS_MISSES_SPECIFIC_ROUTE_UPDATES, 1, [need to recreate sockets on changed routing?]) ;;
1798esac
1799
1800AC_CACHE_CHECK([if the OS needs the wildcard socket set to REUSEADDR for binding interface addresses], ac_cv_os_wildcardreuse,
1801[[case "$host" in
1802 *-*-*linux*)
1803    ans=yes
1804    ;;
1805 *) ans=no
1806    ;;
1807esac
1808ac_cv_os_wildcardreuse=$ans]])
1809case "$ac_cv_os_wildcardreuse" in
1810 yes) AC_DEFINE(OS_NEEDS_REUSEADDR_FOR_IFADDRBIND, 1, [wildcard socket needs to set REUSEADDR when binding to interface addresses]) ;;
1811esac
1812
1813ntp_warning='GRONK'
1814AC_MSG_CHECKING([if we'll use clock_settime or settimeofday or stime])
1815case "$ac_cv_func_clock_settime$ac_cv_func_settimeofday$ac_cv_func_stime" in
1816 yes*)
1817    ntp_warning=''
1818    ans='clock_settime()'
1819    ;;
1820 noyes*)
1821    ntp_warning='But clock_settime() would be better (if we had it)'
1822    ans='settimeofday()'
1823    ;;
1824 nonoyes)
1825    ntp_warning='Which is the worst of the three'
1826    ans='stime()'
1827    ;;
1828 *)
1829    case "$build" in
1830     $host) ntp_warning='Which leaves us with nothing to use!'
1831    ans=none
1832    ;;
1833esac
1834esac
1835AC_MSG_RESULT([$ans])
1836case "$ntp_warning" in
1837 '') ;;
1838 *) AC_MSG_WARN([*** $ntp_warning ***])
1839    ;;
1840esac
1841
1842AC_CACHE_CHECK([if we have a losing syscall()], ac_cv_var_syscall_bug,
1843[case "$host" in
1844 *-*-solaris2.4*)
1845    ans=yes
1846    ;;
1847 *) ans=no
1848    ;;
1849esac
1850ac_cv_var_syscall_bug=$ans])
1851case "$ac_cv_var_syscall_bug" in
1852 yes) AC_DEFINE(SYSCALL_BUG, 1, [Buggy syscall() (Solaris2.4)?]) ;;
1853esac
1854
1855AC_CACHE_CHECK([for SIGIO], ac_cv_hdr_def_sigio,
1856 AC_EGREP_CPP(yes,
1857  [#include <signal.h>
1858#ifdef SIGIO
1859   yes
1860#endif
1861  ], ac_cv_hdr_def_sigio=yes, ac_cv_hdr_def_sigio=no))
1862
1863dnl Override those system that have a losing SIGIO
1864AC_CACHE_CHECK([if we want to use signalled IO], ac_cv_var_signalled_io,
1865[ans=no
1866case "$ac_cv_hdr_def_sigio" in
1867 yes)
1868    ans=yes
1869    case "$host" in
1870     alpha*-dec-osf4*|alpha*-dec-osf5*)
1871        ans=no
1872        ;;
1873     *-convex-*)
1874        ans=no
1875        ;;
1876     *-dec-*)
1877        ans=no
1878        ;;
1879     *-pc-cygwin*)
1880	ans=no
1881	;;
1882     *-sni-sysv*)
1883        ans=no
1884        ;;
1885     *-univel-sysv*)
1886        ans=no
1887	;;
1888     *-*-irix6*)
1889	ans=no
1890	;;
1891     *-*-freebsd*)
1892	ans=no
1893	;;
1894     *-*-*linux*)
1895	ans=no
1896	;;
1897     *-*-unicosmp*)
1898	ans=no
1899	;;
1900    esac
1901    ;;
1902esac
1903ac_cv_var_signalled_io=$ans])
1904case "$ac_cv_var_signalled_io" in
1905 yes) AC_DEFINE(HAVE_SIGNALED_IO, 1, [Can we use SIGIO for tcp and udp IO?]) ;;
1906esac
1907
1908AC_CACHE_CHECK([for SIGPOLL], ac_cv_hdr_def_sigpoll,
1909 AC_EGREP_CPP(yes,
1910 [#include <signal.h>
1911#ifdef SIGPOLL
1912  yes
1913#endif
1914 ], ac_cv_hdr_def_sigpoll=yes, ac_cv_hdr_def_sigpoll=no))
1915
1916AC_CACHE_CHECK([for SIGSYS], ac_cv_hdr_def_sigsys,
1917 AC_EGREP_CPP(yes,
1918 [#include <signal.h>
1919#ifdef SIGSYS
1920  yes
1921#endif
1922 ], ac_cv_hdr_def_sigsys=yes, ac_cv_hdr_def_sigsys=no))
1923
1924AC_CACHE_CHECK([if we can use SIGPOLL for UDP I/O], ac_cv_var_use_udp_sigpoll,
1925[ans=no
1926case "$ac_cv_hdr_def_sigpoll" in
1927 yes)
1928    case "$host" in
1929     mips-sgi-irix*)
1930	ans=no
1931	;;
1932     vax-dec-bsd)
1933        ans=no
1934        ;;
1935     *-pc-cygwin*)
1936	ans=no
1937	;;
1938     *-sni-sysv*)
1939        ans=no
1940        ;;
1941     *-*-aix[[456]]*)
1942        ans=no
1943        ;;
1944     *-*-hpux*)
1945        ans=no
1946        ;;
1947     *-*-*linux*)
1948	ans=no
1949	;;
1950     *-*-osf*)
1951        ans=no
1952        ;;
1953     *-*-qnx*)
1954        ans=no
1955        ;;
1956     *-*-sunos*)
1957	ans=no
1958	;;
1959     *-*-solaris*)
1960	ans=no
1961	;;
1962     *-*-ultrix*)
1963        ans=no
1964        ;;
1965     *-*-unicosmp*)
1966        ans=no
1967        ;;
1968     *) ans=yes
1969        ;;
1970    esac
1971    ;;
1972esac
1973ac_cv_var_use_udp_sigpoll=$ans])
1974case "$ac_cv_var_use_udp_sigpoll" in
1975 yes) AC_DEFINE(USE_UDP_SIGPOLL, 1, [Can we use SIGPOLL for UDP?]) ;;
1976esac
1977
1978AC_CACHE_CHECK([if we can use SIGPOLL for TTY I/O], ac_cv_var_use_tty_sigpoll,
1979[ans=no
1980case "$ac_cv_hdr_def_sigpoll" in
1981 yes)
1982    case "$host" in
1983     mips-sgi-irix*)
1984        ans=no
1985        ;;
1986     vax-dec-bsd)
1987        ans=no
1988        ;;
1989     *-pc-cygwin*)
1990	ans=no
1991	;;
1992     *-sni-sysv*)
1993        ans=no
1994        ;;
1995     *-*-aix[[456]]*)
1996	ans=no
1997	;;
1998     *-*-hpux*)
1999        ans=no
2000        ;;
2001     *-*-*linux*)
2002	ans=no
2003	;;
2004     *-*-osf*)
2005        ans=no
2006        ;;
2007     *-*-sunos*)
2008	ans=no
2009	;;
2010     *-*-ultrix*)
2011        ans=no
2012        ;;
2013     *-*-qnx*)
2014        ans=no
2015        ;;
2016     *-*-unicosmp*)
2017        ans=no
2018        ;;
2019     *) ans=yes
2020        ;;
2021    esac
2022    ;;
2023esac
2024ac_cv_var_use_tty_sigpoll=$ans])
2025case "$ac_cv_var_use_tty_sigpoll" in
2026 yes) AC_DEFINE(USE_TTY_SIGPOLL, 1, [Can we use SIGPOLL for tty IO?]) ;;
2027esac
2028
2029case "$ac_cv_header_sys_sio_h" in
2030 yes)
2031    AC_CACHE_CHECK([sys/sio.h for TIOCDCDTIMESTAMP], ac_cv_hdr_def_tiocdcdtimestamp,
2032     AC_EGREP_CPP(yes,
2033[#include <sys/sio.h>
2034#ifdef TIOCDCDTIMESTAMP
2035  yes
2036#endif
2037     ], ac_cv_hdr_def_tiocdcdtimestamp=yes, ac_cv_hdr_def_tiocdcdtimestamp=no))
2038    ;;
2039esac
2040
2041case "$ac_cv_hdr_def_tiocdcdtimestamp" in
2042 yes)
2043    ac_cv_var_oncore_ok=yes
2044    ;;
2045esac
2046
2047AC_CACHE_CHECK([if nlist() values might require extra indirection],
2048ac_cv_var_nlist_extra_indirection,
2049[ans=no
2050case "$host" in
2051 *-*-aix*)
2052    ans=yes
2053    ;;
2054esac
2055ac_cv_var_nlist_extra_indirection=$ans])
2056case "$ac_cv_var_nlist_extra_indirection" in
2057 yes) AC_DEFINE(NLIST_EXTRA_INDIRECTION, 1, [Might nlist() values require an extra level of indirection (AIX)?]) ;;
2058esac
2059
2060AC_CACHE_CHECK([for a minimum recommended value of tickadj],
2061ac_cv_var_min_rec_tickadj,
2062[ans=no
2063case "$host" in
2064 *-*-aix*)
2065    ans=40
2066    ;;
2067esac
2068ac_cv_var_min_rec_tickadj=$ans])
2069case "$ac_cv_var_min_rec_tickadj" in
2070 ''|no) ;;
2071 *) AC_DEFINE_UNQUOTED(MIN_REC_TICKADJ, $ac_cv_var_min_rec_tickadj, [Should we recommend a minimum value for tickadj?]) ;;
2072esac
2073
2074AC_CACHE_CHECK([if the TTY code permits PARENB and IGNPAR],
2075ac_cv_var_no_parenb_ignpar,
2076[ans=no
2077case "$host" in
2078 i?86-*-*linux*)
2079    ans=yes
2080    ;;
2081 mips-sgi-irix*)
2082    ans=yes
2083    ;;
2084 i?86-*-freebsd[[123]].*)
2085    ;;
2086 i?86-*-freebsd*)
2087    ans=yes
2088    ;;
2089 *-*-unicosmp*)
2090    ans=yes
2091    ;;
2092esac
2093ac_cv_var_no_parenb_ignpar=$ans])
2094case "$ac_cv_var_no_parenb_ignpar" in
2095 yes) AC_DEFINE(NO_PARENB_IGNPAR, 1, [Is there a problem using PARENB and IGNPAR (IRIX)?]) ;;
2096esac
2097
2098AC_MSG_CHECKING([if we're including ntpd debugging code])
2099AC_ARG_ENABLE(debugging,
2100   AC_HELP_STRING([--enable-debugging], [+ include ntpd debugging code]),
2101    [ntp_ok=$enableval], [ntp_ok=yes])
2102if test "$ntp_ok" = "yes"; then
2103    AC_DEFINE(DEBUG, 1, [Enable ntpd debugging code?])
2104fi
2105AC_MSG_RESULT($ntp_ok)
2106
2107AC_MSG_CHECKING([if we including processing time debugging code])
2108AC_ARG_ENABLE(debug-timing,
2109   AC_HELP_STRING([--enable-debug-timing], [- include processing time debugging code (costs performance)]),
2110    [ntp_ok=$enableval], [ntp_ok=no])
2111if test "$ntp_ok" = "yes"; then
2112    AC_DEFINE(DEBUG_TIMING, 1, [Enable processing time debugging?])
2113fi
2114AC_MSG_RESULT($ntp_ok)
2115
2116AC_MSG_CHECKING([[for a the number of minutes in a DST adjustment]])
2117AC_ARG_ENABLE(
2118    [dst_minutes],
2119    AS_HELP_STRING(
2120	[--enable-dst-minutes],
2121	[n minutes per DST adjustment @<:@60@:>@]	dnl @<:@ is [
2122    ),
2123    [ans=$enableval],
2124    [ans=60]
2125)
2126AC_DEFINE_UNQUOTED(DSTMINUTES, $ans, [The number of minutes in a DST adjustment])
2127AC_MSG_RESULT([$ans])
2128
2129AC_MSG_CHECKING([[if ntpd will retry permanent DNS failures]])
2130AC_ARG_ENABLE(
2131    [ignore-dns-errors],
2132    AS_HELP_STRING(
2133	[--enable-ignore-dns-errors],
2134	[- retry DNS queries on any error]
2135    ),
2136    [ans=$enableval],
2137    [ans=no]
2138)
2139case "$ans" in
2140 yes)
2141    AC_DEFINE(IGNORE_DNS_ERRORS, 1, [[Retry queries on _any_ DNS error?]])
2142esac
2143AC_MSG_RESULT([$ans])
2144
2145AC_MSG_CHECKING([if ntpd will use the deferred DNS lookup path])
2146AC_ARG_ENABLE(
2147    [force-defer-DNS],
2148    AS_HELP_STRING(
2149	[--enable-force-defer-DNS],
2150	[- force all DNS lookups to take the deferred path]
2151    ),
2152    [ans=$enableval],
2153    [ans=no]
2154)
2155case "$ans" in
2156 yes)
2157    AC_DEFINE(FORCE_DEFER_DNS, 1, [Force deferred DNS lookups?])
2158esac
2159AC_MSG_RESULT([$ans])
2160
2161AC_CACHE_CHECK([if we have the tty_clk line discipline/streams module],
2162 ac_cv_var_tty_clk,
2163 [case "$ac_cv_header_sys_clkdefs_h$ac_cv_hdr_def_tiocdcdtimestamp" in
2164  *yes*) ac_cv_var_tty_clk=yes ;;
2165  *)     ac_cv_var_tty_clk=no ;;
2166 esac])
2167case "$ac_cv_var_tty_clk" in
2168 yes) AC_DEFINE(TTYCLK, 1, [Do we have the tty_clk line discipline/streams module?]) ;;
2169esac
2170
2171AC_CACHE_CHECK([for the ppsclock streams module],
2172 ac_cv_var_ppsclock,
2173 ac_cv_var_ppsclock=$ac_cv_struct_ppsclockev)
2174case "$ac_cv_var_ppsclock" in
2175 yes) AC_DEFINE(PPS, 1, [Do we have the ppsclock streams module?]) ;;
2176esac
2177
2178AC_CACHE_CHECK([for kernel multicast support], ac_cv_var_mcast,
2179  [ac_cv_var_mcast=no
2180  case "$host" in
2181   i386-sequent-sysv4) ;;
2182   *) AC_EGREP_CPP(yes,
2183  [#include <netinet/in.h>
2184#ifdef IP_ADD_MEMBERSHIP
2185   yes
2186#endif
2187  ], ac_cv_var_mcast=yes) ;;
2188  esac])
2189case "$ac_cv_var_mcast" in
2190 yes)
2191    AC_DEFINE(MCAST, 1, [Does the kernel support multicasting IP?])
2192    AC_CACHE_CHECK([[arg type needed for IP*_MULTICAST_LOOP for setsockopt()]],
2193	ac_cv_var_typeof_ip_multicast_loop,
2194	[case "$host" in
2195	 *-*-netbsd*|*-*-*linux*)
2196	    ac_cv_var_typeof_ip_multicast_loop=u_int
2197	    ;;
2198	 *-*-winnt*)
2199	    ac_cv_var_typeof_ip_multicast_loop=BOOL
2200	    ;;
2201	 *) ac_cv_var_typeof_ip_multicast_loop=u_char
2202	    ;;
2203	esac])
2204    AC_DEFINE_UNQUOTED(TYPEOF_IP_MULTICAST_LOOP,
2205		   $ac_cv_var_typeof_ip_multicast_loop,
2206		   [What type to use for setsockopt])
2207    ;;
2208esac
2209
2210AC_CACHE_CHECK([[availability of ntp_{adj,get}time()]], ac_cv_var_ntp_syscalls,
2211 [ac_cv_var_ntp_syscalls=no
2212 case "$ac_cv_func_ntp_adjtime$ac_cv_func_ntp_gettime$ac_cv_func___adjtimex" in
2213  yesyes*)
2214    ac_cv_var_ntp_syscalls=libc
2215    ;;
2216  *yes)
2217    ac_cv_var_ntp_syscalls=inline
2218    ;;
2219  *) AC_EGREP_CPP(yes,
2220         [#include <sys/syscall.h>
2221#if defined(SYS_ntp_gettime) && defined(SYS_ntp_adjtime)
2222           yes
2223#endif
2224          ], ac_cv_var_ntp_syscalls=kernel)
2225    ;;
2226 esac])
2227case "$ac_cv_var_ntp_syscalls" in
2228 libc)
2229    AC_DEFINE(NTP_SYSCALLS_LIBC, 1, [Do we have ntp_{adj,get}time in libc?])
2230    ;;
2231 kernel)
2232    AC_DEFINE(NTP_SYSCALLS_STD, 1, [Do we have ntp_{adj,get}time in the kernel?])
2233    ;;
2234 *)
2235    ;;
2236esac
2237
2238AC_CACHE_CHECK(if sys/timex.h has STA_FLL, ac_cv_var_sta_fll,
2239[AC_EGREP_CPP(yes,
2240    [#include <sys/timex.h>
2241#ifdef STA_FLL
2242    yes
2243#endif
2244    ], ac_cv_var_sta_fll=yes, ac_cv_var_sta_fll=no)])
2245
2246AC_CACHE_CHECK(if we have kernel PLL support, ac_cv_var_kernel_pll,
2247[dnl ac_cv_var_ntp_syscalls is {no,libc,kernel}
2248case "$ac_cv_header_sys_timex_h$ac_cv_struct_ntptimeval$ac_cv_var_sta_fll$ac_cv_var_ntp_syscalls" in
2249 *no*)
2250    ac_cv_var_kernel_pll=no
2251    ;;
2252 *) ac_cv_var_kernel_pll=yes
2253    ;;
2254esac])
2255case "$ac_cv_var_kernel_pll" in
2256 yes)
2257    AC_DEFINE(KERNEL_PLL, 1, [Does the kernel support precision time discipline?])
2258    ;;
2259esac
2260
2261AC_CACHE_CHECK(if SIOCGIFCONF returns buffer size in the buffer, ac_cv_var_size_returned_in_buffer,
2262  [ans=no
2263  case "$host" in
2264   *-fujitsu-uxp*)
2265      ans=yes
2266      ;;
2267   *-ncr-sysv4*)
2268      ans=yes
2269      ;;
2270   *-univel-sysv*)
2271      ans=yes
2272      ;;
2273  esac
2274  ac_cv_var_size_returned_in_buffer=$ans])
2275case "$ac_cv_var_size_returned_in_buffer" in
2276 yes) AC_DEFINE(SIZE_RETURNED_IN_BUFFER, 1, [Does SIOCGIFCONF return size in the buffer?]) ;;
2277esac
2278
2279dnl    vvvvv-- this is wrong, if you re-enable the switch do not cache the result
2280dnl AC_CACHE_CHECK(if we want GDT surveying code, ac_cv_var_gdt_surveying,
2281dnl [AC_ARG_ENABLE(gdt-surveying,	[  --enable-gdt-surveying   - include GDT survey code],
2282dnl     [ans=$enableval], [ans=no])
2283dnl ac_cv_var_gdt_surveying=$ans])
2284dnl case "$ac_cv_var_gdt_surveying" in
2285dnl  yes) AC_DEFINE(GDT_SURVEYING, 1, [Include the GDT Surveying code?]) ;;
2286dnl esac
2287
2288# Check for ioctls TIOCGPPSEV
2289AC_MSG_CHECKING(ioctl TIOCGPPSEV)
2290if test "$ac_cv_header_termios_h" = "yes"; then
2291    AC_EGREP_CPP(yes,
2292    [#include <termios.h>
2293#ifdef TIOCGPPSEV
2294         yes
2295#endif
2296	 ], ntp_ok=yes, ntp_ok=no)
2297else
2298ntp_ok=no
2299fi
2300if test "$ntp_ok" = "yes"; then
2301    AC_DEFINE(HAVE_TIOCGPPSEV, 1, [Do we have the TIOCGPPSEV ioctl (Solaris)?])
2302    ac_cv_var_oncore_ok=yes
2303fi
2304AC_MSG_RESULT($ntp_ok)
2305
2306# Check for ioctls TIOCSPPS
2307AC_MSG_CHECKING(ioctl TIOCSPPS)
2308if test "$ac_cv_header_termios_h" = "yes"; then
2309    AC_EGREP_CPP(yes,
2310    [#include <termios.h>
2311#ifdef TIOCSPPS
2312         yes
2313#endif
2314	 ], ntp_ok=yes, ntp_ok=no)
2315else
2316    ntp_ok=no
2317fi
2318
2319if test "$ntp_ok" = "yes"; then
2320    AC_DEFINE(HAVE_TIOCSPPS, 1, [Do we have the TIOCSPPS ioctl (Solaris)?])
2321fi
2322AC_MSG_RESULT($ntp_ok)
2323
2324# Check for ioctls CIOGETEV
2325AC_MSG_CHECKING([ioctl CIOGETEV])
2326if test "$ac_cv_header_sys_ppsclock_h" = "yes"; then
2327    AC_EGREP_CPP(yes,
2328    [#include <sys/ppsclock.h>
2329#ifdef CIOGETEV
2330         yes
2331#endif
2332	 ], ntp_ok=yes, ntp_ok=no)
2333else
2334ntp_ok=no
2335fi
2336if test "$ntp_ok" = "yes"; then
2337    ac_cv_var_oncore_ok=yes
2338    AC_DEFINE(HAVE_CIOGETEV, 1, [Do we have the CIOGETEV ioctl (SunOS, Linux)?])
2339fi
2340AC_MSG_RESULT($ntp_ok)
2341
2342
2343# ATOM/PPSAPI stuff.
2344
2345# ATOM used to require struct timespec, but that's been fixed now.
2346
2347# case "$ac_cv_struct_timespec" in
2348#  'yes')
2349#     ac_cv_var_atom_ok=yes
2350#     ;;
2351# esac
2352ac_cv_var_atom_ok=yes
2353
2354# Check for header timepps.h, if found then we have PPS API (Draft RFC) stuff.
2355
2356# The PPSAPI headers need "inline" ($ac_cv_c_inline='inline')
2357
2358# The PPSAPI needs struct timespec.
2359
2360# The PPSAPI also needs a timepps header.
2361
2362case "$ac_cv_c_inline$ac_cv_struct_timespec" in
2363 inlineyes)
2364    case "$ac_cv_header_timepps_h$ac_cv_header_sys_timepps_h$host_os" in
2365     *yes* | *sunos* | *solaris* | *sco* | *netbsd* )
2366	AC_DEFINE(HAVE_PPSAPI, 1, [Do we have the PPS API per the Draft RFC?])
2367	ac_cv_var_jupiter_ok=yes
2368	ac_cv_var_oncore_ok=yes
2369	ac_cv_var_parse_ok=yes
2370	ac_cv_var_ripe_ncc_ok=yes
2371	;;
2372    esac
2373    ;;
2374esac
2375
2376# Check for ioctls TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG
2377AC_CHECK_HEADER(linux/serial.h)
2378AC_MSG_CHECKING([ioctl TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG])
2379case "$ac_cv_header_sys_ppsclock_h$ac_cv_header_linux_serial_h" in
2380  yesyes)
2381    AC_EGREP_CPP(yes,
2382    [#include <sys/time.h>
2383typedef int u_int;
2384
2385#include <sys/ppsclock.h>
2386#include <linux/serial.h>
2387
2388#ifdef TIOCGSERIAL
2389#ifdef TIOCSSERIAL
2390#ifdef ASYNC_PPS_CD_POS
2391#ifdef ASYNC_PPS_CD_NEG
2392#ifdef CIOGETEV
2393         yes
2394#endif
2395#endif
2396#endif
2397#endif
2398#endif
2399	 ], ntp_ok=yes)
2400	;;
2401  *)
2402	ntp_ok=no
2403	;;
2404esac
2405if test "$ntp_ok" = "yes"; then
2406    AC_DEFINE(HAVE_TIO_SERIAL_STUFF, 1, [Do we have the TIO serial stuff?])
2407fi
2408AC_MSG_RESULT($ntp_ok)
2409
2410# Check for SHMEM_STATUS support
2411AC_MSG_CHECKING([SHMEM_STATUS support])
2412case "$ac_cv_header_sys_mman_h" in
2413 yes) ntp_ok=yes ;;
2414 *)   ntp_ok=no  ;;
2415esac
2416if test "$ntp_ok" = "yes"; then
2417    AC_DEFINE(ONCORE_SHMEM_STATUS, 1, [Do we have support for SHMEM_STATUS?])
2418fi
2419AC_MSG_RESULT($ntp_ok)
2420
2421dnl dnl These are for OPT_PROGRAMS in authstuff/
2422dnl AC_SUBST(AUTHCERT)
2423dnl AC_SUBST(AUTHSPEED)
2424dnl AC_SUBST(MD5DRIVER)
2425dnl AC_SUBST(KEYPARITY)
2426dnl AC_SUBST(MAKEIPFP)
2427dnl AC_SUBST(MAKEPC1)
2428dnl AC_SUBST(MAKEPC2)
2429dnl AC_SUBST(MAKESP)
2430dnl AC_SUBST(MKRANDKEYS)
2431dnl AC_SUBST(OMAKEIPFP)
2432dnl AC_SUBST(UNIXCERT)
2433
2434ntp_refclock=no
2435
2436# HPUX only, and by explicit request
2437AC_MSG_CHECKING([Datum/Bancomm bc635/VME interface])
2438AC_ARG_ENABLE(BANCOMM,
2439    AC_HELP_STRING([--enable-BANCOMM], [- Datum/Bancomm bc635/VME interface]),
2440    [ntp_ok=$enableval], [ntp_ok=no])
2441if test "$ntp_ok" = "yes"; then
2442    ntp_refclock=yes
2443    AC_DEFINE(CLOCK_BANC, 1, [Datum/Bancomm bc635/VME interface?])
2444fi
2445AC_MSG_RESULT($ntp_ok)
2446case "$ntp_ok$host" in
2447 yes*-*-hpux*) ;;
2448 yes*) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
2449esac
2450
2451#HPUX only, and only by explicit request
2452AC_MSG_CHECKING([TrueTime GPS receiver/VME interface])
2453AC_ARG_ENABLE(GPSVME,
2454    AC_HELP_STRING([--enable-GPSVME], [- TrueTime GPS receiver/VME interface]),
2455    [ntp_ok=$enableval], [ntp_ok=no])
2456if test "$ntp_ok" = "yes"; then
2457    ntp_refclock=yes
2458    AC_DEFINE(CLOCK_GPSVME, 1, [TrueTime GPS receiver/VME interface?])
2459fi
2460AC_MSG_RESULT($ntp_ok)
2461case "$ntp_ok$host" in
2462 yes*-*-hpux*) ;;
2463 yes*) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
2464esac
2465
2466AC_MSG_CHECKING([for PCL720 clock support])
2467case "$ac_cv_header_machine_inline_h$ac_cv_header_sys_pcl720_h$ac_cv_header_sys_i8253_h" in
2468 yesyesyes)
2469    AC_DEFINE(CLOCK_PPS720, 1, [PCL 720 clock support])
2470    ans=yes
2471    ;;
2472 *)
2473    ans=no
2474    ;;
2475esac
2476AC_MSG_RESULT([$ans])
2477
2478AC_MSG_CHECKING([for default inclusion of all suitable non-PARSE clocks])
2479AC_ARG_ENABLE(all-clocks,
2480    AC_HELP_STRING([--enable-all-clocks], [+ include all suitable non-PARSE clocks:]),
2481    [ntp_eac=$enableval], [ntp_eac=yes])
2482AC_MSG_RESULT($ntp_eac)
2483
2484# HMS: Should we also require ac_cv_var_parse_ok?
2485AC_MSG_CHECKING([if we have support for PARSE clocks])
2486case "$ac_cv_var_atom_ok$ac_cv_header_termio_h$ac_cv_header_termios_h" in
2487 yes*yes*)
2488    ntp_canparse=yes
2489    ;;
2490 *) ntp_canparse=no
2491    ;;
2492esac
2493AC_MSG_RESULT($ntp_canparse)
2494
2495AC_MSG_CHECKING([if we have support for audio clocks])
2496case "$ac_cv_header_sun_audioio_h$ac_cv_header_sys_audioio_h$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
2497 *yes*)
2498    ntp_canaudio=yes
2499    AC_DEFINE(HAVE_AUDIO, , [Do we have audio support?])
2500    ;;
2501 *) ntp_canaudio=no ;;
2502esac
2503AC_MSG_RESULT($ntp_canaudio)
2504
2505AC_MSG_CHECKING([if we have support for the SHM refclock interface])
2506case "$ac_cv_header_sys_ipc_h$ac_cv_header_sys_shm_h" in
2507 yesyes)
2508    ntp_canshm=yes
2509    ;;
2510 *) ntp_canshm=no ;;
2511esac
2512AC_MSG_RESULT($ntp_canshm)
2513
2514# Requires modem control
2515AC_MSG_CHECKING([ACTS modem service])
2516AC_ARG_ENABLE(ACTS,
2517    AC_HELP_STRING([--enable-ACTS], [s ACTS modem service]),
2518    [ntp_ok=$enableval],
2519    [AC_EGREP_CPP(yes,
2520        [#include <termios.h>
2521#ifdef HAVE_SYS_IOCTL_H
2522#include <sys/ioctl.h>
2523#endif
2524#ifdef TIOCMBIS
2525         yes
2526#endif
2527         ], ntp_ok=$ntp_eac, ntp_ok=no)])
2528if test "$ntp_ok" = "yes"; then
2529    ntp_refclock=yes
2530    AC_DEFINE(CLOCK_ACTS, 1, [ACTS modem service])
2531fi
2532AC_MSG_RESULT($ntp_ok)
2533
2534AC_MSG_CHECKING([Arbiter 1088A/B GPS receiver])
2535AC_ARG_ENABLE(ARBITER,
2536    AC_HELP_STRING([--enable-ARBITER], [+ Arbiter 1088A/B GPS receiver]),
2537    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2538if test "$ntp_ok" = "yes"; then
2539    ntp_refclock=yes
2540    AC_DEFINE(CLOCK_ARBITER, 1, [Arbiter 1088A/B GPS receiver])
2541fi
2542AC_MSG_RESULT($ntp_ok)
2543
2544AC_MSG_CHECKING([Arcron MSF receiver])
2545AC_ARG_ENABLE(ARCRON_MSF,
2546    AC_HELP_STRING([--enable-ARCRON-MSF], [+ Arcron MSF receiver]),
2547    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2548if test "$ntp_ok" = "yes"; then
2549    ntp_refclock=yes
2550    AC_DEFINE(CLOCK_ARCRON_MSF, 1, [ARCRON support?])
2551fi
2552AC_MSG_RESULT($ntp_ok)
2553
2554AC_MSG_CHECKING([Austron 2200A/2201A GPS receiver])
2555AC_ARG_ENABLE(AS2201,
2556    AC_HELP_STRING([--enable-AS2201], [+ Austron 2200A/2201A GPS receiver]),
2557    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2558if test "$ntp_ok" = "yes"; then
2559    ntp_refclock=yes
2560    AC_DEFINE(CLOCK_AS2201, 1, [Austron 2200A/2201A GPS receiver?])
2561fi
2562AC_MSG_RESULT($ntp_ok)
2563
2564AC_MSG_CHECKING([ATOM PPS interface])
2565AC_ARG_ENABLE(ATOM,
2566    AC_HELP_STRING([--enable-ATOM], [s ATOM PPS interface]),
2567    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2568case "$ac_cv_var_atom_ok" in
2569 no) ntp_ok=no ;;
2570esac
2571if test "$ntp_ok" = "yes"; then
2572    ntp_refclock=yes
2573    AC_DEFINE(CLOCK_ATOM, 1, [PPS interface?])
2574fi
2575AC_MSG_RESULT($ntp_ok)
2576
2577AC_MSG_CHECKING([Chrono-log K-series WWVB receiver])
2578AC_ARG_ENABLE(CHRONOLOG,
2579    AC_HELP_STRING([--enable-CHRONOLOG], [+ Chrono-log K-series WWVB receiver]),
2580    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2581if test "$ntp_ok" = "yes"; then
2582    ntp_refclock=yes
2583    AC_DEFINE(CLOCK_CHRONOLOG, 1, [Chronolog K-series WWVB receiver?])
2584fi
2585AC_MSG_RESULT($ntp_ok)
2586
2587AC_MSG_CHECKING([CHU modem/decoder])
2588AC_ARG_ENABLE(CHU,
2589    AC_HELP_STRING([--enable-CHU], [+ CHU modem/decoder]),
2590    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2591if test "$ntp_ok" = "yes"; then
2592    ntp_refclock=yes
2593    AC_DEFINE(CLOCK_CHU, 1, [CHU modem/decoder])
2594fi
2595AC_MSG_RESULT($ntp_ok)
2596ac_refclock_chu=$ntp_ok
2597
2598AC_MSG_CHECKING([CHU audio/decoder])
2599AC_ARG_ENABLE(AUDIO-CHU,
2600    AC_HELP_STRING([--enable-AUDIO-CHU], [s CHU audio/decoder]),
2601    [ntp_ok=$enableval],
2602    [case "$ntp_eac$ac_refclock_chu$ntp_canaudio" in
2603 *no*)	ntp_ok=no  ;;
2604 *)	ntp_ok=yes ;;
2605esac])
2606if test "$ntp_ok" = "yes"; then
2607    AC_DEFINE(AUDIO_CHU, 1, [CHU audio/decoder?])
2608fi
2609AC_MSG_RESULT($ntp_ok)
2610# We used to check for sunos/solaris target...
2611case "$ntp_ok$ac_refclock_chu$ntp_canaudio" in
2612 yes*no*) AC_MSG_WARN([*** But the expected answer is...no ***]) ;;
2613esac
2614
2615# Not under HP-UX
2616AC_MSG_CHECKING([Datum Programmable Time System])
2617AC_ARG_ENABLE(DATUM,
2618    AC_HELP_STRING([--enable-DATUM], [s Datum Programmable Time System]),
2619    [ntp_ok=$enableval],
2620    [case "$ac_cv_header_termios_h" in
2621    yes)
2622        ntp_ok=$ntp_eac
2623        ;;
2624    *) ntp_ok=no
2625        ;;
2626    esac])
2627if test "$ntp_ok" = "yes"; then
2628    ntp_refclock=yes
2629    AC_DEFINE(CLOCK_DATUM, 1, [Datum Programmable Time System?])
2630fi
2631AC_MSG_RESULT($ntp_ok)
2632
2633AC_MSG_CHECKING([Dumb generic hh:mm:ss local clock])
2634AC_ARG_ENABLE(DUMBCLOCK,
2635    AC_HELP_STRING([--enable-DUMBCLOCK], [+ Dumb generic hh:mm:ss local clock]),
2636    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2637if test "$ntp_ok" = "yes"; then
2638    ntp_refclock=yes
2639    AC_DEFINE(CLOCK_DUMBCLOCK, 1, [Dumb generic hh:mm:ss local clock?])
2640fi
2641AC_MSG_RESULT($ntp_ok)
2642
2643AC_MSG_CHECKING([Forum Graphic GPS])
2644AC_ARG_ENABLE(FG,
2645    AC_HELP_STRING([--enable-FG], [+ Forum Graphic GPS]),
2646    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2647if test "$ntp_ok" = "yes"; then
2648    ntp_refclock=yes
2649    AC_DEFINE(CLOCK_FG, 1, [Forum Graphic GPS datating station driver?])
2650fi
2651AC_MSG_RESULT($ntp_ok)
2652
2653# Requires modem control
2654AC_MSG_CHECKING([Heath GC-1000 WWV/WWVH receiver])
2655AC_ARG_ENABLE(HEATH,
2656    AC_HELP_STRING([--enable-HEATH], [s Heath GC-1000 WWV/WWVH receiver]),
2657    [ntp_ok=$enableval],
2658    [AC_EGREP_CPP(yes,
2659        [#include <termios.h>
2660#ifdef HAVE_SYS_IOCTL_H
2661#include <sys/ioctl.h>
2662#endif
2663#ifdef TIOCMBIS
2664         yes
2665#endif
2666         ], ntp_ok=$ntp_eac, ntp_ok=no)])
2667if test "$ntp_ok" = "yes"; then
2668    ntp_refclock=yes
2669    AC_DEFINE(CLOCK_HEATH, 1, [Heath GC-1000 WWV/WWVH receiver?])
2670fi
2671AC_MSG_RESULT($ntp_ok)
2672
2673AC_MSG_CHECKING([for hopf serial clock device])
2674AC_ARG_ENABLE(HOPFSERIAL,
2675    AC_HELP_STRING([--enable-HOPFSERIAL], [+ hopf serial clock device]),
2676    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2677if test "$ntp_ok" = "yes"; then
2678    ntp_refclock=yes
2679    AC_DEFINE(CLOCK_HOPF_SERIAL, 1, [HOPF serial clock device?])
2680fi
2681AC_MSG_RESULT($ntp_ok)
2682
2683AC_MSG_CHECKING([for hopf PCI clock 6039])
2684AC_ARG_ENABLE(HOPFPCI,
2685    AC_HELP_STRING([--enable-HOPFPCI], [+ hopf 6039 PCI board]),
2686    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2687if test "$ntp_ok" = "yes"; then
2688    ntp_refclock=yes
2689    AC_DEFINE(CLOCK_HOPF_PCI, 1, [HOPF PCI clock device?])
2690fi
2691AC_MSG_RESULT($ntp_ok)
2692
2693AC_MSG_CHECKING([HP 58503A GPS receiver])
2694AC_ARG_ENABLE(HPGPS,
2695    AC_HELP_STRING([--enable-HPGPS], [+ HP 58503A GPS receiver]),
2696    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2697if test "$ntp_ok" = "yes"; then
2698    ntp_refclock=yes
2699    AC_DEFINE(CLOCK_HPGPS, 1, [HP 58503A GPS receiver?])
2700fi
2701AC_MSG_RESULT($ntp_ok)
2702
2703AC_MSG_CHECKING([IRIG audio decoder])
2704AC_ARG_ENABLE(IRIG,
2705    AC_HELP_STRING([--enable-IRIG], [s IRIG audio decoder]),
2706    [ntp_ok=$enableval],
2707    [case "$ntp_eac$ntp_canaudio" in
2708     *no*)	ntp_ok=no  ;;
2709     *)		ntp_ok=yes ;;
2710    esac])
2711if test "$ntp_ok" = "yes"; then
2712    ntp_refclock=yes
2713    AC_DEFINE(CLOCK_IRIG, 1, [IRIG audio decoder?])
2714fi
2715AC_MSG_RESULT($ntp_ok)
2716case "$ntp_ok$ntp_canaudio" in
2717 yesno) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
2718esac
2719
2720AC_MSG_CHECKING([for JJY receiver])
2721AC_ARG_ENABLE(JJY,
2722    AC_HELP_STRING([--enable-JJY], [+ JJY receiver]),
2723    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2724if test "$ntp_ok" = "yes"; then
2725    ntp_refclock=yes
2726    AC_DEFINE(CLOCK_JJY, 1, [JJY receiver?])
2727fi
2728AC_MSG_RESULT($ntp_ok)
2729
2730AC_MSG_CHECKING([Rockwell Jupiter GPS receiver])
2731AC_ARG_ENABLE(JUPITER,
2732    AC_HELP_STRING([--enable-JUPITER], [s Rockwell Jupiter GPS receiver]),
2733    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2734case "$ac_cv_var_jupiter_ok" in
2735 no) ntp_ok=no ;;
2736esac
2737if test "$ntp_ok" = "yes"; then
2738    ntp_refclock=yes
2739    AC_DEFINE(CLOCK_JUPITER, 1, [Rockwell Jupiter GPS clock?])
2740fi
2741AC_MSG_RESULT($ntp_ok)
2742
2743AC_MSG_CHECKING([Leitch CSD 5300 Master Clock System Driver])
2744AC_ARG_ENABLE(LEITCH,
2745    AC_HELP_STRING([--enable-LEITCH], [+ Leitch CSD 5300 Master Clock System Driver]),
2746    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2747if test "$ntp_ok" = "yes"; then
2748    ntp_refclock=yes
2749    AC_DEFINE(CLOCK_LEITCH, 1, [Leitch CSD 5300 Master Clock System Driver?])
2750fi
2751AC_MSG_RESULT($ntp_ok)
2752
2753AC_MSG_CHECKING([local clock reference])
2754AC_ARG_ENABLE(LOCAL-CLOCK,
2755    AC_HELP_STRING([--enable-LOCAL-CLOCK], [+ local clock reference]),
2756    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2757if test "$ntp_ok" = "yes"; then
2758    ntp_refclock=yes
2759    AC_DEFINE(CLOCK_LOCAL, 1, [local clock reference?])
2760fi
2761AC_MSG_RESULT($ntp_ok)
2762
2763dnl Bug 340: longstanding unfixed bugs
2764dnl AC_MSG_CHECKING(EES M201 MSF receiver)
2765dnl AC_ARG_ENABLE(MSFEES,
2766dnl     AC_HELP_STRING([--enable-MSFEES], [+ EES M201 MSF receiver]),
2767dnl     [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2768dnl if test "$ntp_ok" = "yes"; then
2769dnl     ntp_refclock=yes
2770dnl     AC_DEFINE(CLOCK_MSFEES, 1, [EES M201 MSF receiver])
2771dnl fi
2772dnl AC_MSG_RESULT($ntp_ok)
2773
2774# Not Ultrix
2775AC_MSG_CHECKING([Magnavox MX4200 GPS receiver])
2776AC_ARG_ENABLE(MX4200,
2777    AC_HELP_STRING([--enable-MX4200 ], [s Magnavox MX4200 GPS receiver]),
2778    [ntp_ok=$enableval],
2779    [case "$ac_cv_var_ppsclock" in
2780     yes) ntp_ok=$ntp_eac
2781        ;;
2782     *) ntp_ok=no
2783        ;;
2784    esac])
2785if test "$ntp_ok" = "yes"; then
2786    ntp_refclock=yes
2787    AC_DEFINE(CLOCK_MX4200, 1, [Magnavox MX4200 GPS receiver])
2788fi
2789AC_MSG_RESULT($ntp_ok)
2790case "$ntp_ok$host" in
2791 yes*-*-ultrix*) AC_MSG_WARN(*** But the expected answer is... no ***) ;;
2792esac
2793
2794AC_MSG_CHECKING([for NeoClock4X receiver])
2795AC_ARG_ENABLE(NEOCLOCK4X,
2796    AC_HELP_STRING([--enable-NEOCLOCK4X], [+ NeoClock4X DCF77 / TDF receiver]),
2797    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2798if test "$ntp_ok" = "yes"; then
2799    ntp_refclock=yes
2800    AC_DEFINE(CLOCK_NEOCLOCK4X, 1, [NeoClock4X])
2801fi
2802AC_MSG_RESULT($ntp_ok)
2803
2804AC_MSG_CHECKING([NMEA GPS receiver])
2805AC_ARG_ENABLE(NMEA,
2806    AC_HELP_STRING([--enable-NMEA], [+ NMEA GPS receiver]),
2807    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2808if test "$ntp_ok" = "yes"; then
2809    ntp_refclock=yes
2810    AC_DEFINE(CLOCK_NMEA, 1, [NMEA GPS receiver])
2811fi
2812AC_MSG_RESULT($ntp_ok)
2813
2814AC_MSG_CHECKING([for ONCORE Motorola VP/UT Oncore GPS])
2815AC_ARG_ENABLE(ONCORE,
2816    AC_HELP_STRING([--enable-ONCORE], [s Motorola VP/UT Oncore GPS receiver]),
2817    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2818case "$ac_cv_var_oncore_ok" in
2819 no) ntp_ok=no ;;
2820esac
2821if test "$ntp_ok" = "yes"; then
2822    ntp_refclock=yes
2823    AC_DEFINE(CLOCK_ONCORE, 1, [Motorola UT Oncore GPS])
2824fi
2825AC_MSG_RESULT($ntp_ok)
2826
2827AC_MSG_CHECKING([for Palisade clock])
2828AC_ARG_ENABLE(PALISADE,
2829    AC_HELP_STRING([--enable-PALISADE], [s Palisade clock]),
2830    [ntp_ok=$enableval],
2831    [case "$ac_cv_header_termios_h" in
2832    yes)
2833        ntp_ok=$ntp_eac
2834        ;;
2835    *) ntp_ok=no
2836        ;;
2837    esac])
2838
2839if test "$ntp_ok" = "yes"; then
2840    ntp_refclock=yes
2841    AC_DEFINE(CLOCK_PALISADE, 1, [Palisade clock])
2842fi
2843AC_MSG_RESULT($ntp_ok)
2844
2845AC_MSG_CHECKING([Conrad parallel port radio clock])
2846AC_ARG_ENABLE(PCF,
2847    AC_HELP_STRING([--enable-PCF ], [+ Conrad parallel port radio clock]),
2848    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2849if test "$ntp_ok" = "yes"; then
2850    ntp_refclock=yes
2851    AC_DEFINE(CLOCK_PCF, 1, [Conrad parallel port radio clock])
2852fi
2853AC_MSG_RESULT($ntp_ok)
2854
2855AC_MSG_CHECKING([PST/Traconex 1020 WWV/WWVH receiver])
2856AC_ARG_ENABLE(PST,
2857    AC_HELP_STRING([--enable-PST], [+ PST/Traconex 1020 WWV/WWVH receiver]),
2858    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2859if test "$ntp_ok" = "yes"; then
2860    ntp_refclock=yes
2861    AC_DEFINE(CLOCK_PST, 1, [PST/Traconex 1020 WWV/WWVH receiver])
2862fi
2863AC_MSG_RESULT($ntp_ok)
2864
2865AC_MSG_CHECKING([RIPENCC specific Trimble driver])
2866AC_ARG_ENABLE(RIPENCC,
2867    AC_HELP_STRING([--enable-RIPENCC], [- RIPENCC specific Trimble driver]),
2868    [ntp_ok=$enableval], [ntp_ok=no])
2869# 020629: HMS: s/$ntp_eac -> -/no because of ptr += sprintf(ptr, ...) usage
2870case "$ac_cv_var_ripe_ncc_ok" in
2871 no) ntp_ok=no ;;
2872esac
2873if test "$ntp_ok" = "yes"; then
2874    ntp_refclock=yes
2875    AC_DEFINE(CLOCK_RIPENCC, ,[RIPE NCC Trimble clock])
2876fi
2877AC_MSG_RESULT($ntp_ok)
2878
2879# Danny Meyer says SHM compiles (with a few warnings) under Win32.
2880# For *IX, we need sys/ipc.h and sys/shm.h.
2881AC_MSG_CHECKING([for SHM clock attached thru shared memory])
2882AC_ARG_ENABLE(SHM,
2883    AC_HELP_STRING([--enable-SHM], [s SHM clock attached thru shared memory]),
2884    [ntp_ok=$enableval],
2885    [case "$ntp_eac$ntp_canshm" in
2886 *no*)	ntp_ok=no  ;;
2887 *)	ntp_ok=yes ;;
2888esac])
2889if test "$ntp_ok" = "yes"; then
2890    ntp_refclock=yes
2891    AC_DEFINE(CLOCK_SHM, 1, [clock thru shared memory])
2892fi
2893AC_MSG_RESULT($ntp_ok)
2894
2895AC_MSG_CHECKING([Spectracom 8170/Netclock/2 WWVB receiver])
2896AC_ARG_ENABLE(SPECTRACOM,
2897    AC_HELP_STRING([--enable-SPECTRACOM], [+ Spectracom 8170/Netclock/2 WWVB receiver]),
2898    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2899if test "$ntp_ok" = "yes"; then
2900    ntp_refclock=yes
2901    AC_DEFINE(CLOCK_SPECTRACOM, 1, [Spectracom 8170/Netclock/2 WWVB receiver])
2902fi
2903AC_MSG_RESULT($ntp_ok)
2904
2905AC_MSG_CHECKING([KSI/Odetics TPRO/S GPS receiver/IRIG interface])
2906AC_ARG_ENABLE(TPRO,
2907    AC_HELP_STRING([--enable-TPRO], [s KSI/Odetics TPRO/S GPS receiver/IRIG interface]),
2908    [ntp_ok=$enableval],
2909    [case "$ac_cv_header_sys_tpro_h" in
2910     yes)
2911	ntp_ok=$ntp_eac
2912	;;
2913     *)	ntp_ok=no
2914	;;
2915    esac])
2916if test "$ntp_ok" = "yes"; then
2917    ntp_refclock=yes
2918    AC_DEFINE(CLOCK_TPRO, 1, [KSI/Odetics TPRO/S GPS receiver/IRIG interface])
2919fi
2920AC_MSG_RESULT($ntp_ok)
2921case "$ntp_ok$ac_cv_header_sys_tpro" in
2922 yesno) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
2923esac
2924
2925dnl Bug 342: longstanding unfixed bugs
2926dnl AC_MSG_CHECKING(TRAK 8810 GPS receiver)
2927dnl AC_ARG_ENABLE(TRAK,
2928dnl     AC_HELP_STRING([--enable-TRAK], [+ TRAK 8810 GPS receiver]),
2929dnl     [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2930dnl if test "$ntp_ok" = "yes"; then
2931dnl     ntp_refclock=yes
2932dnl     AC_DEFINE(CLOCK_TRAK, 1, [TRAK 8810 GPS receiver])
2933dnl fi
2934dnl AC_MSG_RESULT($ntp_ok)
2935
2936# Not on a vax-dec-bsd
2937AC_MSG_CHECKING([Kinemetrics/TrueTime receivers])
2938AC_ARG_ENABLE(TRUETIME,
2939    AC_HELP_STRING([--enable-TRUETIME], [s Kinemetrics/TrueTime receivers]),
2940    [ntp_ok=$enableval],
2941    [case "$host" in
2942     vax-dec-bsd)
2943	ntp_ok=no
2944	;;
2945     *)
2946	ntp_ok=$ntp_eac
2947	;;
2948    esac])
2949
2950if test "$ntp_ok" = "yes"; then
2951    ntp_refclock=yes
2952    AC_DEFINE(CLOCK_TRUETIME, 1, [Kinemetrics/TrueTime receivers])
2953fi
2954AC_MSG_RESULT($ntp_ok)
2955case "$ntp_ok$host" in
2956 yesvax-dec-bsd) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
2957esac
2958
2959AC_MSG_CHECKING([TrueTime 560 IRIG-B decoder])
2960AC_ARG_ENABLE(TT560,
2961    AC_HELP_STRING([--enable-TT560], [- TrueTime 560 IRIG-B decoder]),
2962    [ntp_ok=$enableval], [ntp_ok=no])
2963if test "$ntp_ok" = "yes"; then
2964    ntp_refclock=yes
2965    AC_DEFINE(CLOCK_TT560, , [TrueTime 560 IRIG-B decoder?])
2966fi
2967AC_MSG_RESULT($ntp_ok)
2968
2969AC_MSG_CHECKING([Ultralink M320 WWVB receiver])
2970AC_ARG_ENABLE(ULINK,
2971    AC_HELP_STRING([--enable-ULINK], [+ Ultralink WWVB receiver]),
2972    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
2973if test "$ntp_ok" = "yes"; then
2974    ntp_refclock=yes
2975    AC_DEFINE(CLOCK_ULINK, 1, [Ultralink M320 WWVB receiver?])
2976fi
2977AC_MSG_RESULT($ntp_ok)
2978
2979AC_MSG_CHECKING([WWV receiver])
2980AC_ARG_ENABLE(WWV,
2981    AC_HELP_STRING([--enable-WWV], [s WWV Audio receiver]),
2982    [ntp_ok=$enableval],
2983    [case "$ntp_eac$ntp_canaudio" in
2984     *no*)	ntp_ok=no  ;;
2985     *)		ntp_ok=yes ;;
2986    esac])
2987if test "$ntp_ok" = "yes"; then
2988    ntp_refclock=yes
2989    AC_DEFINE(CLOCK_WWV, 1, [WWV audio driver])
2990fi
2991AC_MSG_RESULT($ntp_ok)
2992case "$ntp_ok$ntp_canaudio" in
2993 yesno) AC_MSG_WARN(*** But the expected answer is... no ***) ;;
2994esac
2995
2996AC_MSG_CHECKING([for Zyfer receiver])
2997AC_ARG_ENABLE(ZYFER,
2998    AC_HELP_STRING([--enable-ZYFER], [+ Zyfer GPStarplus receiver]),
2999    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
3000if test "$ntp_ok" = "yes"; then
3001    ntp_refclock=yes
3002    AC_DEFINE(CLOCK_ZYFER, 1, [Zyfer GPStarplus])
3003fi
3004AC_MSG_RESULT($ntp_ok)
3005
3006AC_MSG_CHECKING([for default inclusion of all suitable PARSE clocks])
3007AC_ARG_ENABLE(parse-clocks,
3008   AC_HELP_STRING([--enable-parse-clocks], [- include all suitable PARSE clocks:]),
3009    [ntp_eapc=$enableval],
3010    [case "$ntp_eac" in
3011     yes) ntp_eapc=$ntp_canparse ;;
3012     *) ntp_eapc=no ;;
3013    esac
3014    # Delete the next line one of these days
3015    ntp_eapc=no])
3016AC_MSG_RESULT($ntp_eapc)
3017
3018case "$ntp_eac$ntp_eapc$ntp_canparse" in
3019 noyes*)
3020    AC_MSG_ERROR(["--enable-parse-clocks" requires "--enable-all-clocks".])
3021    ;;
3022 yesyesno)
3023    AC_MSG_ERROR([You said "--enable-parse-clocks" but PARSE isn't supported on this platform!])
3024    ;;
3025 *) ;;
3026esac
3027
3028ntp_libparse=no
3029ntp_parseutil=no
3030ntp_rawdcf=no
3031
3032AC_MSG_CHECKING([Diem Computime Radio Clock])
3033AC_ARG_ENABLE(COMPUTIME,
3034    AC_HELP_STRING([--enable-COMPUTIME], [s Diem Computime Radio Clock]),
3035    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3036if test "$ntp_ok" = "yes"; then
3037    ntp_libparse=yes
3038    ntp_refclock=yes
3039    AC_DEFINE(CLOCK_COMPUTIME, 1, [Diems Computime Radio Clock?])
3040fi
3041AC_MSG_RESULT($ntp_ok)
3042case "$ntp_ok$ntp_canparse" in
3043 yesno)
3044    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
3045    ;;
3046esac
3047
3048AC_MSG_CHECKING([ELV/DCF7000 clock])
3049AC_ARG_ENABLE(DCF7000,
3050    AC_HELP_STRING([--enable-DCF7000], [s ELV/DCF7000 clock]),
3051    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3052if test "$ntp_ok" = "yes"; then
3053    ntp_libparse=yes
3054    ntp_refclock=yes
3055    AC_DEFINE(CLOCK_DCF7000, 1, [ELV/DCF7000 clock?])
3056fi
3057AC_MSG_RESULT($ntp_ok)
3058case "$ntp_ok$ntp_canparse" in
3059 yesno)
3060    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
3061    ;;
3062esac
3063
3064AC_MSG_CHECKING([HOPF 6021 clock])
3065AC_ARG_ENABLE(HOPF6021,
3066    AC_HELP_STRING([--enable-HOPF6021 ], [s HOPF 6021 clock]),
3067    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3068if test "$ntp_ok" = "yes"; then
3069    ntp_libparse=yes
3070    ntp_refclock=yes
3071    AC_DEFINE(CLOCK_HOPF6021, 1, [HOPF 6021 clock?])
3072fi
3073AC_MSG_RESULT($ntp_ok)
3074case "$ntp_ok$ntp_canparse" in
3075 yesno)
3076    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
3077    ;;
3078esac
3079
3080AC_MSG_CHECKING([Meinberg clocks])
3081AC_ARG_ENABLE(MEINBERG,
3082    AC_HELP_STRING([--enable-MEINBERG], [s Meinberg clocks]),
3083    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3084if test "$ntp_ok" = "yes"; then
3085    ntp_libparse=yes
3086    ntp_refclock=yes
3087    AC_DEFINE(CLOCK_MEINBERG, 1, [Meinberg clocks])
3088fi
3089AC_MSG_RESULT($ntp_ok)
3090case "$ntp_ok$ntp_canparse" in
3091 yesno)
3092    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
3093    ;;
3094esac
3095
3096AC_MSG_CHECKING([DCF77 raw time code])
3097AC_ARG_ENABLE(RAWDCF,
3098    AC_HELP_STRING([--enable-RAWDCF], [s DCF77 raw time code]),
3099    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3100if test "$ntp_ok" = "yes"; then
3101    ntp_libparse=yes
3102    ntp_parseutil=yes
3103    ntp_refclock=yes
3104    ntp_rawdcf=yes
3105    AC_DEFINE(CLOCK_RAWDCF, 1, [DCF77 raw time code])
3106fi
3107AC_MSG_RESULT($ntp_ok)
3108case "$ntp_ok$ntp_canparse" in
3109 yesno)
3110    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
3111    ;;
3112esac
3113
3114case "$ntp_rawdcf" in
3115 yes)
3116    AC_CACHE_CHECK([if we must enable parity for RAWDCF],
3117    ac_cv_var_rawdcf_parity,
3118    [ans=no
3119    case "$host" in
3120     *-*-*linux*)
3121        ans=yes
3122        ;;
3123    esac
3124    ac_cv_var_rawdcf_parity=$ans])
3125    case "$ac_cv_var_rawdcf_parity" in
3126     yes) AC_DEFINE(RAWDCF_NO_IGNPAR, 1, [Should we not IGNPAR (Linux)?]) ;;
3127    esac
3128    ;;
3129
3130 *) # HMS: Is this a good idea?
3131    ac_cv_var_rawdcf_parity=no
3132    ;;
3133esac
3134
3135AC_MSG_CHECKING([RCC 8000 clock])
3136AC_ARG_ENABLE(RCC8000,
3137    AC_HELP_STRING([--enable-RCC8000], [s RCC 8000 clock]),
3138    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3139if test "$ntp_ok" = "yes"; then
3140    ntp_libparse=yes
3141    ntp_refclock=yes
3142    AC_DEFINE(CLOCK_RCC8000, 1, [RCC 8000 clock])
3143fi
3144AC_MSG_RESULT($ntp_ok)
3145case "$ntp_ok$ntp_canparse" in
3146 yesno)
3147    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
3148    ;;
3149esac
3150
3151AC_MSG_CHECKING([Schmid DCF77 clock])
3152AC_ARG_ENABLE(SCHMID,
3153    AC_HELP_STRING([--enable-SCHMID ], [s Schmid DCF77 clock]),
3154    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3155if test "$ntp_ok" = "yes"; then
3156    ntp_libparse=yes
3157    ntp_refclock=yes
3158    AC_DEFINE(CLOCK_SCHMID, 1, [Schmid DCF77 clock])
3159fi
3160AC_MSG_RESULT($ntp_ok)
3161case "$ntp_ok$ntp_canparse" in
3162 yesno)
3163    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
3164    ;;
3165esac
3166
3167AC_MSG_CHECKING([Trimble GPS receiver/TAIP protocol])
3168AC_ARG_ENABLE(TRIMTAIP,
3169    AC_HELP_STRING([--enable-TRIMTAIP], [s Trimble GPS receiver/TAIP protocol]),
3170    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3171if test "$ntp_ok" = "yes"; then
3172    ntp_libparse=yes
3173    ntp_refclock=yes
3174    AC_DEFINE(CLOCK_TRIMTAIP, 1, [Trimble GPS receiver/TAIP protocol])
3175fi
3176AC_MSG_RESULT($ntp_ok)
3177case "$ntp_ok$ntp_canparse" in
3178 yesno)
3179    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
3180    ;;
3181esac
3182
3183AC_MSG_CHECKING([Trimble GPS receiver/TSIP protocol])
3184AC_ARG_ENABLE(TRIMTSIP,
3185    AC_HELP_STRING([--enable-TRIMTSIP], [s Trimble GPS receiver/TSIP protocol]),
3186    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3187if test "$ntp_ok" = "yes"; then
3188    ntp_libparse=yes
3189    ntp_refclock=yes
3190    AC_DEFINE(CLOCK_TRIMTSIP, 1, [Trimble GPS receiver/TSIP protocol])
3191fi
3192AC_MSG_RESULT($ntp_ok)
3193case "$ntp_ok$ntp_canparse" in
3194 yesno)
3195    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
3196    ;;
3197esac
3198
3199AC_MSG_CHECKING([WHARTON 400A Series clock])
3200AC_ARG_ENABLE(WHARTON,
3201    AC_HELP_STRING([--enable-WHARTON], [s WHARTON 400A Series clock]),
3202    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3203if test "$ntp_ok" = "yes"; then
3204    ntp_libparse=yes
3205    ntp_refclock=yes
3206    AC_DEFINE(CLOCK_WHARTON_400A, 1, [WHARTON 400A Series protocol])
3207fi
3208AC_MSG_RESULT($ntp_ok)
3209case "$ntp_ok$ntp_canparse" in
3210 yesno)
3211    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
3212    ;;
3213esac
3214
3215AC_MSG_CHECKING([VARITEXT clock])
3216AC_ARG_ENABLE(VARITEXT,
3217    AC_HELP_STRING([--enable-VARITEXT], [s VARITEXT clock]),
3218    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
3219if test "$ntp_ok" = "yes"; then
3220    ntp_libparse=yes
3221    ntp_refclock=yes
3222    AC_DEFINE(CLOCK_VARITEXT, 1, [VARITEXT protocol])
3223fi
3224AC_MSG_RESULT($ntp_ok)
3225case "$ntp_ok$ntp_canparse" in
3226 yesno)
3227    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
3228    ;;
3229esac
3230AC_SUBST(LIBPARSE)
3231AC_SUBST(MAKE_LIBPARSE)
3232AC_SUBST(MAKE_LIBPARSE_KERNEL)
3233AC_SUBST(MAKE_CHECK_Y2K)
3234AC_MSG_CHECKING([if we need to make and use the parse libraries])
3235ans=no
3236case "$ntp_libparse" in
3237 yes)
3238    ans=yes
3239    AC_DEFINE(CLOCK_PARSE, 1, [PARSE driver interface])
3240    LIBPARSE=../libparse/libparse.a
3241    MAKE_LIBPARSE=libparse.a
3242    # HMS: check_y2k trips the 34 year problem now...
3243    false && MAKE_CHECK_Y2K=check_y2k
3244    ;;
3245esac
3246AC_MSG_RESULT([$ans])
3247
3248
3249# AC_SUBST(RSAOBJS)
3250# AC_SUBST(RSASRCS)
3251# AC_SUBST(RSADIR)
3252# AC_SUBST(RSAREF)
3253# AC_SUBST(LIBRSAREF)
3254# AC_SUBST(MAKE_LIBRSAREF)
3255
3256AC_SUBST(OPENSSL)
3257AC_SUBST(OPENSSL_INC)
3258AC_SUBST(OPENSSL_LIB)
3259
3260AC_MSG_CHECKING([for openssl library directory])
3261AC_ARG_WITH(openssl-libdir,
3262	AC_HELP_STRING([--with-openssl-libdir], [+ =/something/reasonable]),
3263[ans=$withval],
3264[case "$build" in
3265 $host) ans=yes ;;
3266 *)     ans=no ;;
3267esac])
3268case "$ans" in
3269 no) ;;
3270 yes) # Look in:
3271    ans="/usr/lib /usr/lib/openssl /usr/sfw/lib /usr/local/lib /usr/local/ssl/lib /lib"
3272    ;;
3273 *) # Look where they said
3274    ;;
3275esac
3276case "$ans" in
3277 no) ;;
3278 *) # Look for libcrypto.a and libssl.a:
3279    for i in $ans no
3280    do
3281	case "$host" in
3282	 *-*-darwin*)
3283	    test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
3284	    ;;
3285	 *)
3286	    test -f $i/libcrypto.so -a -f $i/libssl.so && break
3287	    test -f $i/libcrypto.a -a -f $i/libssl.a && break
3288	    ;;
3289	esac
3290    done
3291    case "$i" in
3292     no)
3293	ans=no
3294	OPENSSL_LIB=
3295	;;
3296     *) ans=$i
3297	OPENSSL_LIB=$ans
3298	;;
3299    esac
3300    ;;
3301esac
3302AC_MSG_RESULT([$ans])
3303
3304AC_MSG_CHECKING([for openssl include directory])
3305AC_ARG_WITH(openssl-incdir,
3306	AC_HELP_STRING([--with-openssl-incdir], [+ =/something/reasonable]),
3307[ans=$withval],
3308[case "$build" in
3309 $host) ans=yes ;;
3310 *)     ans=no ;;
3311esac])
3312case "$ans" in
3313 no) ;;
3314 yes) # look in:
3315    ans="/usr/include /usr/sfw/include /usr/local/include /usr/local/ssl/include"
3316    ;;
3317 *) # Look where they said
3318    ;;
3319esac
3320case "$ans" in
3321 no) ;;
3322 *) # look for openssl/opensslconf.h:
3323    for i in $ans no
3324    do
3325	test -f $i/openssl/opensslconf.h && break
3326    done
3327    case "$i" in
3328     no)
3329	ans=no
3330	OPENSSL_INC=
3331	;;
3332     *) ans=$i
3333	OPENSSL_INC=$ans
3334	;;
3335    esac
3336    ;;
3337esac
3338AC_MSG_RESULT([$ans])
3339
3340AC_MSG_CHECKING([if we will use crypto])
3341AC_ARG_WITH(crypto,
3342	AC_HELP_STRING([--with-crypto], [+ =openssl]),
3343[ans=$withval], [ans=yes])
3344case "$ans" in
3345 no)
3346    ;;
3347 yes|openssl)
3348    if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INC"
3349    then
3350	ans=no
3351    else
3352	ans=yes
3353    fi
3354esac
3355ntp_openssl=$ans
3356AC_MSG_RESULT([$ans])
3357
3358case "$ntp_openssl" in
3359 yes)
3360    # We have OpenSSL inc/lib - use them.
3361    CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC"
3362    LDFLAGS="$LDFLAGS -L$OPENSSL_LIB"
3363    case "$need_dash_r" in
3364     1) LDFLAGS="$LDFLAGS -R$OPENSSL_LIB"
3365    esac
3366    AC_SUBST(LCRYPTO, [-lcrypto])
3367    AC_DEFINE(OPENSSL, , [Use OpenSSL?])
3368esac
3369
3370#
3371# OpenSSL has a number of callback prototypes inside other function
3372# prototypes which trigger copious warnings with -Wstrict-prototypes,
3373# (which is included in -Wall).
3374#
3375# An example:
3376#
3377# int i2d_RSA_NET(const RSA *a, unsigned char **pp,
3378#                 int (*cb)(), int sgckey);
3379#                 ^^^^^^^^^^^
3380#
3381# The OpenSSL headers probably haven't been fixed in this regard
3382# due to the hoops you have to jump through to stay compatible with
3383# K&R C compilers.
3384#
3385case "$GCC$ntp_openssl" in
3386 yesyes)
3387    CFLAGS="$CFLAGS -Wno-strict-prototypes"
3388esac
3389
3390AC_MSG_CHECKING([if we want to compile with ElectricFence])
3391AC_ARG_WITH(electricfence,
3392	AC_HELP_STRING([--with-electricfence], [- compile with ElectricFence malloc debugger]),
3393[ans=$withval], [ans=no])
3394case "$ans" in
3395 no) ;;
3396 *)
3397    LIBS="$LIBS \${top_builddir}/ElectricFence/libefence.a"
3398    EF_PROGS="eftest tstheap"
3399    AC_SUBST(EF_PROGS)
3400    EF_LIBS=libefence.a
3401    AC_SUBST(EF_LIBS)
3402    ans=yes
3403    ;;
3404esac
3405AC_MSG_RESULT([$ans])
3406
3407AC_SUBST(MAKE_CHECK_LAYOUT)
3408AC_MSG_CHECKING([if we want to run check-layout])
3409case "$cross_compiling$PATH_PERL" in
3410 no/*)
3411    MAKE_CHECK_LAYOUT=check-layout
3412    ans=yes
3413    ;;
3414 *)
3415    ans=no
3416    ;;
3417esac
3418AC_MSG_RESULT([$ans])
3419
3420AC_SUBST(TESTDCF)
3421AC_SUBST(DCFD)
3422
3423AC_MSG_CHECKING([if we can make dcf parse utilities])
3424ans=no
3425if test "$ntp_parseutil" = "yes"; then
3426    case "$host" in
3427     *-*-sunos4*|*-*-solaris2*|*-*-*linux*|*-*-netbsd*)
3428	ans="dcfd testdcf"
3429	DCFD=dcfd
3430        TESTDCF=testdcf
3431	;;
3432    esac
3433fi
3434AC_MSG_RESULT([$ans])
3435
3436AC_SUBST(MAKE_PARSEKMODULE)
3437AC_MSG_CHECKING([if we can build kernel streams modules for parse])
3438ans=no
3439case "$ntp_parseutil$ac_cv_header_sys_stropts_h" in
3440 yesyes)
3441    case "$host" in
3442     sparc-*-sunos4*)
3443        case "$ac_cv_var_kernel_pll" in
3444	yes)
3445	    AC_DEFINE(PPS_SYNC, 1, [PARSE kernel PLL PPS support])
3446	    ;;
3447	esac
3448	ans=parsestreams
3449	MAKE_PARSEKMODULE=parsestreams.loadable_module.o
3450	;;
3451     sparc-*-solaris2*)
3452	ans=parsesolaris
3453	MAKE_PARSEKMODULE=parse
3454	AC_CHECK_HEADERS([strings.h])
3455	;;
3456    esac
3457    ;;
3458esac
3459AC_MSG_RESULT([$ans])
3460
3461AC_MSG_CHECKING([if we need basic refclock support])
3462if test "$ntp_refclock" = "yes"; then
3463    AC_DEFINE(REFCLOCK, 1, [Basic refclock support?])
3464fi
3465AC_MSG_RESULT($ntp_refclock)
3466
3467dnl Things that can be made in clockstuff/
3468AC_SUBST(PROPDELAY)	dnl Set to "propdelay"
3469AC_SUBST(CHUTEST)	dnl Set to "chutest"
3470AC_SUBST(CLKTEST)	dnl Set to "clktest"
3471
3472AC_SUBST(MAKE_ADJTIMED)
3473AC_MSG_CHECKING(if we want HP-UX adjtimed support)
3474case "$host" in
3475 *-*-hpux[[56789]]*)
3476    ans=yes
3477    ;;
3478 *) ans=no
3479    ;;
3480esac
3481if test "$ans" = "yes"; then
3482    MAKE_ADJTIMED=adjtimed
3483    AC_DEFINE(NEED_HPUX_ADJTIME, 1, [Do we need HPUX adjtime() library support?])
3484fi
3485AC_MSG_RESULT([$ans])
3486
3487AC_MSG_CHECKING([if we want QNX adjtime support])
3488case "$host" in
3489 *-*-qnx*)
3490    ans=yes
3491    ;;
3492 *) ans=no
3493    ;;
3494esac
3495if test "$ans" = "yes"; then
3496    AC_DEFINE(NEED_QNX_ADJTIME, 1, [Do we need the qnx adjtime call?])
3497fi
3498AC_MSG_RESULT([$ans])
3499
3500AC_MSG_CHECKING([if we can read kmem])
3501
3502#  the default is to enable it if the system has the capability
3503
3504case "$ac_cv_func_nlist$ac_cv_func_K_open$ac_cv_func_kvm_open" in
3505 *yes*)
3506    ans=yes
3507    ;;
3508 *) ans=no
3509esac
3510
3511case "$host" in
3512 *-*-domainos)	# Won't be found...
3513    ans=no
3514    ;;
3515 *-*-hpux*)
3516    #ans=no
3517    ;;
3518 *-*-irix[[456]]*)
3519    ans=no
3520    ;;
3521 *-*-*linux*)
3522    ans=no
3523    ;;
3524 *-*-winnt3.5)
3525    ans=no
3526    ;;
3527 *-*-unicosmp*)
3528    ans=no
3529    ;;
3530esac
3531
3532# --enable-kmem / --disable-kmem controls if present
3533AC_ARG_ENABLE(
3534    [kmem],
3535    AC_HELP_STRING(
3536	[--enable-kmem],
3537	[s read /dev/kmem for tick and/or tickadj]
3538    ),
3539    [ans=$enableval]
3540)
3541
3542AC_MSG_RESULT([$ans])
3543
3544case "$ans" in
3545 yes)
3546    can_kmem=yes
3547    ;;
3548 *)
3549    can_kmem=no
3550    AC_DEFINE(NOKMEM, 1, [Should we NOT read /dev/kmem?])
3551esac
3552
3553
3554AC_MSG_CHECKING([if adjtime is accurate])
3555
3556# target-dependent defaults
3557
3558case "$host" in
3559 i386-sequent-ptx*)
3560    ans=no
3561    ;;
3562 i386-unknown-osf1*)
3563    ans=yes
3564    ;;
3565 mips-sgi-irix[[456]]*)
3566    ans=yes
3567    ;;
3568 *-fujitsu-uxp*)
3569    ans=yes
3570    ;;
3571 *-ibm-aix[[456]]*)
3572    ans=yes
3573    ;;
3574 *-*-*linux*)
3575    ans=yes
3576    ;;
3577 *-*-solaris2.[[01]])
3578    ans=no
3579    ;;
3580 *-*-solaris2*)
3581    ans=yes
3582    ;;
3583 *-*-unicosmp*)
3584    ans=yes
3585    ;;
3586 *) ans=no
3587esac
3588
3589# --enable-accurate-adjtime / --disable-accurate-adjtime
3590# override the default
3591AC_ARG_ENABLE([accurate-adjtime],
3592    AC_HELP_STRING(
3593        [--enable-accurate-adjtime],
3594        [s the adjtime() call is accurate]
3595    ),
3596    [ans=$enableval],
3597)
3598
3599AC_MSG_RESULT([$ans])
3600
3601case "$ans" in
3602 yes)
3603    AC_DEFINE(ADJTIME_IS_ACCURATE, 1, [Is adjtime() accurate?])
3604    adjtime_is_accurate=yes
3605    ;;
3606 *)
3607    adjtime_is_accurate=no
3608esac
3609
3610AC_CACHE_CHECK([the name of 'tick' in the kernel],
3611ac_cv_var_nlist_tick,
3612[ans=_tick
3613case "$host" in
3614 m68*-hp-hpux*) # HP9000/300?
3615    ans=_old_tick
3616    ;;
3617 *-apple-aux[[23]]*)
3618    ans=tick
3619    ;;
3620 *-hp-hpux*)
3621    ans=old_tick
3622    ;;
3623 *-ibm-aix[[3456]]*)
3624    ans=no
3625    ;;
3626 *-*-mpeix*)
3627    ans=no
3628    ;;
3629 *-*-ptx*)
3630    ans=tick
3631    ;;
3632 *-*-sco3.2v[[45]]*)
3633    ans=no
3634    ;;
3635 *-*-solaris2*)
3636    ans=nsec_per_tick
3637    ;;
3638 *-*-sysv4*)
3639    ans=tick
3640    ;;
3641esac
3642ac_cv_var_nlist_tick=$ans])
3643case "$ac_cv_var_nlist_tick" in
3644 ''|no) ;;	# HMS: I think we can only get 'no' here...
3645 *) AC_DEFINE_UNQUOTED(K_TICK_NAME, "$ac_cv_var_nlist_tick", [What is the name of TICK in the kernel?]) ;;
3646esac
3647#
3648AC_CACHE_CHECK([for the units of 'tick'],
3649ac_cv_var_tick_nano,
3650[ans=usec
3651case "$host" in
3652 *-*-solaris2*)
3653    ans=nsec
3654    ;;
3655esac
3656ac_cv_var_tick_nano=$ans])
3657case "$ac_cv_var_tick_nano" in
3658 nsec)
3659    AC_DEFINE(TICK_NANO, 1, [Is K_TICK_NAME in nanoseconds?])
3660    ;;
3661esac
3662#
3663AC_CACHE_CHECK([the name of 'tickadj' in the kernel],
3664ac_cv_var_nlist_tickadj,
3665[ans=_tickadj
3666case "$host" in
3667 m68*-hp-hpux*) # HP9000/300?
3668    ans=_tickadj
3669    ;;
3670 *-apple-aux[[23]]*)
3671    ans=tickadj
3672    ;;
3673 *-hp-hpux10*)
3674    ans=no
3675    ;;
3676 *-hp-hpux9*)
3677    ans=no
3678    ;;
3679 *-hp-hpux*)
3680    ans=tickadj
3681    ;;
3682 *-*-aix*)
3683    ans=tickadj
3684    ;;
3685 *-*-mpeix*)
3686    ans=no
3687    ;;
3688 *-*-ptx*)
3689    ans=tickadj
3690    ;;
3691 *-*-sco3.2v4*)
3692    ans=no
3693    ;;
3694 *-*-sco3.2v5.0*)
3695    ans=clock_drift
3696    ;;
3697 *-*-solaris2*)
3698    ans=no	# hrestime_adj
3699    ;;
3700 *-*-sysv4*)
3701    ans=tickadj
3702    ;;
3703esac
3704ac_cv_var_nlist_tickadj=$ans])
3705case "$ac_cv_var_nlist_tickadj" in
3706 ''|no) ;;	# HMS: I think we can only get 'no' here...
3707 *) AC_DEFINE_UNQUOTED(K_TICKADJ_NAME, "$ac_cv_var_nlist_tickadj", [What is the name of TICKADJ in the kernel?]) ;;
3708esac
3709#
3710AC_CACHE_CHECK([for the units of 'tickadj'],
3711ac_cv_var_tickadj_nano,
3712[ans=usec
3713case "$host" in
3714 *-*-solaris2*)
3715    ans=nsec
3716    ;;
3717esac
3718ac_cv_var_tickadj_nano=$ans])
3719case "$ac_cv_var_tickadj_nano" in
3720 nsec)
3721    AC_DEFINE(TICKADJ_NANO, 1, [Is K_TICKADJ_NAME in nanoseconds?])
3722    ;;
3723esac
3724#
3725AC_CACHE_CHECK([half-heartedly for 'dosynctodr' in the kernel],
3726ac_cv_var_nlist_dosynctodr,
3727[case "$host" in
3728 *-apple-aux[[23]]*)
3729    ans=no
3730    ;;
3731 *-sni-sysv*)
3732    ans=dosynctodr
3733    ;;
3734 *-*-aix*)
3735    ans=dosynctodr
3736    ;;
3737 *-*-hpux*)
3738    ans=no
3739    ;;
3740 *-*-mpeix*)
3741    ans=no
3742    ;;
3743 *-*-nextstep*)
3744    ans=_dosynctodr
3745    ;;
3746 *-*-ptx*)
3747    ans=doresettodr
3748    ;;
3749 *-*-sco3.2v4*)
3750    ans=no
3751    ;;
3752 *-*-sco3.2v5*)
3753    ans=track_rtc
3754    ;;
3755 *-*-solaris2*)
3756    ans=dosynctodr
3757    ;;
3758 *-*-sysv4*)
3759    ans=doresettodr
3760    ;;
3761 *)
3762    ans=_dosynctodr
3763    ;;
3764esac
3765ac_cv_var_nlist_dosynctodr=$ans])
3766case "$ac_cv_var_nlist_dosynctodr" in
3767 no) ;;
3768 *)  AC_DEFINE_UNQUOTED(K_DOSYNCTODR_NAME, "$ac_cv_var_nlist_dosynctodr", [What is (probably) the name of DOSYNCTODR in the kernel?])
3769     ;;
3770esac
3771#
3772AC_CACHE_CHECK([half-heartedly for 'noprintf' in the kernel],
3773ac_cv_var_nlist_noprintf,
3774[case "$host" in
3775 *-apple-aux[[23]]*)
3776    ans=no
3777    ;;
3778 *-sni-sysv*)
3779    ans=noprintf
3780    ;;
3781 *-*-aix*)
3782    ans=noprintf
3783    ;;
3784 *-*-hpux*)
3785    ans=no
3786    ;;
3787 *-*-mpeix*)
3788    ans=no
3789    ;;
3790 *-*-ptx*)
3791    ans=noprintf
3792    ;;
3793 *-*-nextstep*)
3794    ans=_noprintf
3795    ;;
3796 *-*-solaris2*)
3797    ans=noprintf
3798    ;;
3799 *-*-sysv4*)
3800    ans=noprintf
3801    ;;
3802 *)
3803    ans=_noprintf
3804    ;;
3805esac
3806ac_cv_var_nlist_noprintf=$ans])
3807case "$ac_cv_var_nlist_noprintf" in
3808 no) ;;
3809 *)  AC_DEFINE_UNQUOTED(K_NOPRINTF_NAME, "$ac_cv_var_nlist_noprintf", [What is (probably) the name of NOPRINTF in the kernel?])
3810     ;;
3811esac
3812
3813dnl The tick/tickadj sections were written by Skippy, who never learned
3814dnl that it's impolite (horridly gross) to show your guts in public.
3815
3816dnl	tick		tickadj
3817dnl	10000		80	    Unixware
3818dnl	1000000L/hz	tick/16     (Solaris,UXPV,HPUX) && ADJTIME_IS_ACCURATE
3819dnl	10000		150	    sgi IRIX
3820dnl	1000000L/hz	1000	    RS6000 && NOKMEM
3821dnl	1000000L/hz	668	    DOMAINOS && NOKMEM
3822dnl	1000000L/hz	500/HZ	    other && NOKMEM
3823dnl	txc.tick	1	    Linux
3824dnl	(every / 10)	50	    WinNT - tickadj is roughly 500/hz
3825dnl	1000000L/hz	(nlist)     (Solaris && !ADJTIME_IS_ACCURATE),
3826dnl				    (RS6000 && !NOKMEM), SINIX MIPS
3827
3828dnl But we'll only use these "values" if we can't find anything else.
3829
3830AC_MSG_CHECKING([for a default value for 'tick'])
3831
3832# target-dependent default for tick
3833
3834case "$host" in
3835 *-*-pc-cygwin*)
3836    AC_MSG_ERROR([tick needs work for cygwin])
3837    ;;
3838 *-univel-sysv*)
3839    ans=10000
3840    ;;
3841 *-*-irix*)
3842    ans=10000
3843    ;;
3844 *-*-*linux*)
3845    ans=txc.tick
3846    ;;
3847 *-*-mpeix*)
3848    ans=no
3849    ;;
3850 *-*-winnt3.5)
3851    ans='(every / 10)'
3852    ;;
3853 *-*-unicosmp*)
3854    ans=10000
3855    ;;
3856 *)
3857    ans='1000000L/hz'
3858    ;;
3859esac
3860
3861AC_ARG_ENABLE(
3862    [tick],
3863    AC_HELP_STRING(
3864	[--enable-tick=VALUE],
3865	[s force a value for 'tick']
3866    ),
3867    [ans=$enableval]
3868)
3869
3870AC_MSG_RESULT([$ans])
3871
3872case "$ans" in
3873 ''|no) ;;	# HMS: I think we can only get 'no' here...
3874 *) AC_DEFINE_UNQUOTED(PRESET_TICK, [$ans], [Preset a value for 'tick'?]) ;;
3875esac
3876
3877
3878AC_MSG_CHECKING([for a default value for 'tickadj'])
3879
3880# target-specific default
3881
3882ans='500/hz'
3883
3884case "$host" in
3885 *-fujitsu-uxp*)
3886    case "$adjtime_is_accurate" in
3887     yes)
3888         ans='tick/16'
3889    esac
3890    ;;
3891 XXX-*-pc-cygwin*)
3892    ans=no
3893    ;;
3894 *-univel-sysv*)
3895    ans=80
3896    ;;
3897 *-*-aix*)
3898    case "$can_kmem" in
3899     no)
3900	ans=1000
3901    esac
3902    ;;
3903 *-*-domainos)	# Skippy: won't be found...
3904    case "$can_kmem" in
3905     no)
3906	ans=668
3907    esac
3908    ;;
3909 *-*-hpux*)
3910    case "$adjtime_is_accurate" in
3911     yes)
3912	ans='tick/16'
3913    esac
3914    ;;
3915 *-*-irix*)
3916    ans=150
3917    ;;
3918 *-*-mpeix*)
3919    ans=no
3920    ;;
3921 *-*-sco3.2v5.0*)
3922    ans=10000L/hz
3923    ;;
3924 *-*-winnt3.5)
3925    ans=50
3926    ;;
3927 *-*-unicosmp*)
3928    ans=150
3929esac
3930
3931AC_ARG_ENABLE(
3932    [tickadj],
3933    AC_HELP_STRING(
3934        [--enable-tickadj=VALUE],
3935        [s force a value for 'tickadj']
3936    ),
3937    [ans=$enableval]
3938)
3939
3940AC_MSG_RESULT([$ans])
3941
3942default_tickadj=$ans
3943
3944case "$default_tickadj" in
3945 ''|no) ;;	# HMS: I think we can only get 'no' here...
3946 *) AC_DEFINE_UNQUOTED(PRESET_TICKADJ, $default_tickadj, [Preset a value for 'tickadj'?]) ;;
3947esac
3948
3949# Newer versions of ReliantUNIX round adjtime() values down to
3950# 1/100s (system tick). Sigh ...
3951# Unfortunately, there is no easy way to know if particular release
3952# has this "feature" or any obvious way to test for it.
3953case "$host" in
3954 mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX_CLOCK, 1, [Do we want the ReliantUNIX clock hacks?]) ;;
3955esac
3956
3957case "$host" in
3958 *-*-sco3.2v5*) AC_DEFINE(SCO5_CLOCK, 1, [Do we want the SCO clock hacks?]) ;;
3959esac
3960
3961ac_cv_make_tickadj=yes
3962case "$can_kmem$ac_cv_var_tick$default_tickadj" in
3963 nonono)	# Don't read KMEM, no presets.  Bogus.
3964    AC_MSG_WARN([Can't read kmem, no PRESET_TICK or PRESET_TICKADJ.  No tickadj.])
3965    ac_cv_make_tickadj=no
3966    ;;
3967 nono*)		# Don't read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
3968    AC_MSG_WARN([Can't read kmem but no PRESET_TICK.  No tickadj.])
3969    ac_cv_make_tickadj=no
3970    ;;
3971 no*no)		# Don't read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Bogus.
3972    AC_MSG_WARN([Can't read kmem but no PRESET_TICKADJ.  No tickadj.])
3973    ac_cv_make_tickadj=no
3974    ;;
3975 no*)		# Don't read KMEM, PRESET_TICK and PRESET_TICKADJ.  Cool.
3976    ;;
3977 yesnono)	# Read KMEM, no presets.  Cool.
3978    ;;
3979 yesno*)	# Read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
3980    AC_MSG_WARN([PRESET_TICKADJ is defined but not PRESET_TICK.  Please report this.])
3981    ;;
3982 yes*no)	# Read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Cool.
3983    ;;
3984 yes*)		# READ KMEM, PRESET_TICK and PRESET_TICKADJ.
3985    ;;
3986 *)		# Generally bogus.
3987    AC_MSG_ERROR([This shouldn't happen.])
3988    ;;
3989esac
3990
3991AC_SUBST(MAKE_NTPTIME)
3992AC_CACHE_CHECK([if we want and can make the ntptime utility], ac_cv_make_ntptime,
3993[case "$host" in
3994 *) case "$ac_cv_struct_ntptimeval$ac_cv_var_kernel_pll" in
3995     yesyes)
3996	ans=yes
3997	;;
3998     *)
3999	ans=no
4000	;;
4001    esac
4002    ;;
4003esac
4004ac_cv_make_ntptime=$ans])
4005case "$ac_cv_make_ntptime" in
4006 yes)
4007    MAKE_NTPTIME=ntptime
4008    ;;
4009esac
4010
4011AC_SUBST(MAKE_TICKADJ)
4012case "$host" in
4013 mips-sni-sysv4*)
4014    # tickadj is pretty useless on newer versions of ReliantUNIX
4015    # Do not bother
4016    ac_cv_make_tickadj=no
4017    ;;
4018 *-*-irix*)
4019    ac_cv_make_tickadj=no
4020    ;;
4021 *-*-solaris2*)
4022    # DLM says tickadj is a no-no starting with solaris2.5
4023    case "$host" in
4024     *-*-solaris2.1[[0-9]]*)
4025	ac_cv_make_tickadj=no
4026	;;
4027     *-*-solaris2.[[0-4]]*) ;;
4028     *) ac_cv_make_tickadj=no ;;
4029    esac
4030    ;;
4031 *-*-unicosmp*)
4032    ac_cv_make_tickadj=no
4033    ;;
4034esac
4035
4036#
4037# Despite all the above, we always make tickadj.  Setting
4038# ac_cv_make_tickadj before AC_CACHE_CHECK will cause a false
4039# report that the configuration variable was cached.  It may
4040# be better to simply remove the hunk above, I did not want
4041# to remove it if there is hope it will be used again.
4042#
4043$as_unset ac_cv_make_tickadj
4044
4045AC_CACHE_CHECK([if we want and can make the tickadj utility], ac_cv_make_tickadj,
4046ac_cv_make_tickadj=yes)
4047case "$ac_cv_make_tickadj" in
4048 yes)
4049    MAKE_TICKADJ=tickadj
4050    ;;
4051esac
4052
4053AC_SUBST(MAKE_TIMETRIM)
4054AC_CACHE_CHECK([if we want and can make the timetrim utility], ac_cv_make_timetrim,
4055[case "$host" in
4056 *-*-irix*)
4057    ac_cv_make_timetrim=yes
4058    ;;
4059 *-*-unicosmp*)
4060    ac_cv_make_timetrim=yes
4061    ;;
4062 *)
4063    ac_cv_make_timetrim=no
4064    ;;
4065esac])
4066case "$ac_cv_make_timetrim" in
4067 yes)
4068    MAKE_TIMETRIM=timetrim
4069    ;;
4070esac
4071
4072AC_SUBST(MAKE_LIBNTPSIM)
4073AC_SUBST(MAKE_NTPDSIM)
4074
4075AC_MSG_CHECKING([if we want to build the NTPD simulator])
4076
4077AC_ARG_ENABLE(
4078    [simulator],
4079    AC_HELP_STRING(
4080	[--enable-simulator],
4081	[- build/install the NTPD simulator?]
4082    ),
4083    [ans=$enableval],
4084    [ans=no]
4085)
4086
4087AC_MSG_RESULT([$ans])
4088
4089case "$ans" in
4090 yes)
4091    MAKE_NTPDSIM=ntpdsim
4092    MAKE_LIBNTPSIM=libntpsim.a
4093    ;;
4094esac
4095
4096case "$build" in
4097 $host)
4098    ;;
4099 *) case "$host" in
4100     *-*-vxworks*)
4101	LDFLAGS="$LDFLAGS -r"
4102	;;
4103    esac
4104    ;;
4105esac
4106
4107
4108AC_MSG_CHECKING([if we want to build ntpsnmpd])
4109AC_ARG_WITH(ntpsnmpd,
4110	AC_HELP_STRING([--with-ntpsnmpd], [s Build ntpsnmpd MIB agent?]),
4111	[ans=$withval],
4112	[case "$PATH_NET_SNMP_CONFIG" in
4113	 /*)	ans=yes ;;
4114	 *)	ans=no  ;;
4115	esac])
4116AC_MSG_RESULT($ans)
4117
4118case "$ans" in
4119 yes)
4120    case "$PATH_NET_SNMP_CONFIG" in
4121     /*)
4122	SNMP_LIBS=`$PATH_NET_SNMP_CONFIG --agent-libs`
4123	AC_SUBST(SNMP_LIBS)
4124	# HMS: we really want to separate CPPFLAGS and CFLAGS
4125	foo=`$PATH_NET_SNMP_CONFIG --cflags`
4126	SNMP_CPPFLAGS=
4127	SNMP_CFLAGS=
4128	for i in $foo; do
4129	    case "$i" in
4130	     -D*|-U*|-I*)
4131		SNMP_CPPFLAGS="$SNMP_CPPFLAGS $i"
4132		;;
4133	    *)	SNMP_CFLAGS="$SNMP_CFLAGS $i"
4134		;;
4135	    esac
4136	done
4137	AC_SUBST(SNMP_CPPFLAGS)
4138	AC_SUBST(SNMP_CFLAGS)
4139
4140	save_CFLAGS=$CFLAGS
4141	save_CPPFLAGS=$CPPFLAGS
4142	save_LIBS=$LIBS
4143	CFLAGS=$SNMP_CFLAGS
4144	CPPFLAGS=$SNMP_CPPFLAGS
4145
4146	AC_CHECK_HEADER([net-snmp/net-snmp-config.h], [MAKE_NTPSNMPD=ntpsnmpd],
4147		[AC_MSG_WARN([net-snmp-config present but net-snmp headers are not available!])])
4148
4149	# Do this last, as we're messing up LIBS.
4150
4151	# check -lnetsnmp for netsnmp_daemonize
4152	LIBS=`$PATH_NET_SNMP_CONFIG --libs`
4153	AC_CHECK_LIB([netsnmp], [netsnmp_daemonize], [],
4154		[AC_DEFINE([NEED_NETSNMP_DAEMONIZE], [1],
4155			[We need to provide netsnmp_daemonize()])])
4156
4157	CFLAGS=$save_CFLAGS
4158	CPPFLAGS=$save_CPPFLAGS
4159	LIBS=$save_LIBS
4160
4161	;;
4162     *) AC_MSG_WARN([Cannot build ntpsnmpd as desired - net-snmp-config cannot be found])
4163	;;
4164    esac
4165    ;;
4166esac
4167AC_SUBST(MAKE_NTPSNMPD)
4168
4169
4170AC_MSG_CHECKING([if we should always slew the time])
4171
4172# target-specific defaults
4173
4174case "$host" in
4175 *-apple-aux[[23]]*)
4176    ans=yes
4177    ;;
4178 *-*-bsdi[[012]]*)
4179    ans=no
4180    ;;
4181 *-*-bsdi*)
4182    ans=yes
4183    ;;
4184 *-*-openvms*)	# HMS: won't be found
4185    ans=yes
4186    ;;
4187 *) ans=no
4188    ;;
4189esac
4190
4191# --enable-slew-always / --disable-slew-always overrides default
4192
4193AC_ARG_ENABLE(
4194    [slew-always],
4195    AC_HELP_STRING(
4196	[--enable-slew-always],
4197	[s always slew the time]
4198    ),
4199    [ans=$enableval]
4200)
4201
4202AC_MSG_RESULT([$ans])
4203
4204case "$ans" in
4205 yes) AC_DEFINE(SLEWALWAYS, 1, [Slew always?]) ;;
4206esac
4207
4208AC_MSG_CHECKING([if we should step and slew the time])
4209
4210case "$host" in
4211 *-sni-sysv*)
4212    ans=yes
4213    ;;
4214 *-univel-sysv*)
4215    ans=no
4216    ;;
4217 *-*-ptx*)
4218    ans=yes
4219    ;;
4220 *-*-solaris2.1[[0-9]]*)
4221    ans=no
4222    ;;
4223 *-*-solaris2.[[012]]*)
4224    ans=yes
4225    ;;
4226 *-*-sysv4*)	# HMS: Does this catch Fujitsu UXP?
4227    ans=yes
4228    ;;
4229 *) ans=no
4230    ;;
4231esac
4232
4233
4234AC_ARG_ENABLE(
4235    [step-slew],
4236    AC_HELP_STRING(
4237	[--enable-step-slew],
4238	[s step and slew the time]
4239    ),
4240    [ans=$enableval]
4241)
4242
4243AC_MSG_RESULT([$ans])
4244
4245case "$ans" in
4246 yes) AC_DEFINE(STEP_SLEW, 1, [Step, then slew the clock?]) ;;
4247esac
4248
4249AC_MSG_CHECKING([if ntpdate should step the time])
4250
4251case "$host" in
4252 *-apple-aux[[23]]*)
4253    ans=yes
4254    ;;
4255 *) ans=no
4256esac
4257
4258AC_ARG_ENABLE(
4259    [ntpdate-step],
4260    AC_HELP_STRING(
4261	[--enable-ntpdate-step],
4262	[s if ntpdate should step the time]
4263    ),
4264    [ans=$enableval]
4265)
4266
4267AC_MSG_RESULT([$ans])
4268
4269case "$ans" in
4270 yes) AC_DEFINE(FORCE_NTPDATE_STEP, 1, [force ntpdate to step the clock if !defined(STEP_SLEW) ?]) ;;
4271esac
4272
4273
4274AC_MSG_CHECKING([if we should sync TODR clock every hour])
4275
4276case "$host" in
4277 *-*-nextstep*)
4278    ans=yes
4279    ;;
4280 *-*-openvms*)	# HMS: won't be found
4281    ans=yes
4282    ;;
4283 *)
4284    ans=no
4285esac
4286
4287AC_ARG_ENABLE(
4288    [hourly-todr-sync],
4289    AC_HELP_STRING(
4290	[--enable-hourly-todr-sync],
4291	[s if we should sync TODR hourly]
4292    ),
4293    [ans=$enableval]
4294)
4295
4296AC_MSG_RESULT([$ans])
4297
4298case "$ac_cv_var_sync_todr" in
4299 yes) AC_DEFINE(DOSYNCTODR, 1, [synch TODR hourly?]) ;;
4300esac
4301
4302
4303AC_MSG_CHECKING([if we should avoid kernel FLL bug])
4304
4305case "$host" in
4306 *-*-solaris2.6)
4307    unamev=`uname -v`
4308    case "$unamev" in
4309     Generic_105181-*)
4310	old_IFS="$IFS"
4311	IFS="-"
4312	set $unamev
4313	IFS="$old_IFS"
4314	if test "$2" -ge 17
4315	then
4316	    # Generic_105181-17 and higher
4317	    ans=no
4318	else
4319	    ans=yes
4320	fi
4321	;;
4322     *)
4323	ans=yes
4324    esac
4325    ;;
4326 *-*-solaris2.7)
4327    unamev=`uname -v`
4328    case "$unamev" in
4329     Generic_106541-*)
4330	old_IFS="$IFS"
4331	IFS="-"
4332	set $unamev
4333	IFS="$old_IFS"
4334	if test "$2" -ge 07
4335	then
4336	    # Generic_106541-07 and higher
4337	    ans=no
4338	else
4339	    ans=yes
4340	fi
4341	;;
4342     *)
4343	ans=yes
4344    esac
4345    ;;
4346 *)
4347    ans=no
4348esac
4349
4350AC_ARG_ENABLE(
4351    [kernel-fll-bug],
4352    AC_HELP_STRING(
4353	[--enable-kernel-fll-bug],
4354	[s if we should avoid a kernel FLL bug]
4355    ),
4356    [ans=$enableval]
4357)
4358
4359AC_MSG_RESULT([$ans])
4360
4361case "$ans" in
4362 yes) AC_DEFINE(KERNEL_FLL_BUG, 1, [Does the kernel have an FLL bug?]) ;;
4363esac
4364
4365
4366AC_MSG_CHECKING([if we want new session key behavior])
4367
4368AC_ARG_ENABLE(
4369    [bug1243-fix],
4370    AC_HELP_STRING(
4371	[--enable-bug1243-fix],
4372	[+ use unmodified autokey session keys]
4373    ),
4374    [ans=$enableval],
4375    [ans=yes]
4376)
4377
4378AC_MSG_RESULT([$ans])
4379
4380case "$ans" in
4381 no)
4382    AC_DEFINE([DISABLE_BUG1243_FIX], 1, [use old autokey session key behavior?])
4383esac
4384
4385
4386AC_MSG_CHECKING([if we should use the IRIG sawtooth filter])
4387
4388case "$host" in
4389 *-*-solaris2.[[89]])
4390    ans=yes
4391    ;;
4392 *-*-solaris2.1[[0-9]]*)
4393    ans=yes
4394    ;;
4395 *) ans=no
4396esac
4397
4398AC_ARG_ENABLE(
4399    [irig-sawtooth],
4400    AC_HELP_STRING(
4401	[--enable-irig-sawtooth],
4402	[s if we should enable the IRIG sawtooth filter]
4403    ),
4404    [ans=$enableval]
4405)
4406
4407AC_MSG_RESULT([$ans])
4408
4409case "$ans" in
4410 yes) AC_DEFINE(IRIG_SUCKS, 1, [Should we use the IRIG sawtooth filter?]) ;;
4411esac
4412
4413
4414AC_MSG_CHECKING([if we should enable NIST lockclock scheme])
4415
4416AC_ARG_ENABLE(
4417	[nist],
4418	AC_HELP_STRING(
4419	    [--enable-nist],
4420	    [- if we should enable the NIST lockclock scheme]
4421	),
4422	[ans=$enableval],
4423	[ans=no]
4424)
4425
4426AC_MSG_RESULT([$ans])
4427
4428case "$ans" in
4429 yes) AC_DEFINE(LOCKCLOCK, 1, [Should we align with the NIST lockclock scheme?]) ;;
4430esac
4431
4432
4433AC_MSG_CHECKING([if we want support for Samba's signing daemon])
4434
4435AC_ARG_ENABLE(
4436    [ntp-signd],
4437    AC_HELP_STRING(
4438	[--enable-ntp-signd],
4439	[- Provide support for Samba's signing daemon, =/var/run/ntp_signd]
4440    ),
4441    [ans=$enableval],
4442    [ans=no]
4443)
4444
4445AC_MSG_RESULT([$ans])
4446
4447case "$ans" in
4448 no)
4449    ntp_signd_path=
4450    ;;
4451 yes)
4452    ntp_signd_path=/var/run/ntp_signd
4453    ;;
4454 *)
4455    ntp_signd_path="$ans"
4456esac
4457
4458case "$ntp_signd_path" in
4459 '')
4460    ;;
4461 *)
4462    AC_DEFINE(HAVE_NTP_SIGND, ,[Do we want support for Samba's signing daemon?])
4463    AC_DEFINE_UNQUOTED(NTP_SIGND_PATH, "$ntp_signd_path", [Path to sign daemon rendezvous socket])
4464esac
4465
4466
4467AC_CHECK_HEADERS(sys/clockctl.h)
4468
4469case "$host" in
4470 *-*-netbsd*)
4471    ans=yes
4472    ;;
4473 *) ans=no
4474    ;;
4475esac
4476
4477AC_ARG_ENABLE(
4478    [clockctl],
4479    AS_HELP_STRING(
4480	[--enable-clockctl],
4481	[s Use /dev/clockctl for non-root clock control]
4482    ),
4483    [ntp_use_dev_clockctl=$enableval],
4484    [ntp_use_dev_clockctl=$ac_cv_header_sys_clockctl_h]
4485)
4486
4487AC_MSG_CHECKING([[if we should use /dev/clockctl]])
4488AC_MSG_RESULT([$ntp_use_dev_clockctl])
4489
4490
4491AC_CHECK_HEADERS([sys/capability.h])
4492AC_CHECK_HEADERS([sys/prctl.h])
4493
4494AC_MSG_CHECKING([[if we have linux capabilities (libcap)]])
4495
4496case "$ac_cv_header_sys_capability_h$ac_cv_header_sys_prctl_h" in
4497 yesyes)
4498    ntp_have_linuxcaps=yes
4499    ;;
4500 *)
4501    ntp_have_linuxcaps=no
4502esac
4503
4504AC_ARG_ENABLE(
4505    [linuxcaps],
4506    AS_HELP_STRING(
4507	[--enable-linuxcaps],
4508	[+ Use Linux capabilities for non-root clock control]
4509    ),
4510    [ntp_have_linuxcaps=$enableval]
4511)
4512
4513AC_MSG_RESULT([$ntp_have_linuxcaps])
4514
4515case "$ntp_have_linuxcaps" in
4516 yes)
4517    AC_DEFINE(HAVE_LINUX_CAPABILITIES, ,[Do we have Linux capabilities?])
4518    LIBS="$LIBS -lcap"
4519esac
4520
4521case "$ntp_use_dev_clockctl$ntp_have_linuxcaps" in
4522 *yes*)
4523    AC_DEFINE(HAVE_DROPROOT, ,[Can we drop root privileges?])
4524esac
4525
4526
4527AC_CHECK_HEADERS([libscf.h])
4528
4529case "$ac_cv_header_libscf_h" in
4530 yes)
4531    AC_SUBST(LSCF, [-lscf])
4532esac
4533
4534AC_CHECK_FUNC(
4535    [setppriv],
4536    AC_DEFINE(HAVE_SOLARIS_PRIVS, ,[Are Solaris privileges available?])
4537)
4538
4539
4540#
4541# ISC stuff
4542#
4543
4544AC_CACHE_CHECK(
4545    [struct sockaddr for sa_len],
4546    isc_cv_platform_havesalen,
4547    [
4548	AC_TRY_COMPILE(
4549	    [
4550		#include <sys/types.h>
4551		#include <sys/socket.h>
4552	    ],
4553	    [
4554		extern struct sockaddr *ps;
4555		return ps->sa_len;
4556	    ],
4557	    [isc_cv_platform_havesalen=yes],
4558	    [isc_cv_platform_havesalen=no]
4559	)
4560    ]
4561)
4562if test $isc_cv_platform_havesalen = yes; then
4563    AC_DEFINE(ISC_PLATFORM_HAVESALEN, ,[struct sockaddr has sa_len?])
4564fi
4565
4566AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--enable-ipv6], [s use IPv6?]))
4567
4568case "$enable_ipv6" in
4569 yes|''|autodetect)
4570    case "$host" in
4571     powerpc-ibm-aix4*) ;;
4572     *)
4573	AC_DEFINE(WANT_IPV6, ,[configure --enable-ipv6])
4574	;;
4575    esac
4576    ;;
4577 no)
4578    ;;
4579esac
4580
4581
4582AC_CACHE_CHECK(
4583    [for IPv6 structures],
4584    ac_cv_isc_found_ipv6,
4585    [
4586	AC_COMPILE_IFELSE(
4587	    [
4588		AC_LANG_PROGRAM(
4589		    [
4590			#include <sys/types.h>
4591			#include <sys/socket.h>
4592			#include <netinet/in.h>
4593		    ],
4594		    [
4595			struct sockaddr_in6 sin6;
4596		    ]
4597		)
4598	    ],
4599	    [ac_cv_isc_found_ipv6=yes],
4600	    [ac_cv_isc_found_ipv6=no]
4601	)
4602    ]
4603)
4604
4605#
4606# See whether IPv6 support is provided via a Kame add-on.
4607# This is done before other IPv6 linking tests so LIBS is properly set.
4608#
4609AC_MSG_CHECKING([for Kame IPv6 support])
4610AC_ARG_WITH(kame,
4611	[AC_HELP_STRING([--with-kame], [- =/usr/local/v6])],
4612	use_kame="$withval", use_kame="no")
4613
4614
4615case "$use_kame" in
4616 no)
4617    ;;
4618 yes)
4619    kame_path=/usr/local/v6
4620    ;;
4621 *)
4622    kame_path="$use_kame"
4623    ;;
4624esac
4625
4626case "$use_kame" in
4627 no)
4628    AC_MSG_RESULT(no)
4629    ;;
4630 *)
4631    if test -f $kame_path/lib/libinet6.a; then
4632	AC_MSG_RESULT($kame_path/lib/libinet6.a)
4633	LIBS="-L$kame_path/lib -linet6 $LIBS"
4634    else
4635	AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
4636
4637Please choose the proper path with the following command:
4638
4639    configure --with-kame=PATH
4640])
4641    fi
4642    ;;
4643esac
4644
4645#
4646# Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
4647# Including it on Kame-using platforms is very bad, though, because
4648# Kame uses #error against direct inclusion.   So include it on only
4649# the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
4650# This is done before the in6_pktinfo check because that's what
4651# netinet6/in6.h is needed for.
4652#
4653case "$host" in
4654 *-bsdi4.[[01]]*)
4655    AC_DEFINE(ISC_PLATFORM_NEEDNETINET6IN6H, 1, [Do we need netinet6/in6.h?])
4656    isc_netinet6in6_hack="#include <netinet6/in6.h>"
4657    ;;
4658 *)
4659    isc_netinet6in6_hack=""
4660esac
4661
4662#
4663# This is similar to the netinet6/in6.h issue.
4664#
4665case "$host" in
4666 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
4667    AC_DEFINE(ISC_PLATFORM_FIXIN6ISADDR, 1,[Do we need to fix in6isaddr?])
4668    isc_netinetin6_hack="#include <netinet/in6.h>"
4669    ;;
4670 *)
4671    isc_netinetin6_hack=""
4672esac
4673
4674
4675case "$ac_cv_isc_found_ipv6" in
4676 yes)
4677    AC_DEFINE(ISC_PLATFORM_HAVEIPV6, ,[have IPv6?])
4678
4679    AC_CACHE_CHECK(
4680	[for in6_pktinfo],
4681	ac_cv_have_in6_pktinfo,
4682	[
4683	    AC_COMPILE_IFELSE(
4684		[
4685		    AC_LANG_PROGRAM(
4686			[
4687			    #include <sys/types.h>
4688			    #include <sys/socket.h>
4689			    #include <netinet/in.h>
4690			    $isc_netinetin6_hack
4691			    $isc_netinet6in6_hack
4692			],
4693			[
4694			    struct in6_pktinfo xyzzy;
4695			]
4696		    )
4697		],
4698		[ac_cv_have_in6_pktinfo=yes],
4699		[ac_cv_have_in6_pktinfo=no]
4700	    )
4701	]
4702    )
4703
4704    case "$ac_cv_have_in6_pktinfo" in
4705     yes)
4706	AC_DEFINE(ISC_PLATFORM_HAVEIN6PKTINFO, , [have struct in6_pktinfo?])
4707    esac
4708
4709
4710    # HMS: Use HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID instead?
4711    AC_CACHE_CHECK(
4712	[for sockaddr_in6.sin6_scope_id],
4713	ac_cv_have_sin6_scope_id,
4714	[
4715	    AC_COMPILE_IFELSE(
4716		[
4717		    AC_LANG_PROGRAM(
4718			[
4719			    #include <sys/types.h>
4720			    #include <sys/socket.h>
4721			    #include <netinet/in.h>
4722			    $isc_netinetin6_hack
4723			    $isc_netinet6in6_hack
4724			],
4725			[
4726			    struct sockaddr_in6 xyzzy;
4727			    xyzzy.sin6_scope_id = 0;
4728			]
4729		    )
4730		],
4731		[ac_cv_have_sin6_scope_id=yes],
4732		[ac_cv_have_sin6_scope_id=no]
4733	    )
4734	]
4735    )
4736
4737    case "$ac_cv_have_sin6_scope_id" in
4738     yes)
4739	AC_DEFINE(ISC_PLATFORM_HAVESCOPEID, , [have sin6_scope_id?])
4740    esac
4741esac
4742
4743
4744# We need this check run even without ac_cv_isc_found_ipv6=yes
4745
4746AC_CACHE_CHECK(
4747    [for in6addr_any],
4748    isc_cv_have_in6addr_any,
4749    [
4750	AC_LINK_IFELSE(
4751	    [
4752		AC_LANG_PROGRAM(
4753		    [
4754			#include <sys/types.h>
4755			#include <sys/socket.h>
4756			#include <netinet/in.h>
4757			$isc_netinetin6_hack
4758			$isc_netinet6in6_hack
4759		    ],
4760		    [
4761			struct in6_addr in6;
4762			in6 = in6addr_any;
4763		    ]
4764		)
4765	    ],
4766	    [isc_cv_have_in6addr_any=yes],
4767	    [isc_cv_have_in6addr_any=no]
4768	)
4769    ]
4770)
4771
4772case "$isc_cv_have_in6addr_any" in
4773 no)
4774    AC_DEFINE(ISC_PLATFORM_NEEDIN6ADDRANY, , [missing in6addr_any?])
4775esac
4776
4777
4778AC_CACHE_CHECK(
4779    [for struct if_laddrconf],
4780    ac_cv_isc_struct_if_laddrconf,
4781    [
4782        AC_COMPILE_IFELSE(
4783	    [
4784		AC_LANG_PROGRAM(
4785		    [
4786			#include <sys/types.h>
4787			#include <net/if6.h>
4788		    ],
4789		    [
4790			struct if_laddrconf a;
4791		    ]
4792		)
4793	    ],
4794	    [ac_cv_isc_struct_if_laddrconf=yes],
4795	    [ac_cv_isc_struct_if_laddrconf=no]
4796	)
4797    ]
4798)
4799
4800case "$ac_cv_isc_struct_if_laddrconf" in
4801 yes)
4802    AC_DEFINE(ISC_PLATFORM_HAVEIF_LADDRCONF, , [have struct if_laddrconf?])
4803esac
4804
4805AC_CACHE_CHECK(
4806    [for struct if_laddrreq],
4807    ac_cv_isc_struct_if_laddrreq,
4808    [
4809        AC_COMPILE_IFELSE(
4810	    [
4811		AC_LANG_PROGRAM(
4812		    [
4813			#include <sys/types.h>
4814			#include <net/if6.h>
4815		    ],
4816		    [
4817			struct if_laddrreq a;
4818		    ]
4819		)
4820	    ],
4821	    [ac_cv_isc_struct_if_laddrreq=yes],
4822	    [ac_cv_isc_struct_if_laddrreq=no]
4823	)
4824    ]
4825)
4826
4827case "$ac_cv_isc_struct_if_laddrreq" in
4828 yes)
4829    AC_DEFINE(ISC_PLATFORM_HAVEIF_LADDRREQ, , [have struct if_laddrreq?])
4830esac
4831
4832#
4833# Look for a sysctl call to get the list of network interfaces.
4834#
4835AC_CACHE_CHECK(
4836    [for interface list sysctl],
4837    ac_cv_iflist_sysctl,
4838    AC_EGREP_CPP(
4839	[found_rt_iflist],
4840	[
4841	    #include <sys/param.h>
4842	    #include <sys/sysctl.h>
4843	    #include <sys/socket.h>
4844	    #ifdef NET_RT_IFLIST
4845	    found_rt_iflist
4846	    #endif
4847	],
4848	[ac_cv_iflist_sysctl=yes],
4849	[ac_cv_iflist_sysctl=no]
4850    )
4851)
4852
4853case "$ac_cv_iflist_sysctl" in
4854 yes)
4855    AC_DEFINE(HAVE_IFLIST_SYSCTL,1,[have iflist_sysctl?])
4856esac
4857
4858###
4859
4860AC_MSG_CHECKING([if we want the saveconfig mechanism])
4861AC_ARG_ENABLE(saveconfig,
4862    AC_HELP_STRING([--enable-saveconfig], [+ saveconfig mechanism]),
4863    [ntp_ok=$enableval], [ntp_ok=yes])
4864ntp_saveconfig_enabled=0
4865if test "$ntp_ok" = "yes"; then
4866    ntp_saveconfig_enabled=1
4867    AC_DEFINE(SAVECONFIG, 1, [saveconfig mechanism])
4868fi
4869AM_CONDITIONAL([SAVECONFIG_ENABLED], [test x$ntp_saveconfig_enabled = x1])
4870AC_MSG_RESULT($ntp_ok)
4871
4872###
4873
4874AC_DEFINE_DIR(NTP_KEYSDIR, sysconfdir, [Default location of crypto key info])
4875
4876AC_CONFIG_FILES(Makefile)
4877AC_CONFIG_FILES(ElectricFence/Makefile)
4878AC_CONFIG_FILES(adjtimed/Makefile)
4879AC_CONFIG_FILES(clockstuff/Makefile)
4880AC_CONFIG_FILES(include/Makefile)
4881AC_CONFIG_FILES(include/isc/Makefile)
4882AC_CONFIG_FILES(kernel/Makefile)
4883AC_CONFIG_FILES(kernel/sys/Makefile)
4884AC_CONFIG_FILES(libntp/Makefile)
4885AC_CONFIG_FILES(libparse/Makefile)
4886AC_CONFIG_FILES(ntpd/Makefile)
4887AC_CONFIG_FILES(ntpdate/Makefile)
4888AC_CONFIG_FILES(ntpdc/Makefile)
4889AC_CONFIG_FILES(ntpdc/nl.pl,		[chmod +x ntpdc/nl.pl])
4890AC_CONFIG_FILES(ntpq/Makefile)
4891AC_CONFIG_FILES(ntpsnmpd/Makefile)
4892AC_CONFIG_FILES(parseutil/Makefile)
4893AC_CONFIG_FILES(scripts/Makefile)
4894AC_CONFIG_FILES(scripts/calc_tickadj,	[chmod +x scripts/calc_tickadj])
4895AC_CONFIG_FILES(scripts/checktime,	[chmod +x scripts/checktime])
4896AC_CONFIG_FILES(scripts/freq_adj,	[chmod +x scripts/freq_adj])
4897AC_CONFIG_FILES(scripts/html2man,	[chmod +x scripts/html2man])
4898AC_CONFIG_FILES(scripts/mkver,		[chmod +x scripts/mkver])
4899AC_CONFIG_FILES(scripts/ntp-wait,	[chmod +x scripts/ntp-wait])
4900AC_CONFIG_FILES(scripts/ntpsweep,	[chmod +x scripts/ntpsweep])
4901AC_CONFIG_FILES(scripts/ntptrace,	[chmod +x scripts/ntptrace])
4902AC_CONFIG_FILES(scripts/ntpver,		[chmod +x scripts/ntpver])
4903AC_CONFIG_FILES(scripts/plot_summary,	[chmod +x scripts/plot_summary])
4904AC_CONFIG_FILES(scripts/summary,	[chmod +x scripts/summary])
4905AC_CONFIG_FILES(util/Makefile)
4906
4907AC_CONFIG_SUBDIRS(sntp)
4908
4909AC_OUTPUT
4910