From nobody Fri Apr 26 21:48:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669103226295932.749101954269; Mon, 21 Nov 2022 23:47:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxNz8-0002vC-3Q; Tue, 22 Nov 2022 02:46:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxNyy-0002ua-K3 for qemu-devel@nongnu.org; Tue, 22 Nov 2022 02:46:16 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxNyw-0005uP-J5 for qemu-devel@nongnu.org; Tue, 22 Nov 2022 02:46:16 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 429F74033B; Tue, 22 Nov 2022 10:46:02 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id C3D053D3; Tue, 22 Nov 2022 10:46:01 +0300 (MSK) Received: (nullmailer pid 848963 invoked by uid 1000); Tue, 22 Nov 2022 07:46:01 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Peter Maydell , Michael Tokarev , Richard Henderson Subject: [PATCH v3] disas: recognize either or Date: Tue, 22 Nov 2022 10:45:59 +0300 Message-Id: <20221122074559.848913-1-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1669103230087100003 Content-Type: text/plain; charset="utf-8" Historically, capstone varies in requiring either or 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 so it's easy to override which capstone to use by pkgconfig's --cflags (or --extra-cflags). Signed-off-by: Michael Tokarev Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Daniel P. Berrang=C3=A9 --- v2: use cc.has_header, not cc.compile (pm215) v3: fix the forgotten arg for config_host_data.set (comitted locally but not included in previous format-patch) 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 @@ =20 #ifdef CONFIG_CAPSTONE =20 +#ifdef HAVE_CAPSTONE_CAPSTONE_H +#include +#else #include +#endif + =20 #else =20 diff --git a/meson.build b/meson.build index cf3e517e56..b97e9e1195 100644 --- a/meson.build +++ b/meson.build @@ -2680,16 +2680,17 @@ if not get_option('capstone').auto() or have_system= or have_user capstone =3D dependency('capstone', version: '>=3D3.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 ', - dependencies: [capstone]) - capstone =3D not_found - if get_option('capstone').enabled() - error('capstone requested, but it does not appear to work') + if capstone.found() + # capstone works either with or + 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', 1) + else + capstone =3D not_found + if get_option('capstone').enabled() + error('capstone requested, but it does not appear to work') + endif endif endif endif --=20 2.30.2