From patchwork Wed Oct 25 12:30:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117119 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1693586edm; Wed, 25 Oct 2017 05:34:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TrWSObwCu52dNLOOqezRwFB2x+1hdmvFEoiXmQYzJDmxvpIbLmwsrFRo39KNugPEs1hM6g X-Received: by 10.37.186.7 with SMTP id t7mr1190350ybg.495.1508934878016; Wed, 25 Oct 2017 05:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934878; cv=none; d=google.com; s=arc-20160816; b=AZbvhXwac/HgTViM/yULmdMceQNaTkMe0DzVC9/aL11WE659GP84u/wYn93URVhRTK mdOLFkOIiFyHkkyWZRRZd0cXXrqQHgFthgNkWEMLTfrJrhspwNP3WZZKc3se7lJWLHxo R19ZE1I7ROgotTU25zSjwOEmN666kws/zG28JCKirvKs9yTJwW3zUx5ONuPmqPmVH7sk nzkQcorpLMGwGbJC9JzxU6+Ke/4+fqYQIwyFaHTUhEk/DfYp047Ix4omyXaczxdD72s5 k+U1COC0nOXYuquZa0zU6iqfiUfG2M/Sv5/wXCrxmUA94iVkG2nBChBZYDIQ7PqXbVg9 9DKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=RminbL6lnTAsUkz7cTvMgitD71VzNFGUX7fWXcW8aws=; b=WCOwK/tZOTjvGDjcSa8ZaDW+Z/KxGSPViNNJ/hkThKsf0C6Tkgz/IrZV58wfukSww2 WNech5LkxNCSOy/He6aeBuKSvWaEwj5WTFPPODL12FB6HLrSe/MiZznyWpOAxs2GW9Sh ys2sB2/wi4TbkWScSJam+ma2F21UZ8IA4/4Ht4IhJAXaxZ80PYx7SsuSSsWtAEzFXRuJ 18aDzM1KI1bHh2h+sms1XihoB1Fb7yC2ZlA22teklCv3NC3B6JzXSDGhhVmtcQi08Lku O3113Z1FSF73pJLVE+v7b3MY2QGPFD3EAddMQCDHpuph/eiVhECfKJl6fZevGvL60kr0 BFrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a43AGrLB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t31si406874ybt.390.2017.10.25.05.34.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:34:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a43AGrLB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KtJ-0001cc-EC for patch@linaro.org; Wed, 25 Oct 2017 08:34:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq8-0007b8-7O for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq6-00086e-S0 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:20 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:51746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq6-00085X-HY for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:18 -0400 Received: by mail-wm0-x241.google.com with SMTP id b9so1636048wmh.0 for ; Wed, 25 Oct 2017 05:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RminbL6lnTAsUkz7cTvMgitD71VzNFGUX7fWXcW8aws=; b=a43AGrLBhH33aon6NsKVjTRgfKlEksY+XmOOxVesYF3fHV54zfofITx8UwH5OMyXNL n67nf1ytOT/CD41UQLzSS5mTelTJ9iSFZpNDtaQEcBEvLsH2blyABK12UvXgIuaW2/nC WVhpE85TnV5HtSo/l527gy+FlV+qPjryTLY/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RminbL6lnTAsUkz7cTvMgitD71VzNFGUX7fWXcW8aws=; b=foF0vLtbt/k4cFNosWmpx2Ea43O0JEqDSmkx/i3mlGoupsutb7PJrASjN5flxJyVnf w5T8mJYo9tAdE070aGSpHIR811/tc+STe9u9Df1jk9AAB4LWUtHQWMTNGFGXPzOk5/Aj doaQ6g+UPuBeRx2QCEgH5ukwKw5CHKwXiXAxOmmROrd3JGYWlBRAllNXnCf1H0wXAk6O 9v3kXf9xpYC+Uo+iQQmvqN3R5nHPxOKmQrRwVQsK2ucA+DByDlI6+kczkf+/0JKqFhxd iaFAfJYXv81H4+lCTIqby9ZN3UKwPBSvKntiCTlZyaOw7O0fS5ABJ3YugVVl95dXl61X i5dg== X-Gm-Message-State: AMCzsaXzjH6cijKEWpL5lQUKUSAPUtSamwIWOVB6ajvOx5dOhaAxeQmw QMokToX1zfIb79rHbcSyOwSW1gDVYEo= X-Received: by 10.28.165.4 with SMTP id o4mr1723084wme.68.1508934677323; Wed, 25 Oct 2017 05:31:17 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:56 +0200 Message-Id: <20171025123056.3165-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 11/11] disas: Add capstone as submodule X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not require the submodule, but use it if present. Allow the command-line to override system or git submodule either way. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- Makefile | 15 +++++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 68 insertions(+), 11 deletions(-) create mode 160000 capstone -- 2.13.6 diff --git a/Makefile b/Makefile index 9372742f86..33b4ce6e6e 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,21 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests dtc/%: .git-submodule-status mkdir -p $@ +# Overriding CFLAGS causes us to lose defines added in the sub-makefile. +# Not overriding CFLAGS leads to mis-matches between compilation modes. +# Therefore we replicate some of the logic in the sub-makefile. +# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't; +# no need to annoy QEMU developers with such things. +CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS)) +CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM +CAP_CFLAGS += -DCAPSTONE_HAS_ARM +CAP_CFLAGS += -DCAPSTONE_HAS_ARM64 +CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC +CAP_CFLAGS += -DCAPSTONE_HAS_X86 + +subdir-capstone: .git-submodule-status + $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/libcapstone.a) + $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) diff --git a/.gitmodules b/.gitmodules index 7c981a42b6..1500579638 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "ui/keycodemapdb"] path = ui/keycodemapdb url = git://git.qemu.org/keycodemapdb.git +[submodule "capstone"] + path = capstone + url = git://git.qemu.org/capstone.git diff --git a/capstone b/capstone new file mode 160000 index 0000000000..22ead3e0bf --- /dev/null +++ b/capstone @@ -0,0 +1 @@ +Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf diff --git a/configure b/configure index d06ad64058..9ab10b0261 100755 --- a/configure +++ b/configure @@ -1299,6 +1299,10 @@ for opt do ;; --enable-capstone) capstone="yes" ;; + --enable-capstone=git) capstone="git" + ;; + --enable-capstone=system) capstone="system" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -4419,18 +4423,49 @@ fi ########################################## # capstone -if test "$capstone" != no; then - if $pkg_config capstone; then - capstone=yes +case "$capstone" in + "" | yes) + if $pkg_config capstone; then + capstone=system + elif test -e "${source_path}/.git" ; then + capstone=git + elif test -e "${source_path}/capstone/Makefile" ; then + capstone=internal + elif test -z "$capstone" ; then + capstone=no + else + feature_not_found "capstone" "Install capstone devel or git submodule" + fi + ;; + + system) + if ! $pkg_config capstone; then + feature_not_found "capstone" "Install capstone devel" + fi + ;; +esac + +case "$capstone" in + git | internal) + if test "$capstone" = git; then + git_submodules="${git_submodules} capstone" + fi + mkdir -p capstone + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + LIBS="\$(BUILD_DIR)/capstone/libcapstone.a $LIBS" + ;; + + system) QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" LIBS="$($pkg_config --libs capstone) $LIBS" - else - if test "$capstone" = yes; then - feature_not_found capstone - fi - capstone=no - fi -fi + ;; + + no) + ;; + *) + error_exit "Unknown state for capstone: $capstone" + ;; +esac ########################################## # check if we have fdatasync @@ -6165,7 +6200,7 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi -if test "$capstone" = "yes" ; then +if test "$capstone" != "no" ; then echo "CONFIG_CAPSTONE=y" >> $config_host_mak fi @@ -6650,6 +6685,9 @@ done # for target in $targets if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi +if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then + echo "config-host.h: subdir-capstone" >> $config_host_mak +fi if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak