Commit | Line | Data |
---|---|---|
442f04c3 | 1 | include ../scripts/Makefile.include |
630e7a29 | 2 | include ../scripts/Makefile.arch |
442f04c3 | 3 | |
442f04c3 JP |
4 | ifeq ($(ARCH),x86_64) |
5 | ARCH := x86 | |
6 | endif | |
442f04c3 | 7 | |
c1d45c3a JP |
8 | # always use the host compiler |
9 | CC = gcc | |
10 | LD = ld | |
11 | AR = ar | |
12 | ||
442f04c3 JP |
13 | ifeq ($(srctree),) |
14 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) | |
15 | srctree := $(patsubst %/,%,$(dir $(srctree))) | |
16 | endif | |
17 | ||
c1d45c3a JP |
18 | SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ |
19 | LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(PWD)/) | |
20 | LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a | |
442f04c3 JP |
21 | |
22 | OBJTOOL := $(OUTPUT)objtool | |
23 | OBJTOOL_IN := $(OBJTOOL)-in.o | |
24 | ||
25 | all: $(OBJTOOL) | |
26 | ||
0cf6eb60 | 27 | INCLUDES := -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi |
d435fb5e | 28 | CFLAGS += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) |
442f04c3 JP |
29 | LDFLAGS += -lelf $(LIBSUBCMD) |
30 | ||
2e51f262 JB |
31 | # Allow old libelf to be used: |
32 | elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) | |
33 | CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) | |
34 | ||
442f04c3 | 35 | AWK = awk |
60cbdf5d | 36 | export srctree OUTPUT CFLAGS SRCARCH AWK |
442f04c3 JP |
37 | include $(srctree)/tools/build/Makefile.include |
38 | ||
39 | $(OBJTOOL_IN): fixdep FORCE | |
40 | @$(MAKE) $(build)=objtool | |
41 | ||
1a4bf285 ACM |
42 | # Busybox's diff doesn't have -I, avoid warning in that case |
43 | # | |
442f04c3 | 44 | $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) |
1a4bf285 ACM |
45 | @(diff -I 2>&1 | grep -q 'option requires an argument' && \ |
46 | test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \ | |
442f04c3 JP |
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) \ | |
2af04ea5 | 54 | || echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true |
442f04c3 JP |
55 | $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ |
56 | ||
57 | ||
58 | $(LIBSUBCMD): fixdep FORCE | |
c1d45c3a | 59 | $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) |
442f04c3 | 60 | |
c1d45c3a | 61 | clean: |
442f04c3 JP |
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 | ||
66 | FORCE: | |
67 | ||
68 | .PHONY: clean FORCE |