Lines 1-18
Link Here
|
1 |
from __future__ import print_function |
1 |
from __future__ import print_function |
2 |
|
2 |
|
3 |
from datetime import datetime |
3 |
# from datetime import datetime |
4 |
import itertools |
4 |
import itertools |
5 |
import os |
5 |
import os |
6 |
import shlex |
6 |
import shlex |
7 |
import sys |
7 |
import sys |
8 |
import time |
8 |
|
|
|
9 |
# import time |
9 |
|
10 |
|
10 |
from waflib import Build |
11 |
from waflib import Build |
11 |
from waflib import Context |
12 |
from waflib import Context |
12 |
from waflib import Scripting |
13 |
from waflib import Scripting |
13 |
from waflib import Utils |
14 |
from waflib import Utils |
14 |
from waflib.Build import (BuildContext, CleanContext, InstallContext, |
15 |
from waflib.Build import ( |
15 |
StepContext, ListContext) |
16 |
BuildContext, |
|
|
17 |
CleanContext, |
18 |
InstallContext, |
19 |
StepContext, |
20 |
ListContext, |
21 |
) |
16 |
from waflib.Context import BOTH |
22 |
from waflib.Context import BOTH |
17 |
from waflib.Errors import WafError |
23 |
from waflib.Errors import WafError |
18 |
from waflib.Logs import pprint |
24 |
from waflib.Logs import pprint |
Lines 28-46
from wafhelpers.test import test_write_log, test_print_log
Link Here
|
28 |
|
34 |
|
29 |
pprint.__doc__ = None |
35 |
pprint.__doc__ = None |
30 |
|
36 |
|
31 |
APPNAME = 'ntpsec' |
37 |
APPNAME = "ntpsec" |
32 |
|
38 |
|
33 |
out = "build" |
39 |
out = "build" |
34 |
|
40 |
|
35 |
config = { |
41 |
config = {"out": out, "OPT_STORE": {}} |
36 |
"out": out, |
|
|
37 |
"OPT_STORE": {} |
38 |
} |
39 |
|
42 |
|
40 |
|
43 |
|
41 |
def help(ctx): |
44 |
def help(ctx): |
42 |
"Be helpful, give a usage" |
45 |
"Be helpful, give a usage" |
43 |
print(''' |
46 |
print( |
|
|
47 |
""" |
44 |
Usage: waf <command> |
48 |
Usage: waf <command> |
45 |
build Build the project |
49 |
build Build the project |
46 |
check Run tests |
50 |
check Run tests |
Lines 50-85
Usage: waf <command>
Link Here
|
50 |
loccount Show SLOC count of the source tree |
54 |
loccount Show SLOC count of the source tree |
51 |
uninstall Uninstall the project |
55 |
uninstall Uninstall the project |
52 |
|
56 |
|
53 |
''') |
57 |
""" |
|
|
58 |
) |
54 |
|
59 |
|
55 |
|
60 |
|
56 |
def options(ctx): |
61 |
def options(ctx): |
57 |
options_cmd(ctx, config) |
62 |
options_cmd(ctx, config) |
58 |
ctx.load('asciidoc', tooldir='wafhelpers/') |
63 |
ctx.load("asciidoc", tooldir="wafhelpers/") |
59 |
ctx.recurse("pylib") |
64 |
ctx.recurse("pylib") |
60 |
|
65 |
|
61 |
|
66 |
|
62 |
def configure(ctx): |
67 |
def configure(ctx): |
63 |
ctx.load('asciidoc', tooldir='wafhelpers/') |
68 |
ctx.load("asciidoc", tooldir="wafhelpers/") |
64 |
|
69 |
|
65 |
class oc(Build.BuildContext): |
70 |
class oc(Build.BuildContext): |
66 |
cmd = 'oc' |
71 |
cmd = "oc" |
67 |
|
72 |
|
68 |
def exec_command(self, cmd, **kw): |
73 |
def exec_command(self, cmd, **kw): |
69 |
kw['output'] = BOTH |
74 |
kw["output"] = BOTH |
70 |
try: |
75 |
try: |
71 |
err, out = self.cmd_and_log(cmd, **kw) |
76 |
err, out = self.cmd_and_log(cmd, **kw) |
72 |
except WafError as e: |
77 |
except WafError as e: |
73 |
self.logger.debug('WafError') |
78 |
self.logger.debug("WafError") |
74 |
return e.returncode |
79 |
return e.returncode |
75 |
if (len(out) and any(word in out for word |
80 |
if len(out) and any( |
76 |
in ['err', 'err:', 'error', 'error:', |
81 |
word in out |
77 |
'ignored', 'illegal', 'unknown', |
82 |
for word in [ |
78 |
'unrecognized', 'warning'])): |
83 |
"err", |
79 |
self.logger.debug('noooo %r' % out) |
84 |
"err:", |
|
|
85 |
"error", |
86 |
"error:", |
87 |
"ignored", |
88 |
"illegal", |
89 |
"unknown", |
90 |
"unrecognized", |
91 |
"warning", |
92 |
] |
93 |
): |
94 |
self.logger.debug("noooo %r" % out) |
80 |
return 1 |
95 |
return 1 |
81 |
if err: |
96 |
if err: |
82 |
self.logger.debug('noooo %r' % err) |
97 |
self.logger.debug("noooo %r" % err) |
83 |
return 1 |
98 |
return 1 |
84 |
return 0 |
99 |
return 0 |
85 |
|
100 |
|
Lines 93-102
def configure(ctx):
Link Here
|
93 |
srcnode = ctx.srcnode.abspath() |
108 |
srcnode = ctx.srcnode.abspath() |
94 |
bldnode = ctx.bldnode.abspath() |
109 |
bldnode = ctx.bldnode.abspath() |
95 |
|
110 |
|
96 |
ctx.run_build_cls = 'check' |
111 |
ctx.run_build_cls = "check" |
97 |
ctx.load('waf', tooldir='wafhelpers/') |
112 |
ctx.load("waf", tooldir="wafhelpers/") |
98 |
ctx.load('waf_unit_test') |
113 |
ctx.load("waf_unit_test") |
99 |
ctx.load('gnu_dirs') |
114 |
ctx.load("gnu_dirs") |
100 |
|
115 |
|
101 |
with open("VERSION", "r") as f: |
116 |
with open("VERSION", "r") as f: |
102 |
ntpsec_release = f.read().split(" ")[0].strip() |
117 |
ntpsec_release = f.read().split(" ")[0].strip() |
Lines 120-160
def configure(ctx):
Link Here
|
120 |
opt = flag.replace("--", "").upper() |
135 |
opt = flag.replace("--", "").upper() |
121 |
opt_map[opt] = ctx.env.OPT_STORE[flag] |
136 |
opt_map[opt] = ctx.env.OPT_STORE[flag] |
122 |
|
137 |
|
123 |
ctx.env['ntpc'] = ctx.options.enable_pylib |
138 |
ctx.env["ntpc"] = ctx.options.enable_pylib |
124 |
ctx.env['ntpcver'] = '1.1.0' |
139 |
ctx.env["ntpcver"] = "1.1.0" |
125 |
|
140 |
|
126 |
msg("--- Configuring host ---") |
141 |
msg("--- Configuring host ---") |
127 |
ctx.setenv('host', ctx.env.derive()) |
142 |
ctx.setenv("host", ctx.env.derive()) |
128 |
|
143 |
|
129 |
ctx.load('compiler_c') |
144 |
ctx.load("compiler_c") |
130 |
ctx.start_msg('Checking compiler version') |
145 |
ctx.start_msg("Checking compiler version") |
131 |
ctx.end_msg("%s" % ".".join(ctx.env.CC_VERSION)) |
146 |
ctx.end_msg("%s" % ".".join(ctx.env.CC_VERSION)) |
132 |
|
147 |
|
133 |
# Some distros do not have /sbin in the PATH for non-root users. We honor |
148 |
# Some distros do not have /sbin in the PATH for non-root users. We honor |
134 |
# the real PATH first, but append the sbin directories. |
149 |
# the real PATH first, but append the sbin directories. |
135 |
ctx.find_program( |
150 |
ctx.find_program( |
136 |
"ldconfig", var="BIN_LDCONFIG", mandatory=False, |
151 |
"ldconfig", |
137 |
path_list=(os.environ.get('PATH','').split(os.pathsep) + |
152 |
var="BIN_LDCONFIG", |
138 |
["/sbin", "/usr/sbin", "/usr/local/sbin"])) |
153 |
mandatory=False, |
|
|
154 |
path_list=( |
155 |
os.environ.get("PATH", "").split(os.pathsep) |
156 |
+ ["/sbin", "/usr/sbin", "/usr/local/sbin"] |
157 |
), |
158 |
) |
139 |
|
159 |
|
140 |
# Ensure m4 is present, or bison will fail with SIGPIPE |
160 |
# Ensure m4 is present, or bison will fail with SIGPIPE |
141 |
ctx.find_program('m4') |
161 |
ctx.find_program("m4") |
142 |
ctx.load('bison') |
162 |
ctx.load("bison") |
143 |
|
163 |
|
144 |
for opt in opt_map: |
164 |
for opt in opt_map: |
145 |
ctx.env[opt] = opt_map[opt] |
165 |
ctx.env[opt] = opt_map[opt] |
146 |
|
166 |
|
147 |
if ctx.options.enable_rtems_trace: |
167 |
if ctx.options.enable_rtems_trace: |
148 |
ctx.find_program("rtems-tld", var="BIN_RTEMS_TLD", |
168 |
ctx.find_program( |
149 |
path_list=[ctx.options.rtems_trace_path, |
169 |
"rtems-tld", |
150 |
'${BINDIR}']) |
170 |
var="BIN_RTEMS_TLD", |
|
|
171 |
path_list=[ctx.options.rtems_trace_path, "${BINDIR}"], |
172 |
) |
151 |
ctx.env.RTEMS_TEST_ENABLE = True |
173 |
ctx.env.RTEMS_TEST_ENABLE = True |
152 |
ctx.env.RTEMS_TEST_FLAGS = [ |
174 |
ctx.env.RTEMS_TEST_FLAGS = [ |
153 |
"-C", "%s/devel/trace/ntpsec-trace.ini" % srcnode, |
175 |
"-C", |
154 |
"-W", "%s/ntpsec-wrapper" % bldnode, |
176 |
"%s/devel/trace/ntpsec-trace.ini" % srcnode, |
155 |
"-P", "%s/devel/trace/" % srcnode, |
177 |
"-W", |
156 |
"-f", "-I%s" % bldnode, |
178 |
"%s/ntpsec-wrapper" % bldnode, |
157 |
"-f", "-I%s/include/" % srcnode, |
179 |
"-P", |
|
|
180 |
"%s/devel/trace/" % srcnode, |
181 |
"-f", |
182 |
"-I%s" % bldnode, |
183 |
"-f", |
184 |
"-I%s/include/" % srcnode, |
158 |
] |
185 |
] |
159 |
|
186 |
|
160 |
# Not needed to build. Used by utility scripts. |
187 |
# Not needed to build. Used by utility scripts. |
Lines 162-170
def configure(ctx):
Link Here
|
162 |
ctx.find_program("sh", var="BIN_SH", mandatory=False) |
189 |
ctx.find_program("sh", var="BIN_SH", mandatory=False) |
163 |
|
190 |
|
164 |
ctx.check_cfg( |
191 |
ctx.check_cfg( |
165 |
package='systemd', variables=['systemdsystemunitdir'], |
192 |
package="systemd", |
166 |
uselib_store='SYSTEMD', mandatory=False, |
193 |
variables=["systemdsystemunitdir"], |
167 |
msg="Checking for systemd") |
194 |
uselib_store="SYSTEMD", |
|
|
195 |
mandatory=False, |
196 |
msg="Checking for systemd", |
197 |
) |
168 |
if ctx.env.SYSTEMD_systemdsystemunitdir: |
198 |
if ctx.env.SYSTEMD_systemdsystemunitdir: |
169 |
ctx.start_msg("systemd unit directory:") |
199 |
ctx.start_msg("systemd unit directory:") |
170 |
ctx.end_msg(ctx.env.SYSTEMD_systemdsystemunitdir) |
200 |
ctx.end_msg(ctx.env.SYSTEMD_systemdsystemunitdir) |
Lines 175-181
def configure(ctx):
Link Here
|
175 |
|
205 |
|
176 |
build_desc = ctx.options.build_desc.strip() |
206 |
build_desc = ctx.options.build_desc.strip() |
177 |
if build_desc: |
207 |
if build_desc: |
178 |
build_desc = ' ' + build_desc |
208 |
build_desc = " " + build_desc |
179 |
if ctx.env.BIN_GIT: |
209 |
if ctx.env.BIN_GIT: |
180 |
# 'tag', '7', and 'deadbeef' are fill ins for |
210 |
# 'tag', '7', and 'deadbeef' are fill ins for |
181 |
# a previous tag (always dropped), commits since that tag, |
211 |
# a previous tag (always dropped), commits since that tag, |
Lines 189-207
def configure(ctx):
Link Here
|
189 |
# 3-4 gets the first token dropped and the rest added |
219 |
# 3-4 gets the first token dropped and the rest added |
190 |
# I have never seen 5+ tokens, we should be safe |
220 |
# I have never seen 5+ tokens, we should be safe |
191 |
cmd = ctx.env.BIN_GIT + shlex.split("describe --tags --dirty --always") |
221 |
cmd = ctx.env.BIN_GIT + shlex.split("describe --tags --dirty --always") |
192 |
git_short_hash = ctx.cmd_and_log(cmd).strip().split('-') |
222 |
git_short_hash = ctx.cmd_and_log(cmd).strip().split("-") |
193 |
clip = 1 if len(git_short_hash) > 2 else 0 |
223 |
clip = 1 if len(git_short_hash) > 2 else 0 |
194 |
git_short_hash = '-'.join(git_short_hash[clip:]) |
224 |
git_short_hash = "-".join(git_short_hash[clip:]) |
195 |
|
225 |
|
196 |
ctx.env.NTPSEC_VERSION = "%s+" % ntpsec_release |
226 |
ctx.env.NTPSEC_VERSION = "%s+" % ntpsec_release |
197 |
ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+%s%s" % |
227 |
ctx.env.NTPSEC_VERSION_EXTENDED = "%s+%s%s" % ( |
198 |
(ntpsec_release, |
228 |
ntpsec_release, |
199 |
git_short_hash, |
229 |
git_short_hash, |
200 |
build_desc)) |
230 |
build_desc, |
|
|
231 |
) |
201 |
else: |
232 |
else: |
202 |
ctx.env.NTPSEC_VERSION = "%s" % ntpsec_release |
233 |
ctx.env.NTPSEC_VERSION = "%s" % ntpsec_release |
203 |
ctx.env.NTPSEC_VERSION_EXTENDED = ("%s%s" % (ntpsec_release, |
234 |
ctx.env.NTPSEC_VERSION_EXTENDED = "%s%s" % (ntpsec_release, build_desc) |
204 |
build_desc)) |
|
|
205 |
ctx.define("NTPSEC_VERSION", ctx.env.NTPSEC_VERSION) |
235 |
ctx.define("NTPSEC_VERSION", ctx.env.NTPSEC_VERSION) |
206 |
ctx.define("NTPSEC_VERSION_EXTENDED", ctx.env.NTPSEC_VERSION_EXTENDED) |
236 |
ctx.define("NTPSEC_VERSION_EXTENDED", ctx.env.NTPSEC_VERSION_EXTENDED) |
207 |
|
237 |
|
Lines 239-245
def configure(ctx):
Link Here
|
239 |
ctx.env.ENABLE_CROSS = True |
269 |
ctx.env.ENABLE_CROSS = True |
240 |
|
270 |
|
241 |
ctx.start_msg("Using Cross compiler CC:") |
271 |
ctx.start_msg("Using Cross compiler CC:") |
242 |
# ctx.get_cc_version(ctx.env.CC, gcc=True) |
272 |
# ctx.get_cc_version(ctx.env.CC, gcc=True) |
243 |
ctx.end_msg(ctx.options.cross_compiler) |
273 |
ctx.end_msg(ctx.options.cross_compiler) |
244 |
|
274 |
|
245 |
ctx.env.CC = shlex.split(ctx.options.cross_compiler) |
275 |
ctx.env.CC = shlex.split(ctx.options.cross_compiler) |
Lines 257-262
def configure(ctx):
Link Here
|
257 |
|
287 |
|
258 |
if ctx.options.list: |
288 |
if ctx.options.list: |
259 |
from wafhelpers.refclock import refclock_map |
289 |
from wafhelpers.refclock import refclock_map |
|
|
290 |
|
260 |
print("ID Description") |
291 |
print("ID Description") |
261 |
print("~~ ~~~~~~~~~~~") |
292 |
print("~~ ~~~~~~~~~~~") |
262 |
for id in refclock_map: |
293 |
for id in refclock_map: |
Lines 270-308
def configure(ctx):
Link Here
|
270 |
ctx.define("WORDS_BIGENDIAN", 1) |
301 |
ctx.define("WORDS_BIGENDIAN", 1) |
271 |
|
302 |
|
272 |
if ctx.options.enable_leap_testing: |
303 |
if ctx.options.enable_leap_testing: |
273 |
ctx.define("ENABLE_LEAP_TESTING", 1, |
304 |
ctx.define( |
274 |
comment="Enable leap seconds on other than 1st of month.") |
305 |
"ENABLE_LEAP_TESTING", |
|
|
306 |
1, |
307 |
comment="Enable leap seconds on other than 1st of month.", |
308 |
) |
275 |
|
309 |
|
276 |
# check for some libs first. some options, like stack protector, |
310 |
# check for some libs first. some options, like stack protector, |
277 |
# may depend on some libs, like -lssp |
311 |
# may depend on some libs, like -lssp |
278 |
ctx.check_cc(lib="m", comment="Math library") |
312 |
ctx.check_cc(lib="m", comment="Math library") |
279 |
ctx.check_cc(lib="rt", mandatory=False, comment="realtime library") |
313 |
ctx.check_cc(lib="rt", mandatory=False, comment="realtime library") |
280 |
ctx.check_cc(lib="pthread", mandatory=False, comment="threads library") |
314 |
ctx.check_cc(lib="pthread", mandatory=False, comment="threads library") |
281 |
ctx.check_cc(lib="execinfo", mandatory=False, |
315 |
ctx.check_cc(lib="execinfo", mandatory=False, comment="BSD backtrace library") |
282 |
comment="BSD backtrace library") |
316 |
ret = ctx.check_cc(lib="bsd", mandatory=False, comment="BSD compatibility library") |
283 |
ret = ctx.check_cc(lib="bsd", mandatory=False, |
|
|
284 |
comment="BSD compatibility library") |
285 |
if ret: |
317 |
if ret: |
286 |
ctx.env.LDFLAGS += ["-lbsd"] |
318 |
ctx.env.LDFLAGS += ["-lbsd"] |
287 |
|
319 |
|
288 |
# -lssp and -lssp_nonshared may be needed by older gcc to |
320 |
# -lssp and -lssp_nonshared may be needed by older gcc to |
289 |
# support "-fstack-protector-all" |
321 |
# support "-fstack-protector-all" |
290 |
ret = ctx.check_cc(lib="ssp", mandatory=False, |
322 |
ret = ctx.check_cc(lib="ssp", mandatory=False, comment="libssp") |
291 |
comment="libssp") |
|
|
292 |
if ret: |
323 |
if ret: |
293 |
ctx.env.LDFLAGS += ["-lssp"] |
324 |
ctx.env.LDFLAGS += ["-lssp"] |
294 |
|
325 |
|
295 |
ret = ctx.check_cc(lib="ssp_nonshared", mandatory=False, |
326 |
ret = ctx.check_cc(lib="ssp_nonshared", mandatory=False, comment="libssp_nonshared") |
296 |
comment="libssp_nonshared") |
|
|
297 |
if ret: |
327 |
if ret: |
298 |
ctx.env.LDFLAGS += ["-lssp_nonshared"] |
328 |
ctx.env.LDFLAGS += ["-lssp_nonshared"] |
299 |
|
329 |
|
300 |
cc_test_flags = [ |
330 |
cc_test_flags = [ |
301 |
('f_stack_protector_all', '-fstack-protector-all'), |
331 |
("f_stack_protector_all", "-fstack-protector-all"), |
302 |
('PIC', '-fPIC'), |
332 |
("PIC", "-fPIC"), |
303 |
('PIE', '-pie -fPIE'), |
333 |
("PIE", "-pie -fPIE"), |
304 |
# this quiets most of macOS warnings on -fpie |
334 |
# this quiets most of macOS warnings on -fpie |
305 |
('unused', '-Qunused-arguments'), |
335 |
("unused", "-Qunused-arguments"), |
306 |
# This is a useless warning on any architecture with a barrel |
336 |
# This is a useless warning on any architecture with a barrel |
307 |
# shifter, which includes Intel and ARM and basically |
337 |
# shifter, which includes Intel and ARM and basically |
308 |
# everything nowadays. Even so, we'd enable it out of |
338 |
# everything nowadays. Even so, we'd enable it out of |
Lines 310-338
def configure(ctx):
Link Here
|
310 |
# useful for forcing structure alignment in order to suppress |
340 |
# useful for forcing structure alignment in order to suppress |
311 |
# it locally don't seem to be working quite right. |
341 |
# it locally don't seem to be working quite right. |
312 |
# ('w_cast_align', "-Wcast-align"), |
342 |
# ('w_cast_align', "-Wcast-align"), |
313 |
('w_cast_qual', "-Wcast-qual"), |
343 |
("w_cast_qual", "-Wcast-qual"), |
314 |
('w_disabled_optimization', "-Wdisabled-optimization"), |
344 |
("w_disabled_optimization", "-Wdisabled-optimization"), |
315 |
('w_float_equal', "-Wfloat-equal"), |
345 |
("w_float_equal", "-Wfloat-equal"), |
316 |
('w_format', '-Wformat'), |
346 |
("w_format", "-Wformat"), |
317 |
('w_format_security', '-Wformat-security'), |
347 |
("w_format_security", "-Wformat-security"), |
318 |
# fails on OpenBSD 6 |
348 |
# fails on OpenBSD 6 |
319 |
('w_format_signedness', '-Wformat-signedness'), |
349 |
("w_format_signedness", "-Wformat-signedness"), |
320 |
('w_implicit_function_declaration', "-Wimplicit-function-declaration"), |
350 |
("w_implicit_function_declaration", "-Wimplicit-function-declaration"), |
321 |
('w_init_self', '-Winit-self'), |
351 |
("w_init_self", "-Winit-self"), |
322 |
('w_invalid_pch', '-Winvalid-pch'), |
352 |
("w_invalid_pch", "-Winvalid-pch"), |
323 |
('w_missing_declarations', '-Wmissing-declarations'), |
353 |
("w_missing_declarations", "-Wmissing-declarations"), |
324 |
('w_multichar', '-Wmultichar'), |
354 |
("w_multichar", "-Wmultichar"), |
325 |
('w_packed', '-Wpacked'), |
355 |
("w_packed", "-Wpacked"), |
326 |
('w_pointer_arith', '-Wpointer-arith'), |
356 |
("w_pointer_arith", "-Wpointer-arith"), |
327 |
('w_shadow', '-Wshadow'), |
357 |
("w_shadow", "-Wshadow"), |
328 |
# fails on clang |
358 |
# fails on clang |
329 |
('w_suggest_attribute_noreturn', "-Wsuggest-attribute=noreturn"), |
359 |
("w_suggest_attribute_noreturn", "-Wsuggest-attribute=noreturn"), |
330 |
('w_write_strings', '-Wwrite-strings'), |
360 |
("w_write_strings", "-Wwrite-strings"), |
331 |
] |
361 |
] |
332 |
|
362 |
|
333 |
# Check which linker flags are supported |
363 |
# Check which linker flags are supported |
334 |
ld_hardening_flags = [ |
364 |
ld_hardening_flags = [ |
335 |
("z_now", "-Wl,-z,now"), # no deferred symbol resolution |
365 |
("z_now", "-Wl,-z,now"), # no deferred symbol resolution |
336 |
] |
366 |
] |
337 |
|
367 |
|
338 |
# we prepend our options to CFLAGS, this allows user provided |
368 |
# we prepend our options to CFLAGS, this allows user provided |
Lines 343-353
def configure(ctx):
Link Here
|
343 |
else: |
373 |
else: |
344 |
# not gdb debugging |
374 |
# not gdb debugging |
345 |
cc_test_flags += [ |
375 |
cc_test_flags += [ |
346 |
('LTO', '-flto'), # link time optimization |
376 |
("LTO", "-flto"), # link time optimization |
347 |
] |
377 |
] |
348 |
ld_hardening_flags += [ |
378 |
ld_hardening_flags += [ |
349 |
('stripall', "-Wl,--strip-all"), # Strip binaries |
379 |
("stripall", "-Wl,--strip-all"), # Strip binaries |
350 |
] |
380 |
] |
351 |
|
381 |
|
352 |
if ctx.options.enable_debug: |
382 |
if ctx.options.enable_debug: |
353 |
ctx.define("DEBUG", 1, comment="Enable debug mode") |
383 |
ctx.define("DEBUG", 1, comment="Enable debug mode") |
Lines 361-375
def configure(ctx):
Link Here
|
361 |
# "-Wcast-align", # fails on RasPi, needs fixing. |
391 |
# "-Wcast-align", # fails on RasPi, needs fixing. |
362 |
# "-Wbad-function-cast", # ntpd casts long<->double a lot |
392 |
# "-Wbad-function-cast", # ntpd casts long<->double a lot |
363 |
# "-Wformat-nonliteral", # complains about a used feature |
393 |
# "-Wformat-nonliteral", # complains about a used feature |
364 |
"-Winline", # some OS have inline issues. |
394 |
"-Winline", # some OS have inline issues. |
365 |
# "-Wmissing-format-attribute", # false positives |
395 |
# "-Wmissing-format-attribute", # false positives |
366 |
# "-Wnested-externs", # incompatible w/ Unity... |
396 |
# "-Wnested-externs", # incompatible w/ Unity... |
367 |
# "-Wpadded", # duck... over 3k warnings |
397 |
# "-Wpadded", # duck... over 3k warnings |
368 |
# "-Wredundant-decls", # incompatible w/ Unity |
398 |
# "-Wredundant-decls", # incompatible w/ Unity |
369 |
"-Wswitch-default", # warns on Bison bug |
399 |
"-Wswitch-default", # warns on Bison bug |
370 |
] + ctx.env.CFLAGS |
400 |
] + ctx.env.CFLAGS |
371 |
cc_test_flags += [ |
401 |
cc_test_flags += [ |
372 |
('w_implicit_fallthru', "-Wimplicit-fallthrough=3"), |
402 |
("w_implicit_fallthru", "-Wimplicit-fallthrough=3"), |
373 |
# Fails on Solaris, OpenBSD 6, and RasPi |
403 |
# Fails on Solaris, OpenBSD 6, and RasPi |
374 |
# Complains about a Bison bug |
404 |
# Complains about a Bison bug |
375 |
# Cannot be suppressed |
405 |
# Cannot be suppressed |
Lines 378-384
def configure(ctx):
Link Here
|
378 |
# ('w_suggest_attribute_const', "-Wsuggest-attribute=const"), |
408 |
# ('w_suggest_attribute_const', "-Wsuggest-attribute=const"), |
379 |
# fails on clang, lot's of false positives and Unity complaints |
409 |
# fails on clang, lot's of false positives and Unity complaints |
380 |
# ('w_suggest_attribute_pure', "-Wsuggest-attribute=pure"), |
410 |
# ('w_suggest_attribute_pure', "-Wsuggest-attribute=pure"), |
381 |
] |
411 |
] |
382 |
|
412 |
|
383 |
ctx.env.CFLAGS = [ |
413 |
ctx.env.CFLAGS = [ |
384 |
# -O1 will turn on -D_FORTIFY_SOURCE=2 for us |
414 |
# -O1 will turn on -D_FORTIFY_SOURCE=2 for us |
Lines 389-416
def configure(ctx):
Link Here
|
389 |
"-Wstrict-prototypes", |
419 |
"-Wstrict-prototypes", |
390 |
"-Wundef", |
420 |
"-Wundef", |
391 |
"-Wunused", |
421 |
"-Wunused", |
392 |
] + ctx.env.CFLAGS |
422 |
] + ctx.env.CFLAGS |
393 |
|
423 |
|
394 |
# gotta be tricky to test for -Wsuggest-attribute=const |
424 |
# gotta be tricky to test for -Wsuggest-attribute=const |
395 |
FRAGMENT = ''' |
425 |
FRAGMENT = """ |
396 |
int tmp; |
426 |
int tmp; |
397 |
int main(int argc, char **argv) { |
427 |
int main(int argc, char **argv) { |
398 |
(void)argc; (void)argv; |
428 |
(void)argc; (void)argv; |
399 |
tmp = argc; |
429 |
tmp = argc; |
400 |
return argc; |
430 |
return argc; |
401 |
} |
431 |
} |
402 |
''' |
432 |
""" |
403 |
|
433 |
|
404 |
# check if C compiler supports some flags |
434 |
# check if C compiler supports some flags |
405 |
old_run_build_cls = ctx.run_build_cls |
435 |
old_run_build_cls = ctx.run_build_cls |
406 |
ctx.run_build_cls = 'oc' |
436 |
ctx.run_build_cls = "oc" |
407 |
for (name, ccflag) in cc_test_flags: |
437 |
for (name, ccflag) in cc_test_flags: |
408 |
ctx.check(cflags=ccflag, |
438 |
ctx.check( |
409 |
define_name='HAS_' + name, |
439 |
cflags=ccflag, |
410 |
fragment=FRAGMENT, |
440 |
define_name="HAS_" + name, |
411 |
mandatory=False, |
441 |
fragment=FRAGMENT, |
412 |
msg='Checking if C compiler supports ' + ccflag, |
442 |
mandatory=False, |
413 |
run_build_cls='oc') |
443 |
msg="Checking if C compiler supports " + ccflag, |
|
|
444 |
run_build_cls="oc", |
445 |
) |
414 |
|
446 |
|
415 |
ctx.run_build_cls = old_run_build_cls |
447 |
ctx.run_build_cls = old_run_build_cls |
416 |
|
448 |
|
Lines 420-433
int main(int argc, char **argv) {
Link Here
|
420 |
if ctx.env.HAS_PIE: |
452 |
if ctx.env.HAS_PIE: |
421 |
ctx.env.LINKFLAGS_NTPD += [ |
453 |
ctx.env.LINKFLAGS_NTPD += [ |
422 |
"-pie", |
454 |
"-pie", |
423 |
] |
455 |
] |
424 |
ctx.env.CFLAGS_bin = ["-fPIE", "-pie"] + ctx.env.CFLAGS |
456 |
ctx.env.CFLAGS_bin = ["-fPIE", "-pie"] + ctx.env.CFLAGS |
425 |
ld_hardening_flags += [ |
457 |
ld_hardening_flags += [ |
426 |
('relro', "-Wl,-z,relro"), # hardening, marks some read only, |
458 |
("relro", "-Wl,-z,relro"), # hardening, marks some read only, |
427 |
] |
459 |
] |
428 |
|
460 |
|
429 |
if ctx.env.HAS_unused: |
461 |
if ctx.env.HAS_unused: |
430 |
ctx.env.CFLAGS = ['-Qunused-arguments'] + ctx.env.CFLAGS |
462 |
ctx.env.CFLAGS = ["-Qunused-arguments"] + ctx.env.CFLAGS |
431 |
|
463 |
|
432 |
# XXX: -flto currently breaks link of ntpd |
464 |
# XXX: -flto currently breaks link of ntpd |
433 |
if ctx.env.HAS_LTO and False: |
465 |
if ctx.env.HAS_LTO and False: |
Lines 435-495
int main(int argc, char **argv) {
Link Here
|
435 |
|
467 |
|
436 |
# debug warnings that are not available with all compilers |
468 |
# debug warnings that are not available with all compilers |
437 |
if ctx.env.HAS_w_implicit_fallthru: |
469 |
if ctx.env.HAS_w_implicit_fallthru: |
438 |
ctx.env.CFLAGS = ['-Wimplicit-fallthrough=3'] + ctx.env.CFLAGS |
470 |
ctx.env.CFLAGS = ["-Wimplicit-fallthrough=3"] + ctx.env.CFLAGS |
439 |
if ctx.env.HAS_w_suggest_attribute_const: |
471 |
if ctx.env.HAS_w_suggest_attribute_const: |
440 |
ctx.env.CFLAGS = ['-Wsuggest-attribute=const'] + ctx.env.CFLAGS |
472 |
ctx.env.CFLAGS = ["-Wsuggest-attribute=const"] + ctx.env.CFLAGS |
441 |
if ctx.env.HAS_w_suggest_attribute_noreturn: |
473 |
if ctx.env.HAS_w_suggest_attribute_noreturn: |
442 |
ctx.env.CFLAGS = ['-Wsuggest-attribute=noreturn'] + ctx.env.CFLAGS |
474 |
ctx.env.CFLAGS = ["-Wsuggest-attribute=noreturn"] + ctx.env.CFLAGS |
443 |
if ctx.env.HAS_w_suggest_attribute_pure: |
475 |
if ctx.env.HAS_w_suggest_attribute_pure: |
444 |
ctx.env.CFLAGS = ['-Wsuggest-attribute=pure'] + ctx.env.CFLAGS |
476 |
ctx.env.CFLAGS = ["-Wsuggest-attribute=pure"] + ctx.env.CFLAGS |
445 |
if ctx.env.HAS_w_format_security: |
477 |
if ctx.env.HAS_w_format_security: |
446 |
ctx.env.CFLAGS = ['-Wformat-security'] + ctx.env.CFLAGS |
478 |
ctx.env.CFLAGS = ["-Wformat-security"] + ctx.env.CFLAGS |
447 |
if ctx.env.HAS_w_format_signedness: |
479 |
if ctx.env.HAS_w_format_signedness: |
448 |
ctx.env.CFLAGS = ['-Wformat-signedness'] + ctx.env.CFLAGS |
480 |
ctx.env.CFLAGS = ["-Wformat-signedness"] + ctx.env.CFLAGS |
449 |
# should be before other -Wformat-* in CFLAGS |
481 |
# should be before other -Wformat-* in CFLAGS |
450 |
if ctx.env.HAS_w_format: |
482 |
if ctx.env.HAS_w_format: |
451 |
ctx.env.CFLAGS = ['-Wformat'] + ctx.env.CFLAGS |
483 |
ctx.env.CFLAGS = ["-Wformat"] + ctx.env.CFLAGS |
452 |
if ctx.env.HAS_w_float_equal: |
484 |
if ctx.env.HAS_w_float_equal: |
453 |
ctx.env.CFLAGS = ['-Wfloat-equal'] + ctx.env.CFLAGS |
485 |
ctx.env.CFLAGS = ["-Wfloat-equal"] + ctx.env.CFLAGS |
454 |
if ctx.env.HAS_w_init_self: |
486 |
if ctx.env.HAS_w_init_self: |
455 |
ctx.env.CFLAGS = ['-Winit-self'] + ctx.env.CFLAGS |
487 |
ctx.env.CFLAGS = ["-Winit-self"] + ctx.env.CFLAGS |
456 |
if ctx.env.HAS_w_write_strings: |
488 |
if ctx.env.HAS_w_write_strings: |
457 |
ctx.env.CFLAGS = ['-Wwrite-strings'] + ctx.env.CFLAGS |
489 |
ctx.env.CFLAGS = ["-Wwrite-strings"] + ctx.env.CFLAGS |
458 |
if ctx.env.HAS_w_pointer_arith: |
490 |
if ctx.env.HAS_w_pointer_arith: |
459 |
ctx.env.CFLAGS = ['-Wpointer-arith'] + ctx.env.CFLAGS |
491 |
ctx.env.CFLAGS = ["-Wpointer-arith"] + ctx.env.CFLAGS |
460 |
if ctx.env.HAS_w_invalid_pch: |
492 |
if ctx.env.HAS_w_invalid_pch: |
461 |
ctx.env.CFLAGS = ['-Winvalid-pch'] + ctx.env.CFLAGS |
493 |
ctx.env.CFLAGS = ["-Winvalid-pch"] + ctx.env.CFLAGS |
462 |
if ctx.env.HAS_w_implicit_function_declaration: |
494 |
if ctx.env.HAS_w_implicit_function_declaration: |
463 |
ctx.env.CFLAGS = ['-Wimplicit-function-declaration'] + ctx.env.CFLAGS |
495 |
ctx.env.CFLAGS = ["-Wimplicit-function-declaration"] + ctx.env.CFLAGS |
464 |
if ctx.env.HAS_w_disabled_optimization: |
496 |
if ctx.env.HAS_w_disabled_optimization: |
465 |
ctx.env.CFLAGS = ['-Wdisabled-optimization'] + ctx.env.CFLAGS |
497 |
ctx.env.CFLAGS = ["-Wdisabled-optimization"] + ctx.env.CFLAGS |
466 |
# if ctx.env.HAS_w_cast_align: |
498 |
# if ctx.env.HAS_w_cast_align: |
467 |
# ctx.env.CFLAGS = ['-Wcast-align'] + ctx.env.CFLAGS |
499 |
# ctx.env.CFLAGS = ['-Wcast-align'] + ctx.env.CFLAGS |
468 |
if ctx.env.HAS_w_missing_declarations: |
500 |
if ctx.env.HAS_w_missing_declarations: |
469 |
ctx.env.CFLAGS = ['-Wmissing-declarations'] + ctx.env.CFLAGS |
501 |
ctx.env.CFLAGS = ["-Wmissing-declarations"] + ctx.env.CFLAGS |
470 |
if ctx.env.HAS_w_cast_qual: |
502 |
if ctx.env.HAS_w_cast_qual: |
471 |
ctx.env.CFLAGS = ['-Wcast-qual'] + ctx.env.CFLAGS |
503 |
ctx.env.CFLAGS = ["-Wcast-qual"] + ctx.env.CFLAGS |
472 |
if ctx.env.HAS_w_packed: |
504 |
if ctx.env.HAS_w_packed: |
473 |
ctx.env.CFLAGS = ['-Wpacked'] + ctx.env.CFLAGS |
505 |
ctx.env.CFLAGS = ["-Wpacked"] + ctx.env.CFLAGS |
474 |
if ctx.env.HAS_w_shadow: |
506 |
if ctx.env.HAS_w_shadow: |
475 |
ctx.env.CFLAGS = ['-Wshadow'] + ctx.env.CFLAGS |
507 |
ctx.env.CFLAGS = ["-Wshadow"] + ctx.env.CFLAGS |
476 |
# if ctx.env.HAS_w_sign_conversion: |
508 |
# if ctx.env.HAS_w_sign_conversion: |
477 |
# ctx.env.CFLAGS = ['-Wsign-conversion'] + ctx.env.CFLAGS |
509 |
# ctx.env.CFLAGS = ['-Wsign-conversion'] + ctx.env.CFLAGS |
478 |
if ctx.env.HAS_f_stack_protector_all: |
510 |
if ctx.env.HAS_f_stack_protector_all: |
479 |
ctx.env.CFLAGS = ['-fstack-protector-all'] + ctx.env.CFLAGS |
511 |
ctx.env.CFLAGS = ["-fstack-protector-all"] + ctx.env.CFLAGS |
480 |
|
512 |
|
481 |
# old gcc takes -z,relro, but then barfs if -fPIE available and used. |
513 |
# old gcc takes -z,relro, but then barfs if -fPIE available and used. |
482 |
# ("relro", "-Wl,-z,relro"), # marks some sections read only |
514 |
# ("relro", "-Wl,-z,relro"), # marks some sections read only |
483 |
old_run_build_cls = ctx.run_build_cls |
515 |
old_run_build_cls = ctx.run_build_cls |
484 |
ctx.run_build_cls = 'oc' |
516 |
ctx.run_build_cls = "oc" |
485 |
for (name, ldflag) in ld_hardening_flags: |
517 |
for (name, ldflag) in ld_hardening_flags: |
486 |
ctx.check(define_name='HAS_' + name, |
518 |
ctx.check( |
487 |
fragment=FRAGMENT, |
519 |
define_name="HAS_" + name, |
488 |
ldflags=ldflag, |
520 |
fragment=FRAGMENT, |
489 |
mandatory=False, |
521 |
ldflags=ldflag, |
490 |
msg='Checking if linker supports ' + ldflag, |
522 |
mandatory=False, |
491 |
run_build_cls='oc') |
523 |
msg="Checking if linker supports " + ldflag, |
492 |
if ctx.env['HAS_' + name]: |
524 |
run_build_cls="oc", |
|
|
525 |
) |
526 |
if ctx.env["HAS_" + name]: |
493 |
ctx.env.LDFLAGS += [ldflag] |
527 |
ctx.env.LDFLAGS += [ldflag] |
494 |
|
528 |
|
495 |
ctx.run_build_cls = old_run_build_cls |
529 |
ctx.run_build_cls = old_run_build_cls |
Lines 509-538
int main(int argc, char **argv) {
Link Here
|
509 |
# ] + ctx.env.CFLAGS |
543 |
# ] + ctx.env.CFLAGS |
510 |
ctx.env.LDFLAGS += [ |
544 |
ctx.env.LDFLAGS += [ |
511 |
"-Wl,-z,relro", # hardening, marks some section read only, |
545 |
"-Wl,-z,relro", # hardening, marks some section read only, |
512 |
] |
546 |
] |
513 |
# else: # gcc, probably |
547 |
# else: # gcc, probably |
514 |
|
548 |
|
515 |
# Exclude Unity's support for printing floating point numbers |
549 |
# Exclude Unity's support for printing floating point numbers |
516 |
# since it triggers warnings |
550 |
# since it triggers warnings |
517 |
# with -Wfloat-equal |
551 |
# with -Wfloat-equal |
518 |
ctx.env.CFLAGS = ['-DUNITY_EXCLUDE_FLOAT_PRINT'] + ctx.env.CFLAGS |
552 |
ctx.env.CFLAGS = ["-DUNITY_EXCLUDE_FLOAT_PRINT"] + ctx.env.CFLAGS |
519 |
|
553 |
|
520 |
# XXX: hack |
554 |
# XXX: hack |
521 |
if ctx.env.DEST_OS in ["freebsd"]: |
555 |
if ctx.env.DEST_OS in ["freebsd"]: |
522 |
ctx.env.INCLUDES = ["/usr/local/include"] |
556 |
ctx.env.INCLUDES = ["/usr/local/include"] |
523 |
ctx.env.LIBPATH = ["/usr/local/lib"] |
557 |
ctx.env.LIBPATH = ["/usr/local/lib"] |
524 |
if os.path.isdir("/usr/local/ssl/"): |
558 |
if os.path.isdir("/usr/local/ssl/"): |
525 |
# This assumes OpenSSL is the only thing that was in /usr/local/ |
559 |
# This assumes OpenSSL is the only thing that was in /usr/local/ |
526 |
ctx.env.INCLUDES = ["/usr/local/ssl/include"] |
560 |
ctx.env.INCLUDES = ["/usr/local/ssl/include"] |
527 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib"] |
561 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib"] |
528 |
elif ctx.env.DEST_OS == "netbsd" and os.path.isdir("/usr/pkg/include"): |
562 |
elif ctx.env.DEST_OS == "netbsd" and os.path.isdir("/usr/pkg/include"): |
529 |
ctx.env.INCLUDES = ["/usr/pkg/include"] |
563 |
ctx.env.INCLUDES = ["/usr/pkg/include"] |
530 |
ctx.env.LIBPATH = ["/usr/pkg/lib"] |
564 |
ctx.env.LIBPATH = ["/usr/pkg/lib"] |
531 |
ctx.env.LDFLAGS += ["-rpath=/usr/pkg/lib"] |
565 |
ctx.env.LDFLAGS += ["-rpath=/usr/pkg/lib"] |
532 |
if os.path.isdir("/usr/local/ssl/"): |
566 |
if os.path.isdir("/usr/local/ssl/"): |
533 |
# This assumes OpenSSL is the only thing that was in /usr/pkg/ |
567 |
# This assumes OpenSSL is the only thing that was in /usr/pkg/ |
534 |
ctx.env.INCLUDES = ["/usr/local/ssl/include"] |
568 |
ctx.env.INCLUDES = ["/usr/local/ssl/include"] |
535 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib"] |
569 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib"] |
536 |
elif ctx.env.DEST_OS == "linux" and os.path.isdir("/usr/local/ssl/"): |
570 |
elif ctx.env.DEST_OS == "linux" and os.path.isdir("/usr/local/ssl/"): |
537 |
# This supports building OpenSSL from source |
571 |
# This supports building OpenSSL from source |
538 |
# That allows using OpenSSL 1.1.1 on older CentOS |
572 |
# That allows using OpenSSL 1.1.1 on older CentOS |
Lines 540-548
int main(int argc, char **argv) {
Link Here
|
540 |
# see HOWTO-OpenSSL |
574 |
# see HOWTO-OpenSSL |
541 |
ctx.env.INCLUDES = ["/usr/local/ssl/include"] |
575 |
ctx.env.INCLUDES = ["/usr/local/ssl/include"] |
542 |
if os.path.isdir("/usr/local/ssl/lib64/"): |
576 |
if os.path.isdir("/usr/local/ssl/lib64/"): |
543 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib64"] |
577 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib64"] |
544 |
else: |
578 |
else: |
545 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib"] |
579 |
ctx.env.LIBPATH = ["/usr/local/ssl/lib"] |
546 |
elif ctx.env.DEST_OS == "darwin": |
580 |
elif ctx.env.DEST_OS == "darwin": |
547 |
# macports location |
581 |
# macports location |
548 |
if os.path.isdir("/opt/local/include"): |
582 |
if os.path.isdir("/opt/local/include"): |
Lines 550-557
int main(int argc, char **argv) {
Link Here
|
550 |
if os.path.isdir("/opt/local/lib"): |
584 |
if os.path.isdir("/opt/local/lib"): |
551 |
ctx.env.LIBPATH = ["/opt/local/lib"] |
585 |
ctx.env.LIBPATH = ["/opt/local/lib"] |
552 |
# OS X needs this for IPv6 |
586 |
# OS X needs this for IPv6 |
553 |
ctx.define("__APPLE_USE_RFC_3542", 1, |
587 |
ctx.define("__APPLE_USE_RFC_3542", 1, comment="Needed for IPv6 support") |
554 |
comment="Needed for IPv6 support") |
|
|
555 |
elif ctx.env.DEST_OS == "sunos": |
588 |
elif ctx.env.DEST_OS == "sunos": |
556 |
# Declare compatibility with the POSIX.1-2001 standard, and any |
589 |
# Declare compatibility with the POSIX.1-2001 standard, and any |
557 |
# headers/interfaces not in conflict with that standard |
590 |
# headers/interfaces not in conflict with that standard |
Lines 559-574
int main(int argc, char **argv) {
Link Here
|
559 |
ctx.define("__EXTENSIONS__", "1", quote=False) |
592 |
ctx.define("__EXTENSIONS__", "1", quote=False) |
560 |
|
593 |
|
561 |
# Borrowed from waf-1.9, when type_name and field_name were valid keywords |
594 |
# Borrowed from waf-1.9, when type_name and field_name were valid keywords |
562 |
SNIP_TYPE = ''' |
595 |
SNIP_TYPE = """ |
563 |
int main(int argc, char **argv) { |
596 |
int main(int argc, char **argv) { |
564 |
(void)argc; (void)argv; |
597 |
(void)argc; (void)argv; |
565 |
if ((%(type_name)s *) 0) return 0; |
598 |
if ((%(type_name)s *) 0) return 0; |
566 |
if (sizeof (%(type_name)s)) return 0; |
599 |
if (sizeof (%(type_name)s)) return 0; |
567 |
return 1; |
600 |
return 1; |
568 |
} |
601 |
} |
569 |
''' |
602 |
""" |
570 |
|
603 |
|
571 |
SNIP_FIELD = ''' |
604 |
SNIP_FIELD = """ |
572 |
#include <stddef.h> |
605 |
#include <stddef.h> |
573 |
int main(int argc, char **argv) { |
606 |
int main(int argc, char **argv) { |
574 |
char *off; |
607 |
char *off; |
Lines 576-586
int main(int argc, char **argv) {
Link Here
|
576 |
off = (char*) &((%(type_name)s*)0)->%(field_name)s; |
609 |
off = (char*) &((%(type_name)s*)0)->%(field_name)s; |
577 |
return (size_t) off < sizeof(%(type_name)s); |
610 |
return (size_t) off < sizeof(%(type_name)s); |
578 |
} |
611 |
} |
579 |
''' |
612 |
""" |
580 |
|
613 |
|
581 |
def to_header(header_name): |
614 |
def to_header(header_name): |
582 |
return ''.join(['#include <%s>\n' % |
615 |
return "".join(["#include <%s>\n" % x for x in Utils.to_list(header_name)]) |
583 |
x for x in Utils.to_list(header_name)]) |
|
|
584 |
|
616 |
|
585 |
structures = ( |
617 |
structures = ( |
586 |
("struct if_laddrconf", ["sys/types.h", "net/if6.h"], False), |
618 |
("struct if_laddrconf", ["sys/types.h", "net/if6.h"], False), |
Lines 590-597
int main(int argc, char **argv) {
Link Here
|
590 |
) |
622 |
) |
591 |
for (s, h, r) in structures: |
623 |
for (s, h, r) in structures: |
592 |
ctx.check_cc( |
624 |
ctx.check_cc( |
593 |
fragment=to_header(h) + SNIP_TYPE % {'type_name': s}, |
625 |
fragment=to_header(h) + SNIP_TYPE % {"type_name": s}, |
594 |
msg='Checking for type %s' % s, |
626 |
msg="Checking for type %s" % s, |
595 |
define_name=ctx.have_define(s.upper()), |
627 |
define_name=ctx.have_define(s.upper()), |
596 |
mandatory=r, |
628 |
mandatory=r, |
597 |
) |
629 |
) |
Lines 605-621
int main(int argc, char **argv) {
Link Here
|
605 |
) |
637 |
) |
606 |
for (s, f, h) in structure_fields: |
638 |
for (s, f, h) in structure_fields: |
607 |
ctx.check_cc( |
639 |
ctx.check_cc( |
608 |
fragment=(to_header(h) + SNIP_FIELD % |
640 |
fragment=(to_header(h) + SNIP_FIELD % {"type_name": s, "field_name": f}), |
609 |
{'type_name': s, 'field_name': f}), |
641 |
msg="Checking for field %s in %s" % (f, s), |
610 |
msg='Checking for field %s in %s' % (f, s), |
642 |
define_name=ctx.have_define((s + "_" + f).upper()), |
611 |
define_name=ctx.have_define((s + '_' + f).upper()), |
|
|
612 |
mandatory=False, |
643 |
mandatory=False, |
613 |
) |
644 |
) |
614 |
|
645 |
|
615 |
# mostly used by timetoa.h and timespecops.h |
646 |
# mostly used by timetoa.h and timespecops.h |
616 |
sizeofs = [ |
647 |
sizeofs = [ |
617 |
("time.h", "time_t"), |
648 |
("time.h", "time_t"), |
618 |
(None, "long"), |
649 |
(None, "long"), |
619 |
] |
650 |
] |
620 |
|
651 |
|
621 |
for header, sizeof in sorted(sizeofs, key=lambda x: x[1:]): |
652 |
for header, sizeof in sorted(sizeofs, key=lambda x: x[1:]): |
Lines 624-661
int main(int argc, char **argv) {
Link Here
|
624 |
if not ctx.options.disable_nts: |
655 |
if not ctx.options.disable_nts: |
625 |
# Check via pkg-config first, then fall back to a direct search |
656 |
# Check via pkg-config first, then fall back to a direct search |
626 |
if not ctx.check_cfg( |
657 |
if not ctx.check_cfg( |
627 |
package='libssl', uselib_store='SSL', |
658 |
package="libssl", |
628 |
args=['--cflags', '--libs'], |
659 |
uselib_store="SSL", |
|
|
660 |
args=["--cflags", "--libs"], |
629 |
msg="Checking for OpenSSL/libssl (via pkg-config)", |
661 |
msg="Checking for OpenSSL/libssl (via pkg-config)", |
630 |
define_name='', mandatory=False, |
662 |
define_name="", |
|
|
663 |
mandatory=False, |
631 |
): |
664 |
): |
632 |
ctx.check_cc(msg="Checking for OpenSSL's ssl library", |
665 |
ctx.check_cc( |
633 |
lib="ssl", mandatory=True) |
666 |
msg="Checking for OpenSSL's ssl library", lib="ssl", mandatory=True |
|
|
667 |
) |
634 |
|
668 |
|
635 |
# Check via pkg-config first, then fall back to a direct search |
669 |
# Check via pkg-config first, then fall back to a direct search |
636 |
if not ctx.check_cfg( |
670 |
if not ctx.check_cfg( |
637 |
package='libcrypto', uselib_store='CRYPTO', |
671 |
package="libcrypto", |
638 |
args=['--cflags', '--libs'], |
672 |
uselib_store="CRYPTO", |
|
|
673 |
args=["--cflags", "--libs"], |
639 |
msg="Checking for OpenSSL/libcrypto (via pkg-config)", |
674 |
msg="Checking for OpenSSL/libcrypto (via pkg-config)", |
640 |
define_name='', mandatory=False, |
675 |
define_name="", |
|
|
676 |
mandatory=False, |
641 |
): |
677 |
): |
642 |
ctx.check_cc(msg="Checking for OpenSSL's crypto library", |
678 |
ctx.check_cc( |
643 |
lib="crypto", mandatory=True) |
679 |
msg="Checking for OpenSSL's crypto library", lib="crypto", mandatory=True |
|
|
680 |
) |
644 |
|
681 |
|
645 |
# Optional functions. Do all function checks here, otherwise |
682 |
# Optional functions. Do all function checks here, otherwise |
646 |
# we're likely to duplicate them. |
683 |
# we're likely to duplicate them. |
647 |
optional_functions = ( |
684 |
optional_functions = ( |
648 |
('_Unwind_Backtrace', ["unwind.h"]), |
685 |
("_Unwind_Backtrace", ["unwind.h"]), |
649 |
('adjtimex', ["sys/time.h", "sys/timex.h"]), |
686 |
("adjtimex", ["sys/time.h", "sys/timex.h"]), |
650 |
('backtrace_symbols_fd', ["execinfo.h"]), |
687 |
("backtrace_symbols_fd", ["execinfo.h"]), |
651 |
('ntp_adjtime', ["sys/time.h", "sys/timex.h"]), # BSD |
688 |
("ntp_adjtime", ["sys/time.h", "sys/timex.h"]), # BSD |
652 |
('ntp_gettime', ["sys/time.h", "sys/timex.h"]), # BSD |
689 |
("ntp_gettime", ["sys/time.h", "sys/timex.h"]), # BSD |
653 |
('res_init', ["netinet/in.h", "arpa/nameser.h", "resolv.h"]), |
690 |
("res_init", ["netinet/in.h", "arpa/nameser.h", "resolv.h"]), |
654 |
('strlcpy', ["string.h"]), |
691 |
("strlcpy", ["string.h"]), |
655 |
('strlcat', ["string.h"]), |
692 |
("strlcat", ["string.h"]), |
656 |
('timegm', ["time.h"]), |
693 |
("timegm", ["time.h"]), |
657 |
# Hack. It's not a function, but this works. |
694 |
# Hack. It's not a function, but this works. |
658 |
('PRIV_NTP_ADJTIME', ["sys/priv.h"]) # FreeBSD |
695 |
("PRIV_NTP_ADJTIME", ["sys/priv.h"]), # FreeBSD |
659 |
) |
696 |
) |
660 |
for ft in optional_functions: |
697 |
for ft in optional_functions: |
661 |
probe_function(ctx, function=ft[0], prerequisites=ft[1]) |
698 |
probe_function(ctx, function=ft[0], prerequisites=ft[1]) |
Lines 667-701
int main(int argc, char **argv) {
Link Here
|
667 |
# Sanity checks to give a sensible error message |
704 |
# Sanity checks to give a sensible error message |
668 |
required_functions = ( |
705 |
required_functions = ( |
669 |
# MacOS doesn't have timer_create ?? |
706 |
# MacOS doesn't have timer_create ?? |
670 |
('timer_create', ["signal.h", "time.h"], "RT", False), |
707 |
("timer_create", ["signal.h", "time.h"], "RT", False), |
671 |
# Very old versions of OpenSSL don't have cmac.h |
708 |
# Very old versions of OpenSSL don't have cmac.h |
672 |
# We could add ifdefs, but old crypto is deprecated in favor of CMAC |
709 |
# We could add ifdefs, but old crypto is deprecated in favor of CMAC |
673 |
# and so far, all the systems that we want to support are new enough. |
710 |
# and so far, all the systems that we want to support are new enough. |
674 |
('CMAC_CTX_new', ["openssl/cmac.h"], "CRYPTO", True), |
711 |
("CMAC_CTX_new", ["openssl/cmac.h"], "CRYPTO", True), |
675 |
# Next should be above, but it needs a library |
712 |
# Next should be above, but it needs a library |
676 |
# EVP_PKEY_new_CMAC_key added in OpenSSL 1.1.1 |
713 |
# EVP_PKEY_new_CMAC_key added in OpenSSL 1.1.1 |
677 |
('EVP_PKEY_new_CMAC_key', ["openssl/cmac.h"], "CRYPTO", False)) |
714 |
("EVP_PKEY_new_CMAC_key", ["openssl/cmac.h"], "CRYPTO", False), |
|
|
715 |
) |
678 |
for ft in required_functions: |
716 |
for ft in required_functions: |
679 |
probe_function(ctx, function=ft[0], |
717 |
probe_function( |
680 |
prerequisites=ft[1], use=ft[2], |
718 |
ctx, function=ft[0], prerequisites=ft[1], use=ft[2], mandatory=ft[3] |
681 |
mandatory=ft[3]) |
719 |
) |
682 |
|
720 |
|
683 |
# check for BSD versions outside of libc |
721 |
# check for BSD versions outside of libc |
684 |
if not ctx.get_define("HAVE_STRLCAT"): |
722 |
if not ctx.get_define("HAVE_STRLCAT"): |
685 |
ret = probe_function(ctx, function='strlcat', |
723 |
ret = probe_function(ctx, function="strlcat", prerequisites=["bsd/string.h"]) |
686 |
prerequisites=['bsd/string.h']) |
|
|
687 |
if ret: |
724 |
if ret: |
688 |
ctx.define("HAVE_STRLCAT", 1, comment="Using bsd/strlcat") |
725 |
ctx.define("HAVE_STRLCAT", 1, comment="Using bsd/strlcat") |
689 |
|
726 |
|
690 |
if not ctx.get_define("HAVE_STRLCPY"): |
727 |
if not ctx.get_define("HAVE_STRLCPY"): |
691 |
ret = probe_function(ctx, function='strlcpy', |
728 |
ret = probe_function(ctx, function="strlcpy", prerequisites=["bsd/string.h"]) |
692 |
prerequisites=['bsd/string.h']) |
|
|
693 |
if ret: |
729 |
if ret: |
694 |
ctx.define("HAVE_STRLCPY", 1, comment="Using bsd/strlcpy") |
730 |
ctx.define("HAVE_STRLCPY", 1, comment="Using bsd/strlcpy") |
695 |
|
731 |
|
696 |
# Nobody uses the symbol, but this seems like a good sanity check. |
732 |
# Nobody uses the symbol, but this seems like a good sanity check. |
697 |
ctx.check_cc(header_name="stdbool.h", mandatory=True, |
733 |
ctx.check_cc(header_name="stdbool.h", mandatory=True, comment="Sanity check.") |
698 |
comment="Sanity check.") |
|
|
699 |
|
734 |
|
700 |
# This is a list of every optional include header in the |
735 |
# This is a list of every optional include header in the |
701 |
# codebase that is guarded by a directly corresponding HAVE_*_H symbol. |
736 |
# codebase that is guarded by a directly corresponding HAVE_*_H symbol. |
Lines 711-728
int main(int argc, char **argv) {
Link Here
|
711 |
optional_headers = ( |
746 |
optional_headers = ( |
712 |
"alloca.h", |
747 |
"alloca.h", |
713 |
("arpa/nameser.h", ["sys/types.h"]), |
748 |
("arpa/nameser.h", ["sys/types.h"]), |
714 |
"bsd/string.h", # bsd emulation |
749 |
"bsd/string.h", # bsd emulation |
715 |
("ifaddrs.h", ["sys/types.h"]), |
750 |
("ifaddrs.h", ["sys/types.h"]), |
716 |
("linux/if_addr.h", ["sys/socket.h"]), |
751 |
("linux/if_addr.h", ["sys/socket.h"]), |
717 |
("linux/rtnetlink.h", ["sys/socket.h"]), |
752 |
("linux/rtnetlink.h", ["sys/socket.h"]), |
718 |
"linux/serial.h", |
753 |
"linux/serial.h", |
719 |
"net/if6.h", |
754 |
"net/if6.h", |
720 |
("net/route.h", ["sys/types.h", "sys/socket.h", "net/if.h"]), |
755 |
("net/route.h", ["sys/types.h", "sys/socket.h", "net/if.h"]), |
721 |
"priv.h", # Solaris |
756 |
"priv.h", # Solaris |
722 |
"stdatomic.h", |
757 |
"stdatomic.h", |
723 |
"sys/clockctl.h", # NetBSD |
758 |
"sys/clockctl.h", # NetBSD |
724 |
"sys/ioctl.h", |
759 |
"sys/ioctl.h", |
725 |
"sys/modem.h", # Apple |
760 |
"sys/modem.h", # Apple |
726 |
"sys/sockio.h", |
761 |
"sys/sockio.h", |
727 |
("sys/sysctl.h", ["sys/types.h"]), |
762 |
("sys/sysctl.h", ["sys/types.h"]), |
728 |
("timepps.h", ["inttypes.h"]), |
763 |
("timepps.h", ["inttypes.h"]), |
Lines 731-738
int main(int argc, char **argv) {
Link Here
|
731 |
) |
766 |
) |
732 |
for hdr in optional_headers: |
767 |
for hdr in optional_headers: |
733 |
if isinstance(hdr, str): |
768 |
if isinstance(hdr, str): |
734 |
if ctx.check_cc(header_name=hdr, mandatory=False, |
769 |
if ctx.check_cc( |
735 |
comment="<%s> header" % hdr): |
770 |
header_name=hdr, mandatory=False, comment="<%s> header" % hdr |
|
|
771 |
): |
736 |
continue |
772 |
continue |
737 |
else: |
773 |
else: |
738 |
(hdr, prereqs) = hdr |
774 |
(hdr, prereqs) = hdr |
Lines 742-765
int main(int argc, char **argv) {
Link Here
|
742 |
# Sanity check... |
778 |
# Sanity check... |
743 |
print("Compilation check failed but include exists %s" % hdr) |
779 |
print("Compilation check failed but include exists %s" % hdr) |
744 |
|
780 |
|
745 |
if ((ctx.get_define("HAVE_TIMEPPS_H") or |
781 |
if ctx.get_define("HAVE_TIMEPPS_H") or ctx.get_define("HAVE_SYS_TIMEPPS_H"): |
746 |
ctx.get_define("HAVE_SYS_TIMEPPS_H"))): |
|
|
747 |
ctx.define("HAVE_PPSAPI", 1, comment="Enable the PPS API") |
782 |
ctx.define("HAVE_PPSAPI", 1, comment="Enable the PPS API") |
748 |
|
783 |
|
749 |
# Check for Solaris capabilities |
784 |
# Check for Solaris capabilities |
750 |
if ctx.get_define("HAVE_PRIV_H") and ctx.env.DEST_OS == "sunos": |
785 |
if ctx.get_define("HAVE_PRIV_H") and ctx.env.DEST_OS == "sunos": |
751 |
ctx.define("HAVE_SOLARIS_PRIVS", 1, |
786 |
ctx.define( |
752 |
comment="Enable Solaris Privileges (Solaris only)") |
787 |
"HAVE_SOLARIS_PRIVS", 1, comment="Enable Solaris Privileges (Solaris only)" |
|
|
788 |
) |
753 |
|
789 |
|
754 |
from wafhelpers.check_sockaddr import check_sockaddr |
790 |
from wafhelpers.check_sockaddr import check_sockaddr |
|
|
791 |
|
755 |
check_sockaddr(ctx) |
792 |
check_sockaddr(ctx) |
756 |
|
793 |
|
757 |
from wafhelpers.check_strerror import check_strerror |
794 |
from wafhelpers.check_strerror import check_strerror |
|
|
795 |
|
758 |
check_strerror(ctx) |
796 |
check_strerror(ctx) |
759 |
|
797 |
|
760 |
# Check for Solaris's service configuration facility library |
798 |
# Check for Solaris's service configuration facility library |
761 |
ctx.check_cc(header_name="libscf.h", lib="scf", mandatory=False, |
799 |
ctx.check_cc(header_name="libscf.h", lib="scf", mandatory=False, uselib_store="SCF") |
762 |
uselib_store="SCF") |
|
|
763 |
|
800 |
|
764 |
# Some systems don't have sys/timex.h eg OS X, OpenBSD... |
801 |
# Some systems don't have sys/timex.h eg OS X, OpenBSD... |
765 |
if ctx.get_define("HAVE_SYS_TIMEX_H"): |
802 |
if ctx.get_define("HAVE_SYS_TIMEX_H"): |
Lines 767-772
int main(int argc, char **argv) {
Link Here
|
767 |
|
804 |
|
768 |
if ctx.options.refclocks: |
805 |
if ctx.options.refclocks: |
769 |
from wafhelpers.refclock import refclock_config |
806 |
from wafhelpers.refclock import refclock_config |
|
|
807 |
|
770 |
refclock_config(ctx) |
808 |
refclock_config(ctx) |
771 |
# timegm needed by refclock_nmea, it's not in POSIX |
809 |
# timegm needed by refclock_nmea, it's not in POSIX |
772 |
# It's in Linux, FreeBSD, and NetBSD |
810 |
# It's in Linux, FreeBSD, and NetBSD |
Lines 782-822
int main(int argc, char **argv) {
Link Here
|
782 |
# ctx.define("OS_MISSES_SPECIFIC_ROUTE_UPDATES", 1) |
820 |
# ctx.define("OS_MISSES_SPECIFIC_ROUTE_UPDATES", 1) |
783 |
|
821 |
|
784 |
if ctx.options.enable_leap_smear: |
822 |
if ctx.options.enable_leap_smear: |
785 |
ctx.define("ENABLE_LEAP_SMEAR", 1, |
823 |
ctx.define( |
786 |
comment="Enable experimental leap smearing code") |
824 |
"ENABLE_LEAP_SMEAR", 1, comment="Enable experimental leap smearing code" |
|
|
825 |
) |
787 |
|
826 |
|
788 |
if ctx.options.enable_mssntp: |
827 |
if ctx.options.enable_mssntp: |
789 |
ctx.define("ENABLE_MSSNTP", 1, |
828 |
ctx.define( |
790 |
comment="Enable MS-SNTP extensions " |
829 |
"ENABLE_MSSNTP", |
791 |
" https://msdn.microsoft.com/en-us/library/cc212930.aspx") |
830 |
1, |
|
|
831 |
comment="Enable MS-SNTP extensions " |
832 |
" https://msdn.microsoft.com/en-us/library/cc212930.aspx", |
833 |
) |
792 |
|
834 |
|
793 |
if ctx.options.enable_attic: |
835 |
if ctx.options.enable_attic: |
794 |
ctx.env.ENABLE_ATTIC = True |
836 |
ctx.env.ENABLE_ATTIC = True |
795 |
|
837 |
|
796 |
if ctx.options.disable_nts: |
838 |
if ctx.options.disable_nts: |
797 |
ctx.env.DISABLE_NTS = True |
839 |
ctx.env.DISABLE_NTS = True |
798 |
ctx.define("DISABLE_NTS", 1, |
840 |
ctx.define("DISABLE_NTS", 1, comment="Disable NTS") |
799 |
comment="Disable NTS") |
|
|
800 |
|
841 |
|
801 |
if not ctx.options.disable_droproot: |
842 |
if not ctx.options.disable_droproot: |
802 |
ctx.define("ENABLE_DROPROOT", 1, |
843 |
ctx.define("ENABLE_DROPROOT", 1, comment="Drop root after initialising") |
803 |
comment="Drop root after initialising") |
|
|
804 |
if ctx.options.enable_early_droproot: |
844 |
if ctx.options.enable_early_droproot: |
805 |
ctx.define("ENABLE_EARLY_DROPROOT", 1, |
845 |
ctx.define("ENABLE_EARLY_DROPROOT", 1, comment="Enable early drop root") |
806 |
comment="Enable early drop root") |
|
|
807 |
if not ctx.options.disable_fuzz: |
846 |
if not ctx.options.disable_fuzz: |
808 |
ctx.define("ENABLE_FUZZ", 1, |
847 |
ctx.define("ENABLE_FUZZ", 1, comment="Enable fuzzing low bits of time") |
809 |
comment="Enable fuzzing low bits of time") |
|
|
810 |
|
848 |
|
811 |
# SO_REUSEADDR socket option is needed to open a socket on an |
849 |
# SO_REUSEADDR socket option is needed to open a socket on an |
812 |
# interface when the port number is already in use on another |
850 |
# interface when the port number is already in use on another |
813 |
# interface. Linux needs this, NetBSD does not, status on |
851 |
# interface. Linux needs this, NetBSD does not, status on |
814 |
# other platforms is unknown. It is probably harmless to |
852 |
# other platforms is unknown. It is probably harmless to |
815 |
# have it on everywhere. |
853 |
# have it on everywhere. |
816 |
ctx.define("NEED_REUSEADDR_FOR_IFADDRBIND", 1, |
854 |
ctx.define( |
817 |
comment="Whether SO_REUSEADDR is needed to open " |
855 |
"NEED_REUSEADDR_FOR_IFADDRBIND", |
818 |
"same sockets on alternate interfaces, required " |
856 |
1, |
819 |
"by Linux at least") |
857 |
comment="Whether SO_REUSEADDR is needed to open " |
|
|
858 |
"same sockets on alternate interfaces, required " |
859 |
"by Linux at least", |
860 |
) |
820 |
|
861 |
|
821 |
# Check for directory separator |
862 |
# Check for directory separator |
822 |
if ctx.env.DEST_OS == "win32": |
863 |
if ctx.env.DEST_OS == "win32": |
Lines 824-835
int main(int argc, char **argv) {
Link Here
|
824 |
else: |
865 |
else: |
825 |
sep = "/" |
866 |
sep = "/" |
826 |
|
867 |
|
827 |
ctx.define("DIR_SEP", "'%s'" % sep, quote=False, |
868 |
ctx.define("DIR_SEP", "'%s'" % sep, quote=False, comment="Directory separator used") |
828 |
comment="Directory separator used") |
|
|
829 |
|
869 |
|
830 |
if ctx.get_define("HAVE_SYS_SYSCTL_H"): |
870 |
if ctx.get_define("HAVE_SYS_SYSCTL_H"): |
831 |
ctx.define("HAVE_IFLIST_SYSCTL", 1, |
871 |
ctx.define("HAVE_IFLIST_SYSCTL", 1, comment="Whether sysctl interface exists") |
832 |
comment="Whether sysctl interface exists") |
|
|
833 |
|
872 |
|
834 |
# Header/library checks |
873 |
# Header/library checks |
835 |
|
874 |
|
Lines 838-845
int main(int argc, char **argv) {
Link Here
|
838 |
ctx.check_cc(header_name="sys/capability.h", mandatory=False) |
877 |
ctx.check_cc(header_name="sys/capability.h", mandatory=False) |
839 |
ctx.check_cc(lib="cap", comment="Capability library", mandatory=False) |
878 |
ctx.check_cc(lib="cap", comment="Capability library", mandatory=False) |
840 |
|
879 |
|
841 |
if ((ctx.get_define("HAVE_SYS_CAPABILITY_H") and |
880 |
if ( |
842 |
ctx.get_define("HAVE_SYS_PRCTL_H") and ctx.env.LIB_CAP)): |
881 |
ctx.get_define("HAVE_SYS_CAPABILITY_H") |
|
|
882 |
and ctx.get_define("HAVE_SYS_PRCTL_H") |
883 |
and ctx.env.LIB_CAP |
884 |
): |
843 |
ctx.define("HAVE_LINUX_CAPABILITY", 1) |
885 |
ctx.define("HAVE_LINUX_CAPABILITY", 1) |
844 |
|
886 |
|
845 |
if ctx.options.enable_seccomp: |
887 |
if ctx.options.enable_seccomp: |
Lines 848-863
int main(int argc, char **argv) {
Link Here
|
848 |
|
890 |
|
849 |
# Check via pkg-config first, then fall back to a direct search |
891 |
# Check via pkg-config first, then fall back to a direct search |
850 |
if not ctx.check_cfg( |
892 |
if not ctx.check_cfg( |
851 |
package='libseccomp', args=['--libs', '--cflags'], |
893 |
package="libseccomp", |
852 |
uselib_store='SECCOMP', define_name='HAVE_SECCOMP_H', |
894 |
args=["--libs", "--cflags"], |
853 |
mandatory=False |
895 |
uselib_store="SECCOMP", |
|
|
896 |
define_name="HAVE_SECCOMP_H", |
897 |
mandatory=False, |
854 |
): |
898 |
): |
855 |
ctx.check_cc(header_name="seccomp.h") |
899 |
ctx.check_cc(header_name="seccomp.h") |
856 |
ctx.check_cc(lib="seccomp") |
900 |
ctx.check_cc(lib="seccomp") |
857 |
|
901 |
|
858 |
if not ctx.options.disable_mdns_registration: |
902 |
if not ctx.options.disable_mdns_registration: |
859 |
ctx.check_cc(header_name="dns_sd.h", lib="dns_sd", mandatory=False, |
903 |
ctx.check_cc( |
860 |
uselib_store="DNS_SD") |
904 |
header_name="dns_sd.h", lib="dns_sd", mandatory=False, uselib_store="DNS_SD" |
|
|
905 |
) |
861 |
|
906 |
|
862 |
# Solaris needs -lsocket and -lnsl for socket code |
907 |
# Solaris needs -lsocket and -lnsl for socket code |
863 |
if ctx.env.DEST_OS == "sunos": |
908 |
if ctx.env.DEST_OS == "sunos": |
Lines 880-885
int main(int argc, char **argv) {
Link Here
|
880 |
if not ctx.env.DISABLE_NTS: |
925 |
if not ctx.env.DISABLE_NTS: |
881 |
from wafhelpers.openssl import check_libssl_tls13 |
926 |
from wafhelpers.openssl import check_libssl_tls13 |
882 |
from wafhelpers.openssl import check_openssl_bad_version |
927 |
from wafhelpers.openssl import check_openssl_bad_version |
|
|
928 |
|
883 |
check_libssl_tls13(ctx) |
929 |
check_libssl_tls13(ctx) |
884 |
check_openssl_bad_version(ctx) |
930 |
check_openssl_bad_version(ctx) |
885 |
|
931 |
|
Lines 919-924
int main(int argc, char **argv) {
Link Here
|
919 |
msg_setting("Build Docs", yesno(ctx.env.BUILD_DOC)) |
965 |
msg_setting("Build Docs", yesno(ctx.env.BUILD_DOC)) |
920 |
msg_setting("Build Manpages", yesno(ctx.env.BUILD_MAN)) |
966 |
msg_setting("Build Manpages", yesno(ctx.env.BUILD_MAN)) |
921 |
|
967 |
|
|
|
968 |
if ctx.env["ntpc"] == "none": |
969 |
return |
922 |
ctx.recurse("pylib") |
970 |
ctx.recurse("pylib") |
923 |
ctx.env.PYSHEBANG = ctx.options.pyshebang |
971 |
ctx.env.PYSHEBANG = ctx.options.pyshebang |
924 |
msg_setting("PYSHEBANG", ctx.env.PYSHEBANG) |
972 |
msg_setting("PYSHEBANG", ctx.env.PYSHEBANG) |
Lines 931-949
int main(int argc, char **argv) {
Link Here
|
931 |
|
979 |
|
932 |
|
980 |
|
933 |
class check(BuildContext): |
981 |
class check(BuildContext): |
934 |
cmd = 'check' |
982 |
cmd = "check" |
935 |
variant = "main" |
983 |
variant = "main" |
936 |
|
984 |
|
937 |
|
985 |
|
938 |
def bin_test(ctx): |
986 |
def bin_test(ctx): |
939 |
"""Run binary check, use after tests.""" |
987 |
"""Run binary check, use after tests.""" |
940 |
from wafhelpers.bin_test import cmd_bin_test |
988 |
from wafhelpers.bin_test import cmd_bin_test |
|
|
989 |
|
941 |
cmd_bin_test(ctx) |
990 |
cmd_bin_test(ctx) |
942 |
|
991 |
|
943 |
|
992 |
|
944 |
def bin_test_summary(ctx): |
993 |
def bin_test_summary(ctx): |
945 |
"""Display results of binary check, use after tests.""" |
994 |
"""Display results of binary check, use after tests.""" |
946 |
from wafhelpers.bin_test import bin_test_summary |
995 |
from wafhelpers.bin_test import bin_test_summary |
|
|
996 |
|
947 |
bin_test_summary(ctx) |
997 |
bin_test_summary(ctx) |
948 |
|
998 |
|
949 |
|
999 |
|
Lines 960-965
variant_cmd = (
Link Here
|
960 |
for v in ["host", "main"]: |
1010 |
for v in ["host", "main"]: |
961 |
# the reason for creating these subclasses is just for __doc__ below... |
1011 |
# the reason for creating these subclasses is just for __doc__ below... |
962 |
for cmd, cls in variant_cmd: |
1012 |
for cmd, cls in variant_cmd: |
|
|
1013 |
|
963 |
class tmp(cls): |
1014 |
class tmp(cls): |
964 |
__doc__ = "%s %s" % (cmd, v) |
1015 |
__doc__ = "%s %s" % (cmd, v) |
965 |
cmd = "%s_%s" % (cmd, v) |
1016 |
cmd = "%s_%s" % (cmd, v) |
Lines 968-981
for v in ["host", "main"]:
Link Here
|
968 |
|
1019 |
|
969 |
def init_handler(ctx): |
1020 |
def init_handler(ctx): |
970 |
cmd = ctx.cmd |
1021 |
cmd = ctx.cmd |
971 |
if cmd == 'init_handler': |
1022 |
if cmd == "init_handler": |
972 |
cmd = 'build' |
1023 |
cmd = "build" |
973 |
|
1024 |
|
974 |
def make_context(name): |
1025 |
def make_context(name): |
975 |
for x in Context.classes: |
1026 |
for x in Context.classes: |
976 |
if x.cmd == name and x.fun != 'init_handler': |
1027 |
if x.cmd == name and x.fun != "init_handler": |
977 |
return x() |
1028 |
return x() |
978 |
ctx.fatal('No class for %r' % cmd) |
1029 |
ctx.fatal("No class for %r" % cmd) |
979 |
|
1030 |
|
980 |
# By default we want to iterate over each variant. |
1031 |
# By default we want to iterate over each variant. |
981 |
for v in ["host", "main"]: |
1032 |
for v in ["host", "main"]: |
Lines 996-1010
commands = (
Link Here
|
996 |
|
1047 |
|
997 |
|
1048 |
|
998 |
for command, func, descr in commands: |
1049 |
for command, func, descr in commands: |
|
|
1050 |
|
999 |
class tmp1(Context.Context): |
1051 |
class tmp1(Context.Context): |
1000 |
if descr: |
1052 |
if descr: |
1001 |
__doc__ = descr |
1053 |
__doc__ = descr |
1002 |
cmd = command |
1054 |
cmd = command |
1003 |
fun = func |
1055 |
fun = func |
1004 |
if ((command in |
1056 |
if command in "install uninstall build clean list step": |
1005 |
'install uninstall build clean list step' |
|
|
1006 |
)): |
1007 |
execute = Scripting.autoconfigure(Context.Context.execute) |
1057 |
execute = Scripting.autoconfigure(Context.Context.execute) |
|
|
1058 |
|
1059 |
|
1008 |
# end borrowed code |
1060 |
# end borrowed code |
1009 |
|
1061 |
|
1010 |
|
1062 |
|
Lines 1018-1032
def afterparty(ctx):
Link Here
|
1018 |
# Note that this setup is applied to the build tree, not the |
1070 |
# Note that this setup is applied to the build tree, not the |
1019 |
# source tree. Only the build-tree copies of the programs are |
1071 |
# source tree. Only the build-tree copies of the programs are |
1020 |
# expected to work. |
1072 |
# expected to work. |
1021 |
for x in ("ntpclients", "tests/pylib",): |
1073 |
if "none" == ctx.env["ntpc"]: |
|
|
1074 |
return |
1075 |
for x in ( |
1076 |
"ntpclients", |
1077 |
"tests/pylib", |
1078 |
): |
1022 |
# List used to be longer... |
1079 |
# List used to be longer... |
1023 |
path_build = ctx.bldnode.make_node("pylib") |
1080 |
path_build = ctx.bldnode.make_node("pylib") |
1024 |
path_source = ctx.bldnode.make_node(x + "/ntp") |
1081 |
path_source = ctx.bldnode.make_node(x + "/ntp") |
1025 |
relpath = (("../" * (x.count("/")+1)) + |
1082 |
relpath = ("../" * (x.count("/") + 1)) + path_build.path_from(ctx.bldnode) |
1026 |
path_build.path_from(ctx.bldnode)) |
1083 |
if ctx.cmd in ("install", "build"): |
1027 |
if ctx.cmd in ('install', 'build'): |
1084 |
if ( |
1028 |
if ((not path_source.exists() or |
1085 |
not path_source.exists() |
1029 |
os.readlink(path_source.abspath()) != relpath)): |
1086 |
or os.readlink(path_source.abspath()) != relpath |
|
|
1087 |
): |
1030 |
try: |
1088 |
try: |
1031 |
os.remove(path_source.abspath()) |
1089 |
os.remove(path_source.abspath()) |
1032 |
except OSError: |
1090 |
except OSError: |
Lines 1046-1055
python_scripts = {
Link Here
|
1046 |
|
1104 |
|
1047 |
|
1105 |
|
1048 |
def build(ctx): |
1106 |
def build(ctx): |
|
|
1107 |
global python_scripts |
1049 |
from waflib.Logs import verbose |
1108 |
from waflib.Logs import verbose |
1050 |
ctx.load('waf', tooldir='wafhelpers/') |
1109 |
|
1051 |
ctx.load('asciidoc', tooldir='wafhelpers/') |
1110 |
ctx.load("waf", tooldir="wafhelpers/") |
1052 |
ctx.load('rtems_trace', tooldir='wafhelpers/') |
1111 |
ctx.load("asciidoc", tooldir="wafhelpers/") |
|
|
1112 |
ctx.load("rtems_trace", tooldir="wafhelpers/") |
1053 |
|
1113 |
|
1054 |
if ctx.variant == "host": |
1114 |
if ctx.variant == "host": |
1055 |
ctx.recurse("ntpd") |
1115 |
ctx.recurse("ntpd") |
Lines 1062-1070
def build(ctx):
Link Here
|
1062 |
ctx.add_pre_fun(lambda ctx: ctx.exec_command("rm -f pylib/*.py[co]")) |
1122 |
ctx.add_pre_fun(lambda ctx: ctx.exec_command("rm -f pylib/*.py[co]")) |
1063 |
# Start purging ntp.ntpc files from build dir |
1123 |
# Start purging ntp.ntpc files from build dir |
1064 |
# so old extension won't clobber FFI or reverse |
1124 |
# so old extension won't clobber FFI or reverse |
1065 |
bldnode = ctx.bldnode.make_node('pylib') |
1125 |
bldnode = ctx.bldnode.make_node("pylib") |
1066 |
bldnode.mkdir() |
1126 |
bldnode.mkdir() |
1067 |
target3 = bldnode.ant_glob('*ntpc*') |
1127 |
target3 = bldnode.ant_glob("*ntpc*") |
1068 |
for _ in target3: |
1128 |
for _ in target3: |
1069 |
ctx.exec_command("rm -f %s" % _.abspath()) |
1129 |
ctx.exec_command("rm -f %s" % _.abspath()) |
1070 |
# Finish purging ntp.ntpc |
1130 |
# Finish purging ntp.ntpc |
Lines 1075-1125
def build(ctx):
Link Here
|
1075 |
ctx.recurse("libparse") |
1135 |
ctx.recurse("libparse") |
1076 |
ctx.recurse("libntp") |
1136 |
ctx.recurse("libntp") |
1077 |
if not ctx.env.DISABLE_NTS: |
1137 |
if not ctx.env.DISABLE_NTS: |
1078 |
ctx.recurse("libaes_siv") |
1138 |
ctx.recurse("libaes_siv") |
1079 |
ctx.recurse("ntpd") |
1139 |
ctx.recurse("ntpd") |
1080 |
ctx.recurse("ntpfrob") |
1140 |
ctx.recurse("ntpfrob") |
1081 |
ctx.recurse("ntptime") |
1141 |
ctx.recurse("ntptime") |
1082 |
ctx.recurse("pylib") |
1142 |
ctx.recurse("pylib") |
1083 |
if ctx.env.ENABLE_ATTIC: |
1143 |
if ctx.env.ENABLE_ATTIC: |
1084 |
ctx.recurse("attic") |
1144 |
ctx.recurse("attic") |
1085 |
ctx.recurse("etc") |
1145 |
ctx.recurse("etc") |
1086 |
ctx.recurse("tests") |
1146 |
ctx.recurse("tests") |
1087 |
|
1147 |
|
1088 |
if ctx.env['PYTHON_ARGPARSE']: |
1148 |
if ctx.env["PYTHON_ARGPARSE"]: |
1089 |
python_scripts.add("ntpclients/ntplogtemp.py") |
1149 |
python_scripts.add("ntpclients/ntplogtemp.py") |
1090 |
python_scripts.add("ntpclients/ntpviz.py") |
1150 |
python_scripts.add("ntpclients/ntpviz.py") |
1091 |
if ctx.env['PYTHON_ARGPARSE'] and ctx.env['PYTHON_GPS']: |
1151 |
if ctx.env["PYTHON_ARGPARSE"] and ctx.env["PYTHON_GPS"]: |
1092 |
python_scripts.add("ntpclients/ntploggps.py") |
1152 |
python_scripts.add("ntpclients/ntploggps.py") |
1093 |
if ctx.env['PYTHON_CURSES']: |
1153 |
if ctx.env["PYTHON_CURSES"]: |
1094 |
python_scripts.add("ntpclients/ntpmon.py") |
1154 |
python_scripts.add("ntpclients/ntpmon.py") |
1095 |
|
1155 |
if "none" == ctx.env["ntpc"]: |
1096 |
# Make sure the python scripts compile, but don't install them |
1156 |
python_scripts = [] |
1097 |
ctx( |
1157 |
else: |
1098 |
features="py", |
1158 |
# Make sure the python scripts compile, but don't install them |
1099 |
source=python_scripts, |
1159 |
ctx( |
1100 |
install_path=None, |
1160 |
features="py", |
1101 |
) |
1161 |
source=python_scripts, |
|
|
1162 |
install_path=None, |
1163 |
) |
1102 |
|
1164 |
|
1103 |
scripts = ["ntpclients/ntpleapfetch"] + list(python_scripts) |
1165 |
scripts = ["ntpclients/ntpleapfetch"] + list(python_scripts) |
1104 |
|
1166 |
|
1105 |
ctx( |
1167 |
ctx( |
1106 |
features="subst", |
1168 |
features="subst", |
1107 |
source=scripts, |
1169 |
source=scripts, |
1108 |
target=[x.replace('.py', '') for x in scripts], |
1170 |
target=[x.replace(".py", "") for x in scripts], |
1109 |
chmod=Utils.O755, |
1171 |
chmod=Utils.O755, |
1110 |
install_path='${BINDIR}', |
1172 |
install_path="${BINDIR}", |
1111 |
) |
1173 |
) |
1112 |
|
1174 |
|
1113 |
ctx.add_post_fun(afterparty) |
1175 |
ctx.add_post_fun(afterparty) |
1114 |
if ctx.cmd == 'clean': |
1176 |
if ctx.cmd == "clean": |
1115 |
afterparty(ctx) |
1177 |
afterparty(ctx) |
1116 |
|
1178 |
|
1117 |
if ctx.env['PYTHON_ARGPARSE']: |
1179 |
if ctx.env["PYTHON_ARGPARSE"]: |
1118 |
ctx.manpage(1, "ntpclients/ntplogtemp-man.adoc") |
1180 |
ctx.manpage(1, "ntpclients/ntplogtemp-man.adoc") |
1119 |
ctx.manpage(1, "ntpclients/ntpviz-man.adoc") |
1181 |
ctx.manpage(1, "ntpclients/ntpviz-man.adoc") |
1120 |
if ctx.env['PYTHON_ARGPARSE'] and ctx.env['PYTHON_GPS']: |
1182 |
if ctx.env["PYTHON_ARGPARSE"] and ctx.env["PYTHON_GPS"]: |
1121 |
ctx.manpage(1, "ntpclients/ntploggps-man.adoc") |
1183 |
ctx.manpage(1, "ntpclients/ntploggps-man.adoc") |
1122 |
if ctx.env['PYTHON_CURSES']: |
1184 |
if ctx.env["PYTHON_CURSES"]: |
1123 |
ctx.manpage(1, "ntpclients/ntpmon-man.adoc") |
1185 |
ctx.manpage(1, "ntpclients/ntpmon-man.adoc") |
1124 |
ctx.manpage(1, "ntpclients/ntpdig-man.adoc") |
1186 |
ctx.manpage(1, "ntpclients/ntpdig-man.adoc") |
1125 |
ctx.manpage(1, "ntpclients/ntpq-man.adoc") |
1187 |
ctx.manpage(1, "ntpclients/ntpq-man.adoc") |
Lines 1132-1137
def build(ctx):
Link Here
|
1132 |
|
1194 |
|
1133 |
# Skip running unit tests on a cross compile build |
1195 |
# Skip running unit tests on a cross compile build |
1134 |
from waflib import Options |
1196 |
from waflib import Options |
|
|
1197 |
|
1135 |
if not ctx.env.ENABLE_CROSS: |
1198 |
if not ctx.env.ENABLE_CROSS: |
1136 |
# Force re-running of tests. Same as 'waf --alltests' |
1199 |
# Force re-running of tests. Same as 'waf --alltests' |
1137 |
if ctx.cmd == "check": |
1200 |
if ctx.cmd == "check": |
Lines 1159-1169
def build(ctx):
Link Here
|
1159 |
|
1222 |
|
1160 |
if ctx.cmd == "build": |
1223 |
if ctx.cmd == "build": |
1161 |
if "PYTHONPATH" not in os.environ: |
1224 |
if "PYTHONPATH" not in os.environ: |
1162 |
print("--- PYTHONPATH is not set, " |
1225 |
print( |
1163 |
"loading the Python ntp library may be troublesome ---") |
1226 |
"--- PYTHONPATH is not set, " |
|
|
1227 |
"loading the Python ntp library may be troublesome ---" |
1228 |
) |
1164 |
elif ctx.env.PYTHONARCHDIR not in os.environ["PYTHONPATH"]: |
1229 |
elif ctx.env.PYTHONARCHDIR not in os.environ["PYTHONPATH"]: |
1165 |
print("--- PYTHONARCHDIR not in PYTHONPATH, " |
1230 |
print( |
1166 |
"loading the Python ntp library may be troublesome ---") |
1231 |
"--- PYTHONARCHDIR not in PYTHONPATH, " |
|
|
1232 |
"loading the Python ntp library may be troublesome ---" |
1233 |
) |
1234 |
|
1167 |
|
1235 |
|
1168 |
# |
1236 |
# |
1169 |
# Miscellaneous utility productions |
1237 |
# Miscellaneous utility productions |
Lines 1183-1196
def loccount(ctx):
Link Here
|
1183 |
|
1251 |
|
1184 |
def cxfreeze(ctx): |
1252 |
def cxfreeze(ctx): |
1185 |
"Create standalone binaries from Python scripts." |
1253 |
"Create standalone binaries from Python scripts." |
1186 |
ctx.exec_command("for prog in " + " ".join(python_scripts) + |
1254 |
ctx.exec_command( |
1187 |
"; do cxfreeze $prog; done") |
1255 |
"for prog in " + " ".join(python_scripts) + "; do cxfreeze $prog; done" |
|
|
1256 |
) |
1188 |
|
1257 |
|
1189 |
|
1258 |
|
1190 |
def linkcheck(ctx): |
1259 |
def linkcheck(ctx): |
1191 |
"Report references without anchors in the documentation." |
1260 |
"Report references without anchors in the documentation." |
1192 |
ctx.exec_command("devel/linkcheck docs/") |
1261 |
ctx.exec_command("devel/linkcheck docs/") |
1193 |
|
1262 |
|
|
|
1263 |
|
1194 |
# The following sets edit modes for GNU EMACS |
1264 |
# The following sets edit modes for GNU EMACS |
1195 |
# Local Variables: |
1265 |
# Local Variables: |
1196 |
# mode:python |
1266 |
# mode:python |
1197 |
- |
|
|