From patchwork Thu Oct 26 10:00:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117185 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp566627qgn; Thu, 26 Oct 2017 03:03:09 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SWuqHHk45a5UlpU0LqR2yEAm+4Tx6+wCJBzfxzwqi2pcC/SlTUMIxKARF5vrze048MCE7u X-Received: by 10.129.128.71 with SMTP id q68mr15512938ywf.154.1509012189546; Thu, 26 Oct 2017 03:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509012189; cv=none; d=google.com; s=arc-20160816; b=su0dRa/LP/RIXD9RqYrBlmelZt25e3PNjAkENHF1YIyWjJBwrnmm0DSyi1nBij3l0+ nlKTAP3nLW15pjXymoN+UvurBrjH8dvp4+jr11S+huOY3KXyRCxsx0oRh2MsGGXf3EWN t+5t5xaupG+MRF8moHlP/pZGrE1o34yGhFeimpGRGjSDP8RUAfXSfHzd4jOk0ULipgIE 8W6bXZl8aBVGsUczHOSowDB0g8KkJrBqGi0AWzrU9QKL3co3nM40K2vK2WU6s6P2+Zd0 f0NbhUrTWnMLcWE51leKr+M352aPYtvPENef7zJ3jypDwV5AmPsNbJIExpBF3qa4Jy4T U4vw== 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=gpzCHuawwYVRcny8Bbw9sSxps0rL3rkyF5JmHGhx4UA=; b=dk1O1xDMXHRuYkSvA3tCTS9HQVZMQ6VnPz8LNekoYWQCwWZAJ3qRqzd73IET/U0yxs k2C8NOAD4lMMHe/6FDgi51R8g2r4LP9VUS2ddUah+PklrypZjv5eU2a9JZo9jDLg3bbW Y+sQg1+OAVskeFTq8d2YYnT4yxBGikZyYFz9nGEK4iqwh2bDPG8aG3/pDaWRgpNaVJU4 Up7pMvospjdieQYhp30dO/TclKsyI+phWa4xxTPfz3Oc3qRbKnVDyh1ZDUwPLRRGFCh6 yiTc2riNoCA3zxMs4rFFXILR5eKgjIoszX0u4eC862R1lvcmRxs1iefJVowagnKmL2Vp dmDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Rvj+FSHG; 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 y136si778996ywd.409.2017.10.26.03.03.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 26 Oct 2017 03:03:09 -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=Rvj+FSHG; 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]:51900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7f0H-0004jZ-4e for patch@linaro.org; Thu, 26 Oct 2017 06:03:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7exx-0003Pb-9D for qemu-devel@nongnu.org; Thu, 26 Oct 2017 06:00:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7exr-0000n7-42 for qemu-devel@nongnu.org; Thu, 26 Oct 2017 06:00:45 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:51554) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7exq-0000mY-Q6 for qemu-devel@nongnu.org; Thu, 26 Oct 2017 06:00:39 -0400 Received: by mail-wr0-x243.google.com with SMTP id j15so2596740wre.8 for ; Thu, 26 Oct 2017 03:00:38 -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=gpzCHuawwYVRcny8Bbw9sSxps0rL3rkyF5JmHGhx4UA=; b=Rvj+FSHGMMkWw/FQM5z+SWaJnMNjeLPathZQflx8pdmm0eyDSR42KkdrkoQqKbON7Y rb/BryTUmFSXHvQ61k1UBFiZ1aagMfnQSU1w8KUmBvYTRLz1qhJGRAimcPpc3nRsxP/u VPgzKxuVNbxCmftfLwZw/biN+Zrwr/MoTh1ZY= 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=gpzCHuawwYVRcny8Bbw9sSxps0rL3rkyF5JmHGhx4UA=; b=ARmj7e5cCgOcZLNJVOALmjdXvz7/P77qKOtGdQ5LEm81Lc6KzbCAynO9lio8O3V3fO OTWKgLPjHnF/xP9O6Pucl58ClPzDXGXr750n1dHs+Bb8X0SQXe1yfcbWDitHfUUcvoLc BOZ1NmlofVbSPqQb9NErCwB1qFlSW9KTbXwqZ2tWMTOfhTRodQDXImBSL/nlNyKe9oKj CzpXT6Y3tQIlWMPsKHc1LEr9qq4HAvOEPMpVxwhEOqsHKFHO0ACZZr9hZbuCwthfwfrW pHg1mzurVqQGJj2OfcQZfyWTtCJgNVk87rcQGyjyFTKXdFkG5hfnWAGZzR+scx6SCmsu NCXA== X-Gm-Message-State: AMCzsaUMNva9fjjsXghPgk5+S0I2LWZCEGmnG47vFRZrVQAr9Mc59Dxh AHgM7n2Uf49qub7akKbZrFSRIYWKfpU= X-Received: by 10.223.165.67 with SMTP id j3mr4539182wrb.271.1509012037430; Thu, 26 Oct 2017 03:00:37 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.124]) by smtp.gmail.com with ESMTPSA id v8sm4516959wrg.80.2017.10.26.03.00.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Oct 2017 03:00:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 26 Oct 2017 12:00:31 +0200 Message-Id: <20171026100031.19042-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171026100031.19042-1-richard.henderson@linaro.org> References: <20171026100031.19042-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:c0c::243 Subject: [Qemu-devel] [PULL v2 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 | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 76 insertions(+), 11 deletions(-) create mode 160000 capstone -- 2.13.6 diff --git a/Makefile b/Makefile index 9372742f86..ec73acfa9a 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)) + $(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..23eddc2f50 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,54 @@ 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" + if test "$mingw32" = "yes"; then + LIBCAPSTONE=capstone.lib + else + LIBCAPSTONE=libcapstone.a + fi + LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $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 +6205,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 +6690,12 @@ 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 -n "$LIBCAPSTONE"; then + echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak +fi if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak