Commit e219c499 authored by Richard Henderson's avatar Richard Henderson
Browse files

disas: Add capstone as submodule



Do not require the submodule, but use it if present.  Allow the
command-line to override system or git submodule either way.

Tested-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
parent b8d87208
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+15 −0
Original line number Diff line number Diff line
@@ -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))

capstone @ 22ead3e0

Original line number Diff line number Diff line
Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf
+57 −11
Original line number Diff line number Diff line
@@ -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
case "$capstone" in
  "" | yes)
    if $pkg_config capstone; then
    capstone=yes
    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
    LIBS="$($pkg_config --libs capstone) $LIBS"
      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
    if test "$capstone" = yes; then
      feature_not_found capstone
      feature_not_found "capstone" "Install capstone devel or git submodule"
    fi
    capstone=no
    ;;

  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"
    ;;

  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