objtool: Make unreachable annotation inline asms explicitly volatile
[linux-2.6-block.git] / tools / objtool / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
442f04c3 2include ../scripts/Makefile.include
630e7a29 3include ../scripts/Makefile.arch
442f04c3 4
442f04c3
JP
5ifeq ($(ARCH),x86_64)
6ARCH := x86
7endif
442f04c3 8
c1d45c3a
JP
9# always use the host compiler
10CC = gcc
11LD = ld
12AR = ar
13
442f04c3 14ifeq ($(srctree),)
e19b7cee 15srctree := $(patsubst %/,%,$(dir $(CURDIR)))
442f04c3
JP
16srctree := $(patsubst %/,%,$(dir $(srctree)))
17endif
18
c1d45c3a 19SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
e19b7cee 20LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/)
c1d45c3a 21LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
442f04c3
JP
22
23OBJTOOL := $(OUTPUT)objtool
24OBJTOOL_IN := $(OBJTOOL)-in.o
25
26all: $(OBJTOOL)
27
0cf6eb60 28INCLUDES := -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi
21ec3bf6
JP
29WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
30CFLAGS += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
442f04c3
JP
31LDFLAGS += -lelf $(LIBSUBCMD)
32
2e51f262
JB
33# Allow old libelf to be used:
34elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
35CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
36
442f04c3 37AWK = awk
60cbdf5d 38export srctree OUTPUT CFLAGS SRCARCH AWK
442f04c3
JP
39include $(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 66clean:
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
71FORCE:
72
73.PHONY: clean FORCE