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