1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 include ../scripts/Makefile.include 2 include ../scripts/Makefile.include 3 include ../scripts/Makefile.arch 3 include ../scripts/Makefile.arch 4 4 >> 5 # always use the host compiler >> 6 AR = $(HOSTAR) >> 7 CC = $(HOSTCC) >> 8 LD = $(HOSTLD) >> 9 5 ifeq ($(srctree),) 10 ifeq ($(srctree),) 6 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 11 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 7 srctree := $(patsubst %/,%,$(dir $(srctree))) 12 srctree := $(patsubst %/,%,$(dir $(srctree))) 8 endif 13 endif 9 14 10 LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ !! 15 SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ 11 ifneq ($(OUTPUT),) !! 16 LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/) 12 LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libs !! 17 LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a 13 else << 14 LIBSUBCMD_OUTPUT = $(CURDIR)/libsubcmd << 15 endif << 16 LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a << 17 18 18 OBJTOOL := $(OUTPUT)objtool 19 OBJTOOL := $(OUTPUT)objtool 19 OBJTOOL_IN := $(OBJTOOL)-in.o 20 OBJTOOL_IN := $(OBJTOOL)-in.o 20 21 21 LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libe !! 22 LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null) 22 LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libe !! 23 LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) 23 24 24 all: $(OBJTOOL) 25 all: $(OBJTOOL) 25 26 26 INCLUDES := -I$(srctree)/tools/include \ 27 INCLUDES := -I$(srctree)/tools/include \ 27 -I$(srctree)/tools/arch/$(HOSTARCH 28 -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ 28 -I$(srctree)/tools/arch/$(SRCARCH) 29 -I$(srctree)/tools/arch/$(SRCARCH)/include \ 29 -I$(srctree)/tools/objtool/include !! 30 -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include 30 -I$(srctree)/tools/objtool/arch/$( << 31 -I$(LIBSUBCMD_OUTPUT)/include << 32 # Note, EXTRA_WARNINGS here was determined for << 33 # is passed here to match a legacy behavior. << 34 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-defa 31 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs 35 OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD !! 32 CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) 36 OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) !! 33 LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) 37 34 38 # Allow old libelf to be used: 35 # Allow old libelf to be used: 39 elfshdr := $(shell echo '$(pound)include <libe !! 36 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) 40 OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_US !! 37 CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) 41 << 42 # Always want host compilation. << 43 HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD) << 44 38 45 AWK = awk 39 AWK = awk 46 MKDIR = mkdir << 47 << 48 ifeq ($(V),1) << 49 Q = << 50 else << 51 Q = @ << 52 endif << 53 40 54 BUILD_ORC := n !! 41 SUBCMD_CHECK := n >> 42 SUBCMD_ORC := n 55 43 56 ifeq ($(SRCARCH),x86) 44 ifeq ($(SRCARCH),x86) 57 BUILD_ORC := y !! 45 SUBCMD_CHECK := y >> 46 SUBCMD_ORC := y 58 endif 47 endif 59 48 60 ifeq ($(SRCARCH),loongarch) !! 49 ifeq ($(SUBCMD_ORC),y) 61 BUILD_ORC := y !! 50 CFLAGS += -DINSN_USE_ORC 62 endif 51 endif 63 52 64 export BUILD_ORC !! 53 export SUBCMD_CHECK SUBCMD_ORC 65 export srctree OUTPUT CFLAGS SRCARCH AWK 54 export srctree OUTPUT CFLAGS SRCARCH AWK 66 include $(srctree)/tools/build/Makefile.includ 55 include $(srctree)/tools/build/Makefile.include 67 56 68 $(OBJTOOL_IN): fixdep $(LIBSUBCMD) FORCE !! 57 $(OBJTOOL_IN): fixdep FORCE 69 $(Q)$(CONFIG_SHELL) ./sync-check.sh !! 58 @$(CONFIG_SHELL) ./sync-check.sh 70 $(Q)$(MAKE) $(build)=objtool $(HOST_OV !! 59 @$(MAKE) $(build)=objtool 71 LDFLAGS="$(OBJTOOL_LDFLAGS)" << 72 << 73 60 74 $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) 61 $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) 75 $(QUIET_LINK)$(HOSTCC) $(OBJTOOL_IN) $ !! 62 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ 76 << 77 << 78 $(LIBSUBCMD_OUTPUT): << 79 $(Q)$(MKDIR) -p $@ << 80 63 81 $(LIBSUBCMD): fixdep $(LIBSUBCMD_OUTPUT) FORCE << 82 $(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LI << 83 DESTDIR=$(LIBSUBCMD_OUTPUT) pr << 84 $(HOST_OVERRIDES) EXTRA_CFLAGS << 85 $@ install_headers << 86 64 87 $(LIBSUBCMD)-clean: !! 65 $(LIBSUBCMD): fixdep FORCE 88 $(call QUIET_CLEAN, libsubcmd) !! 66 $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) 89 $(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT) << 90 67 91 clean: $(LIBSUBCMD)-clean !! 68 clean: 92 $(call QUIET_CLEAN, objtool) $(RM) $(O 69 $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) 93 $(Q)find $(OUTPUT) -name '*.o' -delete 70 $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete 94 $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-t !! 71 $(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep 95 72 96 FORCE: 73 FORCE: 97 74 98 .PHONY: clean FORCE 75 .PHONY: clean FORCE
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.