master hovercats/oakiss / pkg / libffi / gen.lua
 1local targets = {
 2	aarch64={name='AARCH64', dir='aarch64'},
 3	riscv64={name='RISCV', dir='riscv'},
 4	x86_64={name='X86_64', dir='x86'},
 5}
 6local arch = config.target.platform:match('[^-]*')
 7local targ = targets[arch]
 8if not targ then return end
 9
10cflags{
11	'-Wall', '-Wno-deprecated-declarations',
12	'-I $dir',
13	'-I $outdir/include',
14	'-I $srcdir/include',
15}
16
17build('sed', '$outdir/include/ffi.h', '$srcdir/include/ffi.h.in', {
18	expr={
19		'-e s,@VERSION@,3.3,',
20		string.format('-e s,@TARGET@,%s,', targ.name),
21		'-e s,@HAVE_LONG_DOUBLE@,1,',
22		'-e s,@HAVE_LONG_DOUBLE_VARIANT@,0,',
23		'-e s,@FFI_EXEC_TRAMPOLINE_TABLE@,0,',
24	},
25})
26
27pkg.hdrs = {
28	copy('$outdir/include', '$srcdir/src/'..targ.dir, {'ffitarget.h'}),
29	'$outdir/include/ffi.h',
30	install=true,
31}
32
33pkg.deps = {
34	'$gendir/headers',
35}
36
37lib('libffi.a', [[
38	src/(
39		prep_cif.c types.c raw_api.c java_raw_api.c closures.c
40		@aarch64 aarch64/(ffi.c sysv.S)
41		@x86_64 x86/(ffi64.c unix64.S ffiw64.c win64.S)
42		@riscv64 riscv/(ffi.c sysv.S)
43	)
44]])
45file('lib/libffi.a', '644', '$outdir/libffi.a')
46
47fetch 'git'