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: 830558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Rvj+FSHG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yN2c50vg3z9rxj for ; Thu, 26 Oct 2017 21:02:13 +1100 (AEDT) Received: from localhost ([::1]:51897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7ezL-0004AB-8R for incoming@patchwork.ozlabs.org; Thu, 26 Oct 2017 06:02:11 -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-Google-Smtp-Source: ABhQp+SdYZiNcIskB2iAFLdq858BbM7gtdQotvpX+IwD7QWrLGAj4X5Gl3U/JiJiTSN8b1wfsvr5iw== 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+incoming=patchwork.ozlabs.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 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