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