From nobody Sat May 11 23:38:21 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 1668505135025378.0185277751265; Tue, 15 Nov 2022 01:38:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ousOZ-0008KM-RD; Tue, 15 Nov 2022 04:38:20 -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 1ousOU-0008JZ-0d for qemu-devel@nongnu.org; Tue, 15 Nov 2022 04:38:15 -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 1ousOS-0001dv-9M for qemu-devel@nongnu.org; Tue, 15 Nov 2022 04:38:13 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id A924C402A0; Tue, 15 Nov 2022 12:38:09 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 0F60F3B9; Tue, 15 Nov 2022 12:38:09 +0300 (MSK) Received: (nullmailer pid 52100 invoked by uid 1000); Tue, 15 Nov 2022 09:38:09 -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] disas: recognize either or Date: Tue, 15 Nov 2022 12:38:03 +0300 Message-Id: <20221115093803.52050-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: 1668505136582100001 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 easily to override which capstone to use by pkgconfig's --cflags (or --extra-cflags). Signed-off-by: Michael Tokarev --- include/disas/capstone.h | 5 +++++ meson.build | 22 ++++++++++++---------- 2 files changed, 17 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..2a3ae65d76 100644 --- a/meson.build +++ b/meson.build @@ -2680,16 +2680,18 @@ 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 + # determine which one do we have here, prefer first one with pkg-confi= g's --cflags + if cc.compiles('#include ', dependencies: [capstone]) + # nothing to be done here (see include/disas/capstone.h) + elif cc.compiles('#include ', dependencies: [caps= tone]) + 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