From patchwork Sun Oct 22 00:46:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116624 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3190371qgn; Sat, 21 Oct 2017 17:56:41 -0700 (PDT) X-Received: by 10.55.120.194 with SMTP id t185mr12813505qkc.202.1508633801394; Sat, 21 Oct 2017 17:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633801; cv=none; d=google.com; s=arc-20160816; b=nU1C6pQyXg4MBZm69gz2i69jHD0vMDm2TgbLDoEfC9UI2Km8Dyg2uBtVVIp8z/wZum JOsHh3l7MfMJyarN7S2fbjoO4m2C/kkARp2hx8KCMSVwmyl1vMZ9cDLeNangFEX91qOg IUDVsqLDsr3Ay/glfMuMY/0exyMbsc6Vd9rX8uq8qhSrhLdHCWCJxwQaXeIDJGEIxVDH gLDGcLfWwRaGwjBsnTg/P5kG8UThn7WI6UJL9eo8+BQYma20aTkRoWg9aXOdVQfOu4Ps uOxn3x7c0VAXnGkJ66zzIkT8iFR2ZXkl+kLtCMTQPQdIeNdOBFXGSdxv2LRf+Xz5no3V rMgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+hVRL+bJLOVygj5VE2J7+XYckQ8VXrEnW8VFKOT4x/Q=; b=Ye2bhUM6QK9L7b6V4q58QdLGC6IA/BocQIRorjSCy6K03FVuZ+zSFiWZyvW8sqNGeI FuK2a12FdY6yy2n8F8E25Ygtj8MHfTisQHuu2aH1Y+QiX4LkEyzN3f5esAC7zmLxSARt 5OkvTab/JnxkukvmXj9NPXh5hJrJZBuVv2J3KRL4z62Ic1BOZ3HXmPiUA5we2ze6IAOR gbAGnYB/wRSSxXOzK3tbkEjn8/whUMQvQesOS8at9Xy6oIJj2QKpKKktVk/B6vSzf+ip CkTYbkGmV2nShUt7JLWYhK9YFxmvHvYGzxo3Zt5CaCspkjRetINqVWrKxpJWaMcZK4vf KOOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E8Oin8Vs; 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 b16si517301qkb.358.2017.10.21.17.56.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:56:41 -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=E8Oin8Vs; 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]:59660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64ZD-00017p-BC for patch@linaro.org; Sat, 21 Oct 2017 20:56:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Pc-0002Kg-FT for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64Pb-0008Re-4m for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:44 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:48324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64Pa-0008Qq-V2 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:43 -0400 Received: by mail-pg0-x242.google.com with SMTP id v78so9203814pgb.5 for ; Sat, 21 Oct 2017 17:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=+hVRL+bJLOVygj5VE2J7+XYckQ8VXrEnW8VFKOT4x/Q=; b=E8Oin8VsSWP/7hNhJNjnn1s+BiGmJdGwu+AVPJcqCSZKD9PUebEu6Qios2F5p1AbAB fYsO5qJfO/GXPkiyXkbylK64LM91Teq9vX/9wDC8jmWv6aVniWEin5iD3dpZu8jPmRhU CRoiSngC/vScrMjq5mTWz2Oe1eDjFq48GobhY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+hVRL+bJLOVygj5VE2J7+XYckQ8VXrEnW8VFKOT4x/Q=; b=A1wmHFQpeNkUOthZuBeYHgGXTChNKpg8S3MuO5SzsmssfH7uwdM/aotD9iMxb382zC wW1liJ0pi/2t5v66+2FJyIdSMzhNTupIzTMwrGXuyzLA+jBJCe+ZlrJHdSaHlhGpt4Nd AZNE+iGgYlM+xNwtQLvZ6FzIkJoWQ7QyfYzGPNOv609+TJmwAliwvJ0AyFnQSPdv1Zpu bHa5wFD6pj69eEUdsRM3vc9VzEjMjNIx2da89FllwRexnNpy1fBJNdU12yJECHfkrRwL g4L6cGpqlrWUrSH/KoxiO/Oj3wA9RO7OizpVjvIrvN7XVeTm4Oo035l04iTkv73xjqmW qDQA== X-Gm-Message-State: AMCzsaVsxu4YnXgcjzdnIe2NFgKPKedQImCod7XKkTZEzcaQigCD4rJx gpUztpKElHntFs+rhMgR42WrU4/tcTk= X-Google-Smtp-Source: ABhQp+Sb48dZQ0VNZYePb6fGamoeJzmAbQ4LGTYvL/Kmfb+LGKZy3Y61SIasnSgJBfuWxz0Eiw/R/g== X-Received: by 10.99.123.94 with SMTP id k30mr8158025pgn.33.1508633201655; Sat, 21 Oct 2017 17:46:41 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:21 -0700 Message-Id: <20171022004621.28372-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v7 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: , 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. Signed-off-by: Richard Henderson --- Makefile | 13 +++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 66 insertions(+), 11 deletions(-) create mode 160000 capstone -- 2.13.6 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/Makefile b/Makefile index 9372742f86..beecc85bee 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,19 @@ 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. +CAP_CFLAGS = $(subst -Werror,,$(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..a279481dbf --- /dev/null +++ b/capstone @@ -0,0 +1 @@ +Subproject commit a279481dbfd54bb1e2336d771e89978cc6d43176 diff --git a/configure b/configure index 26e5ce7787..2807569f9f 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