summaryrefslogtreecommitdiff
path: root/pkg/kbd/gen.lua
blob: 2abe315da108074b159cd5a20cc9fddb1cb0362f (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
74
75
76
cflags{
	[[-D 'DATADIR="/share/kbd"']],
	'-I include',
	'-I $dir',
	'-I $srcdir',
	'-I $srcdir/src',
	'-I $srcdir/src/libkeymap',
	'-I $srcdir/src/libkeymap/keymap',
}

lib('libcommon.a', 'src/(getfd.c xmalloc.c kbd_error.c)')
lib('libfont.a', 'src/(kdfontop.c kdmapop.c loadunimap.c psffontop.c utf8.c)')
lib('libkeymap.a', [[src/libkeymap/(
	analyze.c
	array.c
	common.c
	diacr.c
	dump.c
	findfile.c
	func.c
	kernel.c
	kmap.c
	ksyms.c
	loadkeys.c
	modifiers.c
	parser.c
	summary.c
)]])

-- old: loadunimap mapscrn
-- optional: clrunmap getunimap setlogcons setvesablank setpalette screendump
-- i386/x86_64 only: resizecons
-- ubase: chvt

local function x(cmd, section, subst, srcs)
	if not srcs then
		srcs = 'src/'..cmd..'.c'
	end
	exe(cmd, {srcs, 'libcommon.a', 'libfont.a', 'libkeymap.a'})
	file('bin/'..cmd, '755', '$outdir/'..cmd)
	if not section then
		return
	end
	local manpage = string.format('docs/man/man%s/%s.%s', section, cmd, section)
	if subst then
		local out = string.format('$outdir/%s.%s', cmd, section)
		build('sed', out, '$srcdir/'..manpage..'.in', {expr='s,@DATADIR@,/share/kbd,g'})
		manpage = out
	end
	man{manpage}
end

x('deallocvt',       '1')
x('dumpkeys',        '1', true)
x('fgconsole',       '1')
x('getkeycodes',     '8')
x('kbd_mode',        '1')
x('kbdinfo')
x('loadkeys',        '1', true)
x('openvt',          '1')
x('psfxtable',       '1')
x('setfont',         '8', true, {'src/setfont.c', 'src/mapscrn.c'})
x('setkeycodes',     '8')
x('setvtrgb',        '8')
x('showconsolefont', '8')
x('showkey',         '1')

-- keymap data
for keymap in iterlines('keymaps.txt') do
	local out = '$outdir/keymaps/'..keymap..'.gz'
	build('gzip', out, '$srcdir/data/keymaps/'..keymap)
	file('share/kbd/keymaps/'..keymap..'.gz', '644', out)
end
sym('share/kbd/keymaps/ppc', 'mac')

fetch 'curl'