From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: berrange@redhat.com, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH v6 9/9] disas: Add capstone as submodule
Date: Thu, 19 Oct 2017 08:51:46 -0700 [thread overview]
Message-ID: <20171019155146.30434-10-richard.henderson@linaro.org> (raw)
In-Reply-To: <20171019155146.30434-1-richard.henderson@linaro.org>
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 <richard.henderson@linaro.org>
---
Makefile | 13 +++++++++++++
.gitmodules | 3 +++
capstone | 1 +
configure | 59 +++++++++++++++++++++++++++++++++++++++++++++++------------
4 files changed, 64 insertions(+), 12 deletions(-)
create mode 160000 capstone
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
--
2.13.6
next prev parent reply other threads:[~2017-10-19 15:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 15:51 [Qemu-devel] [PATCH v6 0/9] Support the Capstone disassembler Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 1/9] target/i386: Convert to disas_set_info hook Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 2/9] target/ppc: " Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 3/9] disas: Remove unused flags arguments Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 4/9] disas: Support the Capstone disassembler library Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 5/9] i386: Support Capstone in disas_set_info Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 6/9] arm: " Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 7/9] ppc: " Richard Henderson
2017-10-19 15:51 ` [Qemu-devel] [PATCH v6 8/9] disas: Remove monitor_disas_is_physical Richard Henderson
2017-10-19 15:51 ` Richard Henderson [this message]
2017-10-19 15:54 ` [Qemu-devel] [PATCH v6 0/9] Support the Capstone disassembler Peter Maydell
2017-10-19 16:03 ` Daniel P. Berrange
2017-10-19 16:58 ` no-reply
2017-10-21 15:59 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171019155146.30434-10-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=berrange@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).