diff options
| author | Michael Forney <mforney@mforney.org> | 2021-02-14 03:34:09 -0800 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2021-02-14 03:36:52 -0800 |
| commit | 699ed0a112df7470e554f23561af1d78c784dc4f (patch) | |
| tree | bf18cb309750d6303d6f10ea9cbe1c075c0ffbe8 | |
| parent | 384c083c1673de3d384160f6ae4180b3a67d55aa (diff) | |
file: Use tool built for host to generate magic.mgc
It turns out file has an undocumented define COMPILE_ONLY that
enables building a tool to just generate the magic database with a
minimal set of sources. Use that to build a tool for the host system
to avoid version incompatibilities.
Fixes #24.
| -rw-r--r-- | pkg/file/.gitignore | 1 | ||||
| -rw-r--r-- | pkg/file/gen.lua | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/pkg/file/.gitignore b/pkg/file/.gitignore new file mode 100644 index 00000000..b38f5394 --- /dev/null +++ b/pkg/file/.gitignore @@ -0,0 +1 @@ +/host.ninja diff --git a/pkg/file/gen.lua b/pkg/file/gen.lua index 626b044d..b1cc4a28 100644 --- a/pkg/file/gen.lua +++ b/pkg/file/gen.lua @@ -38,8 +38,23 @@ exe('file', {'src/file.c', 'src/seccomp.c', 'libmagic.a', '$builddir/pkg/zlib/li file('bin/file', '755', '$outdir/file') man{'$outdir/file.1'} -rule('magic', 'cd $outdir && file -C -m magic') +sub('host.ninja', function() + toolchain(config.host) + cflags{ + '-I $outdir/include', + '-D HAVE_STDINT_H', + '-D HAVE_INTTYPES_H', + '-D HAVE_UNISTD_H', + '-D COMPILE_ONLY', + ([[-D 'VERSION="%s"']]):format(version), + } + set('outdir', '$outdir/host') + exe('magic', 'src/(magic.c apprentice.c encoding.c print.c funcs.c cdf_time.c)') +end) + +rule('magic', 'cd $outdir && ./host/magic magic') build('magic', '$outdir/magic.mgc', {'|', + '$outdir/host/magic', copy('$outdir/magic', '$srcdir/magic/Magdir', lines('magic.txt')), copy('$outdir/magic', '$srcdir/magic', {'Header', 'Localstuff'}), }) |
