From nobody Fri May 10 17:01:53 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 1668513410279604.8632170833662; Tue, 15 Nov 2022 03:56:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouuXs-0004Fm-9z; Tue, 15 Nov 2022 06:56:04 -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 1ouuXq-0004FG-2X for qemu-devel@nongnu.org; Tue, 15 Nov 2022 06:56:02 -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 1ouuXn-00015i-8M for qemu-devel@nongnu.org; Tue, 15 Nov 2022 06:56:01 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 47062402AA; Tue, 15 Nov 2022 14:55:57 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 6DCC710C; Tue, 15 Nov 2022 14:55:56 +0300 (MSK) Received: (nullmailer pid 77295 invoked by uid 1000); Tue, 15 Nov 2022 11:55:56 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Peter Maydell , Michael Tokarev Subject: [PATCH v2] disas: recognize either or Date: Tue, 15 Nov 2022 14:55:52 +0300 Message-Id: <20221115115552.77242-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: 1668513411362100001 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 --- 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 @@ =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..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 =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') + 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