1include ../scripts/Makefile.include 2include ../scripts/Makefile.arch 3 4ifeq ($(ARCH),x86_64) 5ARCH := x86 6endif 7 8# always use the host compiler 9CC = gcc 10LD = ld 11AR = ar 12 13ifeq ($(srctree),) 14srctree := $(patsubst %/,%,$(dir $(shell pwd))) 15srctree := $(patsubst %/,%,$(dir $(srctree))) 16endif 17 18SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ 19LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(PWD)/) 20LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a 21 22OBJTOOL := $(OUTPUT)objtool 23OBJTOOL_IN := $(OBJTOOL)-in.o 24 25all: $(OBJTOOL) 26 27INCLUDES := -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi 28CFLAGS += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) 29LDFLAGS += -lelf $(LIBSUBCMD) 30 31# Allow old libelf to be used: 32elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) 33CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) 34 35AWK = awk 36export srctree OUTPUT CFLAGS SRCARCH AWK 37include $(srctree)/tools/build/Makefile.include 38 39$(OBJTOOL_IN): fixdep FORCE 40 @$(MAKE) $(build)=objtool 41 42# Busybox's diff doesn't have -I, avoid warning in that case 43# 44$(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) 45 @(diff -I 2>&1 | grep -q 'option requires an argument' && \ 46 test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \ 47 diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \ 48 diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \ 49 diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \ 50 diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \ 51 diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \ 52 diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \ 53 diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \ 54 || echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true 55 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ 56 57 58$(LIBSUBCMD): fixdep FORCE 59 $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) 60 61clean: 62 $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) 63 $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete 64 $(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c $(OUTPUT)fixdep 65 66FORCE: 67 68.PHONY: clean FORCE 69