include/disas/capstone.h | 5 +++++ meson.build | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-)
Historically, capstone varies in requiring either <capstone.h>
or <capstone/capstone.h> include depending on version and the
way how it has been installed. This has already been an issue
before, and will likely become an issue again with capstone
5.0 which seem to have changed this aspect once again.
Recognize both ways in the meson check, but prefer <capstone.h>
so it's easy to override which capstone to use by
pkgconfig's --cflags (or --extra-cflags).
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
v2: use cc.has_header, not cc.compile (pm215)
include/disas/capstone.h | 5 +++++
meson.build | 21 +++++++++++----------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/disas/capstone.h b/include/disas/capstone.h
index e29068dd97..406132a63c 100644
--- a/include/disas/capstone.h
+++ b/include/disas/capstone.h
@@ -3,7 +3,12 @@
#ifdef CONFIG_CAPSTONE
+#ifdef HAVE_CAPSTONE_CAPSTONE_H
+#include <capstone/capstone.h>
+#else
#include <capstone.h>
+#endif
+
#else
diff --git a/meson.build b/meson.build
index cf3e517e56..65cb53d1cf 100644
--- a/meson.build
+++ b/meson.build
@@ -2680,16 +2680,17 @@ if not get_option('capstone').auto() or have_system or have_user
capstone = dependency('capstone', version: '>=3.0.5',
kwargs: static_kwargs, method: 'pkg-config',
required: get_option('capstone'))
-
- # 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 <capstone.h>',
- dependencies: [capstone])
- capstone = not_found
- if get_option('capstone').enabled()
- error('capstone requested, but it does not appear to work')
+ if capstone.found()
+ # capstone works either with <capstone.h> or <capstone/capstone.h>
+ if cc.has_header('capstone.h', dependencies: [capstone])
+ # nothing to be done here (see include/disas/capstone.h)
+ elif cc.has_header('capstone/capstone.h', dependencies: [capstone])
+ config_host_data.set('HAVE_CAPSTONE_CAPSTONE_H')
+ else
+ capstone = not_found
+ if get_option('capstone').enabled()
+ error('capstone requested, but it does not appear to work')
+ endif
endif
endif
endif
--
2.30.2
15.11.2022 14:55, Michael Tokarev wrote: > + elif cc.has_header('capstone/capstone.h', dependencies: [capstone]) > + config_host_data.set('HAVE_CAPSTONE_CAPSTONE_H') This needs to be config_host_data.set('HAVE_CAPSTONE_CAPSTONE_H', 1) It either can be fixed at apply time or I resend a v3. (threading was messed up too due to our mailserver munging message-id). /mjt
On 11/15/22 21:55, Michael Tokarev wrote: > Historically, capstone varies in requiring either <capstone.h> > or <capstone/capstone.h> include depending on version and the > way how it has been installed. This has already been an issue > before, and will likely become an issue again with capstone > 5.0 which seem to have changed this aspect once again. > > Recognize both ways in the meson check, but prefer <capstone.h> > so it's easy to override which capstone to use by > pkgconfig's --cflags (or --extra-cflags). > > Signed-off-by: Michael Tokarev<mjt@tls.msk.ru> > --- > v2: use cc.has_header, not cc.compile (pm215) Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
On Tue, 15 Nov 2022 at 11:55, Michael Tokarev <mjt@tls.msk.ru> wrote: > > Historically, capstone varies in requiring either <capstone.h> > or <capstone/capstone.h> include depending on version and the > way how it has been installed. This has already been an issue > before, and will likely become an issue again with capstone > 5.0 which seem to have changed this aspect once again. > > Recognize both ways in the meson check, but prefer <capstone.h> > so it's easy to override which capstone to use by > pkgconfig's --cflags (or --extra-cflags). > > Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> > --- > v2: use cc.has_header, not cc.compile (pm215) Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM
© 2016 - 2024 Red Hat, Inc.