More work on cross long long
[ntpsec.git] / wafhelpers / refclock.py
blob2603139247e2cbcaacaf4df89f22a0b8a3a133ea
1 # Copyright the NTPsec project contributors
3 # SPDX-License-Identifier: BSD-2-Clause
5 from waflib.Configure import conf
6 from waflib.Logs import pprint
8 # Note: When you change this list. also check the following files:
9 # doc/refclock.adoc
10 # include/ntp_refclock.h
11 # ntpd/refclock_conf.c
13 refclock_map = {
15 "local": {
16 "descr": "Undisciplined Local Clock",
17 "define": "CLOCK_LOCAL",
18 "file": "local"
21 "spectracom": {
22 "descr": "Spectracom GPS Receivers",
23 "define": "CLOCK_SPECTRACOM",
24 "file": "spectracom"
27 "truetime": {
28 "descr": "TrueTime GPS/GOES/OMEGA Receivers",
29 "define": "CLOCK_TRUETIME",
30 "file": "truetime"
33 "generic": {
34 "descr": "Generic Reference Driver (Parse)",
35 "define": "CLOCK_GENERIC",
36 "require": ["parse"],
37 "file": "generic"
40 "arbiter": {
41 "descr": "Arbiter 1088A/B GPS Receiver",
42 "define": "CLOCK_ARBITER",
43 "file": "arbiter"
46 "modem": {
47 "descr": "NIST/USNO/PTB Modem Time Services",
48 "define": "CLOCK_MODEM",
49 "file": "modem"
52 "nmea": {
53 "descr": "Generic NMEA GPS Receiver",
54 "define": "CLOCK_NMEA",
55 "file": "nmea"
58 "pps": {
59 "descr": "PPS Clock Discipline",
60 "define": "CLOCK_PPS",
61 "require": ["ppsapi"],
62 "file": "pps"
65 "hpgps": {
66 "descr": "Hewlett Packard 58503A GPS Receiver",
67 "define": "CLOCK_HPGPS",
68 "file": "hpgps"
71 "shm": {
72 "descr": "Shared Memory Driver",
73 "define": "CLOCK_SHM",
74 "file": "shm"
77 "trimble": {
78 "descr": "Trimble Navigation GPSes",
79 "define": "CLOCK_TRIMBLE",
80 "file": "trimble"
83 "oncore": {
84 "descr": "Motorola UT Oncore GPS",
85 "define": "CLOCK_ONCORE",
86 "require": ["ppsapi"],
87 "file": "oncore"
90 "jjy": {
91 "descr": "JJY Receivers",
92 "define": "CLOCK_JJY",
93 "file": "jjy"
96 "zyfer": {
97 "descr": "Zyfer GPStarplus Receiver",
98 "define": "CLOCK_ZYFER",
99 "file": "zyfer"
102 "gpsd": {
103 "descr": "GPSD NG client protocol",
104 "define": "CLOCK_GPSDJSON",
105 "file": "gpsd"
110 @conf
111 def refclock_config(ctx):
112 if ctx.options.refclocks == "all":
113 ids = refclock_map.keys()
114 else:
115 # XXX: better error checking
116 ids = ctx.options.refclocks.split(",")
118 ctx.env.REFCLOCK_SOURCE = []
120 # Remove duplicate IDs while preserving order.
121 unique_id = []
122 [unique_id.append(x) for x in ids if x not in unique_id]
124 refclock = False
125 for id in unique_id:
126 if id not in refclock_map:
127 ctx.fatal("'%s' is not a valid Refclock ID" % id)
129 rc = refclock_map[id]
131 if rc['define'] == "CLOCK_GENERIC":
132 parse_clocks = (
133 "CLOCK_COMPUTIME",
134 "CLOCK_DCF7000",
135 "CLOCK_HOPF6021",
136 "CLOCK_MEINBERG",
137 "CLOCK_RAWDCF",
138 "CLOCK_RCC8000",
139 "CLOCK_SCHMID",
140 "CLOCK_SEL240X",
141 "CLOCK_TRIMTAIP",
142 "CLOCK_TRIMTSIP",
143 "CLOCK_VARITEXT",
144 "CLOCK_WHARTON_400A",
146 for subtype in parse_clocks:
147 ctx.define(subtype, 1, comment="Enable individual parse clock")
149 ctx.start_msg("Enabling Refclock %s (%s):" % (rc["descr"], id))
151 if "require" in rc:
152 if "ppsapi" in rc["require"]:
153 if not ctx.get_define("HAVE_PPSAPI"):
154 ctx.end_msg("No")
155 pprint("RED",
156 "Refclock \"%s\" disabled, PPS API has not "
157 "been detected as working." % rc["descr"])
158 continue
160 ctx.env.REFCLOCK_SOURCE.append((rc["file"], rc["define"]))
161 ctx.env["REFCLOCK_%s" % rc["file"].upper()] = True
162 ctx.define(rc["define"], 1,
163 comment="Enable '%s' refclock" % rc["descr"])
164 ctx.env.REFCLOCK_LIST += [str(id)]
166 ctx.end_msg("Yes")
168 refclock = True
170 if refclock:
171 ctx.env.REFCLOCK_ENABLE = True
172 ctx.define("REFCLOCK", 1, comment="Enable refclock support")