Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / tools / objtool / Makefile
CommitLineData
442f04c3
JP
1include ../scripts/Makefile.include
2
3ifndef ($(ARCH))
4ARCH ?= $(shell uname -m)
5ifeq ($(ARCH),x86_64)
6ARCH := x86
7endif
8endif
9
c1d45c3a
JP
10# always use the host compiler
11CC = gcc
12LD = ld
13AR = ar
14
442f04c3
JP
15ifeq ($(srctree),)
16srctree := $(patsubst %/,%,$(dir $(shell pwd)))
17srctree := $(patsubst %/,%,$(dir $(srctree)))
18endif
19
c1d45c3a
JP
20SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
21LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(PWD)/)
22LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
442f04c3
JP
23
24OBJTOOL := $(OUTPUT)objtool
25OBJTOOL_IN := $(OBJTOOL)-in.o
26
27all: $(OBJTOOL)
28
29INCLUDES := -I$(srctree)/tools/include
d435fb5e 30CFLAGS += -Wall -Werror $(EXTRA_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
JP
37AWK = awk
38export srctree OUTPUT CFLAGS ARCH AWK
39include $(srctree)/tools/build/Makefile.include
40
41$(OBJTOOL_IN): fixdep FORCE
42 @$(MAKE) $(build)=objtool
43
44$(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
45 @(test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
46 diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
47 diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
48 diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
49 diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
50 diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
51 diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
52 diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
53 || echo "Warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true
54 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
55
56
57$(LIBSUBCMD): fixdep FORCE
c1d45c3a 58 $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT)
442f04c3 59
c1d45c3a 60clean:
442f04c3
JP
61 $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
62 $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
63 $(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c $(OUTPUT)fixdep
64
65FORCE:
66
67.PHONY: clean FORCE
This page took 0.052497 seconds and 5 git commands to generate.