From patchwork Thu Oct 19 15:51:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116410 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp650536qgn; Thu, 19 Oct 2017 08:57:31 -0700 (PDT) X-Received: by 10.237.62.71 with SMTP id m7mr2738622qtf.269.1508428651647; Thu, 19 Oct 2017 08:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428651; cv=none; d=google.com; s=arc-20160816; b=kr+n6PiyDpHYUs/B6hWAwNDv6IVfTy/QWd1ThmCWXcvg72KYcR7yGBZgnqSUOxuZ5s GN/499mEGewV0Qw/LQ4SSgjjZbApIE5gFkno3ENFJMRMoxushaIJmfNMXtaaa2CMDqyK wzEMwj2qLfAe2+lBXmHoA4DBT0LYNrQFAflyZjotWKph8EsxjMqqD2NOL+ENdpVCtV0Z z4KKdnrN25fawpI0CkOaDnT3B/sKwIndixiZ+hP1Z2Cl0GXBRZ25XGa4bdRfKmV0dc3V aWsSA/NW193Y1TDSeDfoeglsAiEitt5KUuxUHXZpVsZwpQaxArJJLPFLZL8SaPY1BrSY rA/Q== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SgAc7iOmz6YqrtoDtWcnmz7PTxG614/3TlJEs5rkdnI=; b=lGfLaIPn07o8ncf9Uq2MInJGef5finVHQiTn4GOYg+rQsRcNAEqHXXsO9NevWKuIIs gl4T1Q8dVYFoV7P5cDY1ijacrbg2dDvpPwequhIyNP9JezTnbDqVZwA/tSVs5YQ4O25x /2jYR7OclgpB1yVxwYaQPCCicNAACzcHhuTPOJWH1euM+BeYmsAtYsFHHZBvoXEEkSZA wpyUvoZzVQm0SCZrWAmHt2NZfQhRaFekyIRh/8WBQNtyoX47TtjvDjYj2BJxuRJw9oop n008Zj6rWz7CfJQKgbazg/F9LIHDiZQDkhJ/Rw9y3mwsc6mDerVb+1d/Um2rxI53yPjV kObw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BCCX32b/; 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 l25si3255774qki.290.2017.10.19.08.57.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:57:31 -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=BCCX32b/; 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]:49849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DCL-0002fn-GO for patch@linaro.org; Thu, 19 Oct 2017 11:57:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D7A-0007Kf-BD for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D75-0000KJ-Od for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:08 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:47240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D75-0000Jt-Iv for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:03 -0400 Received: by mail-pf0-x244.google.com with SMTP id z11so6865707pfk.4 for ; Thu, 19 Oct 2017 08:52:03 -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; bh=SgAc7iOmz6YqrtoDtWcnmz7PTxG614/3TlJEs5rkdnI=; b=BCCX32b/2Okfp09A1hVGBV6/XAQT4z0iDeTq0/nANCQTgC3iOtUme1jISpn+7snHrj tLFy+aymv/YZNldsVnFNgimBghc40ScpXQVyJc881Mxc5X2BG5cstz6Onkz/Fk7d1hS+ 0M+47Y3LtyRPw8PJiWeNPlhhIbBtRSYb0QuV4= 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; bh=SgAc7iOmz6YqrtoDtWcnmz7PTxG614/3TlJEs5rkdnI=; b=frjnTwl1Iv14xzavxmo0tfSpP/LZouYs99Zt6XRk1cmVvR59lMHz2InOXHdru9BRvx jTEui/oy50fXft7hLGlAxuRXGA8LkS431W75XbhuHTizwX77Y+ePNl4kNOtdcyE4E35P xZgB6wfL5EPqnU2J/F7kn+kTn6xN+lLkMnRIdTJhbtzAVMLQ9mkjf+tTQjQc95VZdflS qtbkQ92chTXPCfraG1ahQNf4WKqjuKKAgEEVMqNo23zZ2mIBk7wn7b9aJ1LdJgVB8qED QNib/RM4jLognR1jrHlS/qwJ5tC8zat7ZIJoeqROejl7ffiiS74ICyZuhfusTmwMJtYc jCbg== X-Gm-Message-State: AMCzsaUldeOrPPiQcYtaqPuhtcePY0xt9LcMion8q4cGTk99ZRVyIZHd 35iYuj+uh2mdJWNHW7b9lfPx5Mf5T8s= X-Google-Smtp-Source: ABhQp+QyKp8rBmeW9yiqC9genjU08EefpbBuVAudOqdudzbmOcp0AqnQG+UqmwraZwx+2xdWo+Kf/w== X-Received: by 10.99.146.76 with SMTP id s12mr1779827pgn.354.1508428322275; Thu, 19 Oct 2017 08:52:02 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id 76sm27971114pfq.4.2017.10.19.08.52.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:52:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:46 -0700 Message-Id: <20171019155146.30434-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171019155146.30434-1-richard.henderson@linaro.org> References: <20171019155146.30434-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:c00::244 Subject: [Qemu-devel] [PATCH v6 9/9] 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: kraxel@redhat.com 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 | 59 +++++++++++++++++++++++++++++++++++++++++++++++------------ 4 files changed, 64 insertions(+), 12 deletions(-) create mode 160000 capstone -- 2.13.6 diff --git a/Makefile b/Makefile index 062745f3ba..c6436e2442 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,19 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests dtc/%: 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..892bfba2d2 100755 --- a/configure +++ b/configure @@ -375,7 +375,7 @@ opengl_dmabuf="no" cpuid_h="no" avx2_opt="no" zlib="yes" -capstone="" +capstone="yes" lzo="" snappy="" bzip2="" @@ -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,46 @@ 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 + 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 + capstone_internal=yes + 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 +6197,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 +6682,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