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