1 # SPDX-License-Identifier: GPL-2.0-only 1 # SPDX-License-Identifier: GPL-2.0-only 2 include ../../scripts/Makefile.include 2 include ../../scripts/Makefile.include 3 include ../../scripts/Makefile.arch 3 include ../../scripts/Makefile.arch 4 4 5 srctree := $(abspath $(CURDIR)/../../../) 5 srctree := $(abspath $(CURDIR)/../../../) 6 6 7 ifeq ($(V),1) 7 ifeq ($(V),1) 8 Q = 8 Q = 9 msg = 9 msg = 10 else 10 else 11 Q = @ 11 Q = @ 12 ifeq ($(silent),1) 12 ifeq ($(silent),1) 13 msg = 13 msg = 14 else 14 else 15 msg = @printf ' %-8s %s%s\n' "$(1)" "$(no 15 msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))"; 16 endif 16 endif 17 MAKEFLAGS=--no-print-directory 17 MAKEFLAGS=--no-print-directory 18 endif 18 endif 19 19 20 # Overrides for the prepare step libraries. !! 20 # always use the host compiler 21 HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC) !! 21 AR = $(HOSTAR) 22 CROSS_COMPILE="" EXTRA_CFLAG !! 22 CC = $(HOSTCC) 23 !! 23 LD = $(HOSTLD) >> 24 ARCH = $(HOSTARCH) 24 RM ?= rm 25 RM ?= rm 25 HOSTCC ?= gcc << 26 HOSTLD ?= ld << 27 HOSTAR ?= ar << 28 CROSS_COMPILE = << 29 26 30 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ 27 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ 31 28 32 LIBBPF_SRC := $(srctree)/tools/lib/bpf/ 29 LIBBPF_SRC := $(srctree)/tools/lib/bpf/ 33 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ 30 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ 34 31 35 BPFOBJ := $(OUTPUT)/libbpf/libbpf.a 32 BPFOBJ := $(OUTPUT)/libbpf/libbpf.a 36 LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ << 37 SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a 33 SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a 38 SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ << 39 << 40 LIBBPF_DESTDIR := $(LIBBPF_OUT) << 41 LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include << 42 << 43 SUBCMD_DESTDIR := $(SUBCMD_OUT) << 44 SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include << 45 34 46 BINARY := $(OUTPUT)/resolve_btfids 35 BINARY := $(OUTPUT)/resolve_btfids 47 BINARY_IN := $(BINARY)-in.o 36 BINARY_IN := $(BINARY)-in.o 48 37 49 all: $(BINARY) 38 all: $(BINARY) 50 39 51 prepare: $(BPFOBJ) $(SUBCMDOBJ) !! 40 $(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd: 52 << 53 $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): << 54 $(call msg,MKDIR,,$@) 41 $(call msg,MKDIR,,$@) 55 $(Q)mkdir -p $(@) 42 $(Q)mkdir -p $(@) 56 43 57 $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubc 44 $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd 58 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$( !! 45 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) 59 DESTDIR=$(SUBCMD_DESTDIR) << 60 $(abspath $@) install_head << 61 << 62 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(L << 63 $(Q)$(MAKE) $(submake_extras) -C $(LIB << 64 DESTDIR=$(LIBBPF_DESTDIR) << 65 $(abspath $@) install_head << 66 46 67 LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libe !! 47 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf 68 LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libe !! 48 $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) 69 49 70 HOSTCFLAGS_resolve_btfids += -g \ !! 50 CFLAGS := -g \ 71 -I$(srctree)/tools/include \ 51 -I$(srctree)/tools/include \ 72 -I$(srctree)/tools/include/uapi \ 52 -I$(srctree)/tools/include/uapi \ 73 -I$(LIBBPF_INCLUDE) \ !! 53 -I$(LIBBPF_SRC) \ 74 -I$(SUBCMD_INCLUDE) \ !! 54 -I$(SUBCMD_SRC) 75 $(LIBELF_FLAGS) << 76 55 77 LIBS = $(LIBELF_LIBS) -lz !! 56 LIBS = -lelf -lz 78 57 79 export srctree OUTPUT HOSTCFLAGS_resolve_btfid !! 58 export srctree OUTPUT CFLAGS Q 80 include $(srctree)/tools/build/Makefile.includ 59 include $(srctree)/tools/build/Makefile.include 81 60 82 $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) !! 61 $(BINARY_IN): fixdep FORCE | $(OUTPUT) 83 $(Q)$(MAKE) $(build)=resolve_btfids 62 $(Q)$(MAKE) $(build)=resolve_btfids 84 63 85 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) 64 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) 86 $(call msg,LINK,$@) 65 $(call msg,LINK,$@) 87 $(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HO !! 66 $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS) 88 67 89 clean_objects := $(wildcard $(OUTPUT)/*.o 68 clean_objects := $(wildcard $(OUTPUT)/*.o \ 90 $(OUTPUT)/.*.o.cmd 69 $(OUTPUT)/.*.o.cmd \ 91 $(OUTPUT)/.*.o.d 70 $(OUTPUT)/.*.o.d \ 92 $(LIBBPF_OUT) !! 71 $(OUTPUT)/libbpf \ 93 $(LIBBPF_DESTDIR) !! 72 $(OUTPUT)/libsubcmd \ 94 $(SUBCMD_OUT) << 95 $(SUBCMD_DESTDIR) << 96 $(OUTPUT)/resolve_ 73 $(OUTPUT)/resolve_btfids) 97 74 98 ifneq ($(clean_objects),) 75 ifneq ($(clean_objects),) 99 clean: fixdep-clean 76 clean: fixdep-clean 100 $(call msg,CLEAN,$(BINARY)) 77 $(call msg,CLEAN,$(BINARY)) 101 $(Q)$(RM) -rf $(clean_objects) 78 $(Q)$(RM) -rf $(clean_objects) 102 else 79 else 103 clean: 80 clean: 104 endif 81 endif 105 82 106 tags: 83 tags: 107 $(call msg,GEN,,tags) 84 $(call msg,GEN,,tags) 108 $(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_ 85 $(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC) 109 86 110 FORCE: 87 FORCE: 111 88 112 .PHONY: all FORCE clean tags prepare !! 89 .PHONY: all FORCE clean tags
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.