summaryrefslogtreecommitdiff
path: root/pkg/nsd/gen.lua
blob: 0d8526a49f5d9acc764ec51c5c920f0ccb935174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
cflags{
	'-Wall',
	'-I $dir',
	'-I $srcdir',
	'-I $basedir/pkg/openbsd/include',
}

lib('libcommon.a', [[
	answer.c axfr.c buffer.c configlexer.c configparser.c dname.c dns.c
	edns.c iterated_hash.c lookup3.c namedb.c nsec3.c options.c packet.c
	query.c rbtree.c radtree.c rdata.c region-allocator.c rrl.c tsig.c
	tsig-openssl.c udb.c udbradtree.c udbzone.c util.c bitset.c popen3.c
	compat/(cpuset.c setproctitle.c)
	$builddir/pkg/openbsd/libbsd.a
]])

lib('libnsd.a', [[
        dbaccess.c dbcreate.c difffile.c ipc.c mini_event.c netio.c server.c
        zlexer.c zonec.c zparser.c
	xfrd-disk.c xfrd-notify.c xfrd-tcp.c xfrd.c remote.c
	libcommon.a.d
]])

exe('nsd', {'nsd.c', 'libnsd.a.d'})
exe('nsd-checkconf', {'nsd-checkconf.c', 'libcommon.a.d'})
exe('nsd-checkzone', {'nsd-checkzone.c', 'libnsd.a.d'})

local cfg = {
	logfile='/var/log/nsd.log',  -- just used for man page example
	chrootdir='',
	ratelimit_default='on',
}
for line in iterlines('config.h', 1) do
	local var, val = line:match('^#define ([%w_]+) "(.*)"$')
	if var then
		cfg[var:lower()] = val
	elseif line:find('^#define RATELIMIT') then
		cfg.ratelimit = 'on'
	elseif line:find('^#define RATELIMIT_DEFAULT_OFF') then
		cfg.ratelimit_default = 'off'
	end
end
local subst = {
	'-e s,@configdir@,'..cfg.configdir..',g',
	'-e s,@zonesdir@,'..cfg.zonesdir..',g',
	'-e s,@chrootdir@,'..cfg.chrootdir..',g',
	'-e s,@pidfile@,'..cfg.pidfile..',g',
	'-e s,@logfile@,'..cfg.logfile..',g',
	'-e s,@dbfile@,'..cfg.dbfile..',g',
	'-e s,@xfrdir@,'..cfg.xfrdir..',g',
	'-e s,@xfrdfile@,'..cfg.xfrdfile..',g',
	'-e s,@zonelistfile@,'..cfg.zonelistfile..',g',
	'-e s,@nsdconfigfile@,'..cfg.configfile..',g',
	'-e s,@ratelimit_default@,'..cfg.ratelimit_default..',g',
	'-e s,@dnstap_socket_path@,,g',
	'-e s,@user@,'..cfg.user..',g',
}
if not cfg.ratelimit then
	table.insert(subst, '-e /rrlstart/,/rrlend/d')
end
set('subst', subst)
local function substman(file)
	build('sed', '$outdir/'..file, '$srcdir/'..file..'.in', {expr='$subst'})
	man{'$outdir/'..file}
end

for _, cmd in ipairs{'nsd', 'nsd-checkconf', 'nsd-checkzone'} do
	file('bin/'..cmd, '755', '$outdir/'..cmd)
	substman(cmd..'.8')
end
substman('nsd.conf.5')

fetch 'curl'