Merge tag 'powerpc-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux/fpc-iii.git] / tools / objtool / Makefile
blob5cdb19036d7f71a1128a3e2333a483074c68e2eb
1 # SPDX-License-Identifier: GPL-2.0
2 include ../scripts/Makefile.include
3 include ../scripts/Makefile.arch
5 # always use the host compiler
6 AR = $(HOSTAR)
7 CC = $(HOSTCC)
8 LD = $(HOSTLD)
10 ifeq ($(srctree),)
11 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
12 srctree := $(patsubst %/,%,$(dir $(srctree)))
13 endif
15 SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
16 LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/)
17 LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
19 OBJTOOL := $(OUTPUT)objtool
20 OBJTOOL_IN := $(OBJTOOL)-in.o
22 LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null)
23 LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
25 all: $(OBJTOOL)
27 INCLUDES := -I$(srctree)/tools/include \
28 -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
29 -I$(srctree)/tools/arch/$(SRCARCH)/include \
30 -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include
31 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs
32 CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
33 LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
35 # Allow old libelf to be used:
36 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
37 CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
39 AWK = awk
41 SUBCMD_CHECK := n
42 SUBCMD_ORC := n
44 ifeq ($(SRCARCH),x86)
45 SUBCMD_CHECK := y
46 SUBCMD_ORC := y
47 endif
49 ifeq ($(SUBCMD_ORC),y)
50 CFLAGS += -DINSN_USE_ORC
51 endif
53 export SUBCMD_CHECK SUBCMD_ORC
54 export srctree OUTPUT CFLAGS SRCARCH AWK
55 include $(srctree)/tools/build/Makefile.include
57 $(OBJTOOL_IN): fixdep FORCE
58 @$(CONFIG_SHELL) ./sync-check.sh
59 @$(MAKE) $(build)=objtool
61 $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
62 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
65 $(LIBSUBCMD): fixdep FORCE
66 $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT)
68 clean:
69 $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
70 $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
71 $(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep
73 FORCE:
75 .PHONY: clean FORCE