Revision | e219c499e9f5d4fa0e25dc07682f75531ee84d86 (tree) |
---|---|
Time | 2017-10-26 18:56:20 |
Author | Richard Henderson <richard.henderson@lina...> |
Commiter | Richard Henderson |
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: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
@@ -37,3 +37,6 @@ | ||
37 | 37 | [submodule "ui/keycodemapdb"] |
38 | 38 | path = ui/keycodemapdb |
39 | 39 | url = git://git.qemu.org/keycodemapdb.git |
40 | +[submodule "capstone"] | |
41 | + path = capstone | |
42 | + url = git://git.qemu.org/capstone.git |
@@ -383,6 +383,21 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests | ||
383 | 383 | dtc/%: .git-submodule-status |
384 | 384 | mkdir -p $@ |
385 | 385 | |
386 | +# Overriding CFLAGS causes us to lose defines added in the sub-makefile. | |
387 | +# Not overriding CFLAGS leads to mis-matches between compilation modes. | |
388 | +# Therefore we replicate some of the logic in the sub-makefile. | |
389 | +# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't; | |
390 | +# no need to annoy QEMU developers with such things. | |
391 | +CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS)) | |
392 | +CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM | |
393 | +CAP_CFLAGS += -DCAPSTONE_HAS_ARM | |
394 | +CAP_CFLAGS += -DCAPSTONE_HAS_ARM64 | |
395 | +CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC | |
396 | +CAP_CFLAGS += -DCAPSTONE_HAS_X86 | |
397 | + | |
398 | +subdir-capstone: .git-submodule-status | |
399 | + $(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)) | |
400 | + | |
386 | 401 | $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ |
387 | 402 | $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) |
388 | 403 |
@@ -0,0 +1 @@ | ||
1 | +Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf |
@@ -1299,6 +1299,10 @@ for opt do | ||
1299 | 1299 | ;; |
1300 | 1300 | --enable-capstone) capstone="yes" |
1301 | 1301 | ;; |
1302 | + --enable-capstone=git) capstone="git" | |
1303 | + ;; | |
1304 | + --enable-capstone=system) capstone="system" | |
1305 | + ;; | |
1302 | 1306 | *) |
1303 | 1307 | echo "ERROR: unknown option $opt" |
1304 | 1308 | echo "Try '$0 --help' for more information" |
@@ -4419,18 +4423,54 @@ fi | ||
4419 | 4423 | ########################################## |
4420 | 4424 | # capstone |
4421 | 4425 | |
4422 | -if test "$capstone" != no; then | |
4423 | - if $pkg_config capstone; then | |
4424 | - capstone=yes | |
4426 | +case "$capstone" in | |
4427 | + "" | yes) | |
4428 | + if $pkg_config capstone; then | |
4429 | + capstone=system | |
4430 | + elif test -e "${source_path}/.git" ; then | |
4431 | + capstone=git | |
4432 | + elif test -e "${source_path}/capstone/Makefile" ; then | |
4433 | + capstone=internal | |
4434 | + elif test -z "$capstone" ; then | |
4435 | + capstone=no | |
4436 | + else | |
4437 | + feature_not_found "capstone" "Install capstone devel or git submodule" | |
4438 | + fi | |
4439 | + ;; | |
4440 | + | |
4441 | + system) | |
4442 | + if ! $pkg_config capstone; then | |
4443 | + feature_not_found "capstone" "Install capstone devel" | |
4444 | + fi | |
4445 | + ;; | |
4446 | +esac | |
4447 | + | |
4448 | +case "$capstone" in | |
4449 | + git | internal) | |
4450 | + if test "$capstone" = git; then | |
4451 | + git_submodules="${git_submodules} capstone" | |
4452 | + fi | |
4453 | + mkdir -p capstone | |
4454 | + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" | |
4455 | + if test "$mingw32" = "yes"; then | |
4456 | + LIBCAPSTONE=capstone.lib | |
4457 | + else | |
4458 | + LIBCAPSTONE=libcapstone.a | |
4459 | + fi | |
4460 | + LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS" | |
4461 | + ;; | |
4462 | + | |
4463 | + system) | |
4425 | 4464 | QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" |
4426 | 4465 | LIBS="$($pkg_config --libs capstone) $LIBS" |
4427 | - else | |
4428 | - if test "$capstone" = yes; then | |
4429 | - feature_not_found capstone | |
4430 | - fi | |
4431 | - capstone=no | |
4432 | - fi | |
4433 | -fi | |
4466 | + ;; | |
4467 | + | |
4468 | + no) | |
4469 | + ;; | |
4470 | + *) | |
4471 | + error_exit "Unknown state for capstone: $capstone" | |
4472 | + ;; | |
4473 | +esac | |
4434 | 4474 | |
4435 | 4475 | ########################################## |
4436 | 4476 | # check if we have fdatasync |
@@ -6165,7 +6205,7 @@ fi | ||
6165 | 6205 | if test "$ivshmem" = "yes" ; then |
6166 | 6206 | echo "CONFIG_IVSHMEM=y" >> $config_host_mak |
6167 | 6207 | fi |
6168 | -if test "$capstone" = "yes" ; then | |
6208 | +if test "$capstone" != "no" ; then | |
6169 | 6209 | echo "CONFIG_CAPSTONE=y" >> $config_host_mak |
6170 | 6210 | fi |
6171 | 6211 |
@@ -6650,6 +6690,12 @@ done # for target in $targets | ||
6650 | 6690 | if [ "$dtc_internal" = "yes" ]; then |
6651 | 6691 | echo "config-host.h: subdir-dtc" >> $config_host_mak |
6652 | 6692 | fi |
6693 | +if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then | |
6694 | + echo "config-host.h: subdir-capstone" >> $config_host_mak | |
6695 | +fi | |
6696 | +if test -n "$LIBCAPSTONE"; then | |
6697 | + echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak | |
6698 | +fi | |
6653 | 6699 | |
6654 | 6700 | if test "$numa" = "yes"; then |
6655 | 6701 | echo "CONFIG_NUMA=y" >> $config_host_mak |