diff options
author | 2022-06-24 10:19:20 +0200 | |
---|---|---|
committer | 2022-07-12 07:33:20 +0100 | |
commit | 063fcaeaa05074a9d90acec2f68b25dfb8ecd279 (patch) | |
tree | 0e8963a74ae52de9b034f1f255f6873868d94f63 /meson.build | |
parent | seccomp: allow madvise() call (glibc 2.35+) (diff) | |
download | pax-utils-063fcaeaa05074a9d90acec2f68b25dfb8ecd279.tar.gz pax-utils-063fcaeaa05074a9d90acec2f68b25dfb8ecd279.tar.bz2 pax-utils-063fcaeaa05074a9d90acec2f68b25dfb8ecd279.zip |
Convert build system to meson
Some notes about the new build systems:
- I don't fully understand the testing system, but I think I understood
it well enough to implement an equivalent one.
- use_seccomp could be replaced by detecting seccomp support at runtime
(without support, Linux returns -EINVAL in include/linux/seccomp.h)
- The fuzzing test is broken and seems to have been for a while (see
commit 67f3ba64c91b5e1ac9fbbd0bc039fb8ca653cae1, it fails to fuzz on
my machine)
- make-tarball.sh has been replaced with meson dist - hopefully this
works. meson dist should also call seccomp-bpf.c to update
seccomp-bpf.h
Signed-off-by: Arsen Arsenović <arsen@aarsen.me>
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..6a5dd66 --- /dev/null +++ b/meson.build @@ -0,0 +1,169 @@ +project('pax-utils', 'c', + version : '1.3.5-pre', + license : 'GPL-2.0-only', + default_options : [ + 'warning_level=2', + 'c_std=gnu11', + ], +) + +cc = meson.get_compiler('c') + +libcap = dependency('libcap', required : get_option('use_libcap')) +if libcap.found() + add_project_arguments('-DWANT_SYSCAP', language : 'c') +endif + +if get_option('use_seccomp') + add_project_arguments('-DWANT_SECCOMP', language : 'c') +endif + +if get_option('buildtype') in ['debug', 'debugoptimized'] + add_project_arguments('-DEBUG', language : 'c') +endif + +# generate VCSID +version_h = vcs_tag(input : 'version.h.in', output : 'pax_utils_version.h') +# tell paxinc.h to use it +add_project_arguments('-DINCLUDE_GENERATE_VERSION_H', language : 'c') +add_project_arguments('-DVERSION="' + meson.project_version() + '"', language : 'c') + +add_project_arguments('-D_GNU_SOURCE', language : 'c') +add_project_arguments('-D_FILE_OFFSET_BITS=64', language : 'c') + +# probe the platform... +probe_results = configuration_data() + +## first, we check a bunch of headers +foreach x : [ + 'endian.h', 'byteswap.h', # GNU-likes + 'sys/endian.h', # BSDs, + 'sys/isa_defs.h', # Sun/Illumios + 'machine/endian.h', # Mach + + 'linux/seccomp.h', + 'linux/securebits.h', + 'sys/prctl.h', + 'alloca.h', + 'elf-hints.h', + 'glob.h', +] + x_exists = 0 + if cc.has_header(x) + x_exists = 1 + endif + probe_results.set('HAS_' + x.to_upper().underscorify(), x_exists) +endforeach + +configure_file( + output : 'probes.h', + configuration : probe_results, +) + + +# common code +common_src = [ + 'paxinc.c', + 'security.c', + 'xfuncs.c', + version_h, +] +common = static_library('common', + common_src, + install : false +) + +if cc.get_define('__svr4__') == '' + executable('pspax', + 'paxelf.c', + 'paxldso.c', + 'pspax.c', + version_h, + dependencies : [libcap], + link_with : common, + install : true + ) +endif + +executable('scanelf', + 'paxelf.c', + 'paxldso.c', + 'scanelf.c', + version_h, + dependencies : [libcap], + link_with : common, + install : true +) + +# dumpelf code (without the common code above) +dumpelf_src = [ + 'paxelf.c', + 'paxldso.c', + 'dumpelf.c', + version_h, +] + +executable('dumpelf', + dumpelf_src, + dependencies : [libcap], + link_with : common, + install : true +) + +executable('scanmacho', + 'paxmacho.c', + 'scanmacho.c', + version_h, + dependencies : [libcap], + link_with : common, + install : true +) + +lddtree_impl = get_option('lddtree_implementation') +if lddtree_impl != 'none' + if lddtree_impl == 'python' + suffix = '.py' + else + suffix = '.sh' + endif + install_data('lddtree' + suffix, + rename : 'lddtree', + install_dir : get_option('bindir') + ) +endif +install_data('symtree.sh', + rename : 'symtree', + install_dir : get_option('bindir') +) + +subdir('man') + +do_tests = get_option('tests') +if do_tests + subdir('tests/lddtree') + subdir('tests/scanelf') + subdir('tests/source') +endif + +if do_tests and get_option('use_fuzzing') + ncc = meson.get_compiler('c', native : true) + fuzz_flags = [ + '-g3', '-ggdb', + '-fsanitize=fuzzer', '-fsanitize-coverage=edge', + '-DPAX_UTILS_LIBFUZZ=1', + ] + if ncc.get_id() != 'clang' + warning('use_fuzzing requires Clang, due to LibFuzzer. Not building fuzzers') + else + dumpelf_fuzzer = executable('dumpelf.fuzz', + common_src + dumpelf_src, + override_options : [ + 'buildtype=debug', + ], + c_args : fuzz_flags, + link_args : fuzz_flags, + install : false + ) + test('fuzz-dumpelf', dumpelf_fuzzer) + endif +endif |