Merge tag 'for-5.8/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
[linux/fpc-iii.git] / tools / objtool / Makefile
blob7770edcda3a0d61e91c184d6ff64ef4e13d091e8
1 # SPDX-License-Identifier: GPL-2.0
2 include ../scripts/Makefile.include
3 include ../scripts/Makefile.arch
5 # always use the host compiler
6 ifneq ($(LLVM),)
7 HOSTAR ?= llvm-ar
8 HOSTCC ?= clang
9 HOSTLD ?= ld.lld
10 else
11 HOSTAR ?= ar
12 HOSTCC ?= gcc
13 HOSTLD ?= ld
14 endif
15 AR = $(HOSTAR)
16 CC = $(HOSTCC)
17 LD = $(HOSTLD)
19 ifeq ($(srctree),)
20 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
21 srctree := $(patsubst %/,%,$(dir $(srctree)))
22 endif
24 SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
25 LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/)
26 LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
28 OBJTOOL := $(OUTPUT)objtool
29 OBJTOOL_IN := $(OBJTOOL)-in.o
31 LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null)
32 LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
34 all: $(OBJTOOL)
36 INCLUDES := -I$(srctree)/tools/include \
37 -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
38 -I$(srctree)/tools/arch/$(SRCARCH)/include \
39 -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include
40 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
41 CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
42 LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
44 # Allow old libelf to be used:
45 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
46 CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
48 AWK = awk
50 SUBCMD_CHECK := n
51 SUBCMD_ORC := n
53 ifeq ($(SRCARCH),x86)
54 SUBCMD_CHECK := y
55 SUBCMD_ORC := y
56 endif
58 export SUBCMD_CHECK SUBCMD_ORC
59 export srctree OUTPUT CFLAGS SRCARCH AWK
60 include $(srctree)/tools/build/Makefile.include
62 $(OBJTOOL_IN): fixdep FORCE
63 @$(CONFIG_SHELL) ./sync-check.sh
64 @$(MAKE) $(build)=objtool
66 $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
67 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
70 $(LIBSUBCMD): fixdep FORCE
71 $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT)
73 clean:
74 $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
75 $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
76 $(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep
78 FORCE:
80 .PHONY: clean FORCE