From a22e4331e7c9a7377e63dcd3de151e82f9b5ddbf Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Wed, 11 Mar 2026 12:55:25 +0100 Subject: [PATCH] configure: Rework HAVE_CAPSTONE #define Autotools and the current build system define HAVE_* macros only when the corresponding feature is available, leaving them undefined otherwise. HAVE_CAPSTONE is an exception, align it with this convention to make the build system more consistent and slightly simpler. Change-Id: I0b71743a687802b905e3fe1e17cad815a7febb14 Signed-off-by: Marc Schink Reviewed-on: https://review.openocd.org/c/openocd/+/9540 Tested-by: jenkins Reviewed-by: Antonio Borneo --- configure.ac | 4 ---- src/target/a64_disassembler.c | 2 +- src/target/arm_disassembler.c | 4 ++-- src/target/arm_disassembler.h | 2 +- src/target/armv4_5.c | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 39f5e074e..0d5f0eb35 100644 --- a/configure.ac +++ b/configure.ac @@ -527,10 +527,6 @@ AS_IF([test "x$enable_capstone" != xno], [ ]) ]) -AS_IF([test "x$enable_capstone" == xno], [ - AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.]) -]) - for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[ use_hidapi=yes diff --git a/src/target/a64_disassembler.c b/src/target/a64_disassembler.c index ca3d3ea7a..3ae5d9c27 100644 --- a/src/target/a64_disassembler.c +++ b/src/target/a64_disassembler.c @@ -13,7 +13,7 @@ #include "target.h" #include "a64_disassembler.h" -#if HAVE_CAPSTONE +#ifdef HAVE_CAPSTONE #include diff --git a/src/target/arm_disassembler.c b/src/target/arm_disassembler.c index 6dea19f93..e07843afd 100644 --- a/src/target/arm_disassembler.c +++ b/src/target/arm_disassembler.c @@ -15,7 +15,7 @@ #include "arm_disassembler.h" #include -#if HAVE_CAPSTONE +#ifdef HAVE_CAPSTONE #include #endif @@ -3019,7 +3019,7 @@ int arm_access_size(struct arm_instruction *instruction) } } -#if HAVE_CAPSTONE +#ifdef HAVE_CAPSTONE static void print_opcode(struct command_invocation *cmd, const cs_insn *insn) { uint32_t opcode = 0; diff --git a/src/target/arm_disassembler.h b/src/target/arm_disassembler.h index 8317da997..34df0f1f0 100644 --- a/src/target/arm_disassembler.h +++ b/src/target/arm_disassembler.h @@ -187,7 +187,7 @@ int arm_evaluate_opcode(uint32_t opcode, uint32_t address, int thumb_evaluate_opcode(uint16_t opcode, uint32_t address, struct arm_instruction *instruction); int arm_access_size(struct arm_instruction *instruction); -#if HAVE_CAPSTONE +#ifdef HAVE_CAPSTONE int arm_disassemble(struct command_invocation *cmd, struct target *target, target_addr_t address, size_t count, bool thumb_mode); #endif diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 4f61c58e2..d9816d033 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -952,7 +952,7 @@ COMMAND_HANDLER(handle_arm_core_state_command) COMMAND_HANDLER(handle_arm_disassemble_command) { -#if HAVE_CAPSTONE +#ifdef HAVE_CAPSTONE struct target *target = get_current_target(CMD_CTX); if (!target) {