#
# To support disassembly, objtool needs libopcodes which is provided
-# with libbdf (binutils-dev or binutils-devel package).
+# with libbfd (binutils-dev or binutils-devel package).
#
-FEATURE_USER = .objtool
-FEATURE_TESTS = libbfd disassembler-init-styled
-FEATURE_DISPLAY =
-include $(srctree)/tools/build/Makefile.feature
+# We check using HOSTCC directly rather than the shared feature framework
+# because objtool is a host tool that links against host libraries.
+#
+HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \
+ $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y)
-ifeq ($(feature-disassembler-init-styled), 1)
- OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED
-endif
+# Styled disassembler support requires binutils >= 2.39
+HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \
+ $(HOSTCC) -E -xc - 2>/dev/null | grep -q disassembler_style && echo y)
BUILD_DISAS := n
-ifeq ($(feature-libbfd),1)
+ifeq ($(HAVE_LIBOPCODES),y)
BUILD_DISAS := y
- OBJTOOL_CFLAGS += -DDISAS -DPACKAGE="objtool"
+ OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"'
OBJTOOL_LDFLAGS += -lopcodes
+ifeq ($(HAVE_DISASM_STYLED),y)
+ OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED
+endif
endif
export BUILD_DISAS