From 8f4aea712ffc4f2c20c293dac26df8688f497a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 9 Jul 2021 15:29:31 +0100 Subject: build: validate that system capstone works before using it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some versions of capstone have shipped a broken pkg-config file which puts the -I path without the trailing '/capstone' suffix. This breaks the ability to "#include ". Upstream and most distros have fixed this, but a few stragglers remain, notably FreeBSD. Signed-off-by: Daniel P. Berrangé Signed-off-by: Alex Bennée Reviewed-by: Thomas Huth Reviewed-by: Willian Rampazzo Reviewed-by: Richard Henderson Message-Id: <20210625172211.451010-2-berrange@redhat.com> Message-Id: <20210709143005.1554-7-alex.bennee@linaro.org> --- meson.build | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 512ee2e926..89c09ed7ea 100644 --- a/meson.build +++ b/meson.build @@ -1657,6 +1657,19 @@ if capstone_opt in ['enabled', 'auto', 'system'] kwargs: static_kwargs, method: 'pkg-config', required: capstone_opt == 'system' or capstone_opt == 'enabled' and not have_internal) + + # Some versions of capstone have broken pkg-config file + # that reports a wrong -I path, causing the #include to + # fail later. If the system has such a broken version + # do not use it. + if capstone.found() and not cc.compiles('#include ', + dependencies: [capstone]) + capstone = not_found + if capstone_opt == 'system' + error('system capstone requested, it does not appear to work') + endif + endif + if capstone.found() capstone_opt = 'system' elif have_internal -- cgit v1.2.3