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