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