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 # Overrides for the prepare step libraries. 21 HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC) 21 HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \ 22 CROSS_COMPILE="" EXTRA_CFLAG 22 CROSS_COMPILE="" EXTRA_CFLAGS="$(HOSTCFLAGS)" 23 23 24 RM ?= rm 24 RM ?= rm 25 HOSTCC ?= gcc 25 HOSTCC ?= gcc 26 HOSTLD ?= ld 26 HOSTLD ?= ld 27 HOSTAR ?= ar 27 HOSTAR ?= ar 28 CROSS_COMPILE = 28 CROSS_COMPILE = 29 29 30 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ 30 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ 31 31 32 LIBBPF_SRC := $(srctree)/tools/lib/bpf/ 32 LIBBPF_SRC := $(srctree)/tools/lib/bpf/ 33 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ 33 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ 34 34 35 BPFOBJ := $(OUTPUT)/libbpf/libbpf.a 35 BPFOBJ := $(OUTPUT)/libbpf/libbpf.a 36 LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ 36 LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ 37 SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a 37 SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a 38 SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ 38 SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ 39 39 40 LIBBPF_DESTDIR := $(LIBBPF_OUT) 40 LIBBPF_DESTDIR := $(LIBBPF_OUT) 41 LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include 41 LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include 42 42 43 SUBCMD_DESTDIR := $(SUBCMD_OUT) 43 SUBCMD_DESTDIR := $(SUBCMD_OUT) 44 SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include 44 SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include 45 45 46 BINARY := $(OUTPUT)/resolve_btfids 46 BINARY := $(OUTPUT)/resolve_btfids 47 BINARY_IN := $(BINARY)-in.o 47 BINARY_IN := $(BINARY)-in.o 48 48 49 all: $(BINARY) 49 all: $(BINARY) 50 50 51 prepare: $(BPFOBJ) $(SUBCMDOBJ) 51 prepare: $(BPFOBJ) $(SUBCMDOBJ) 52 52 53 $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): 53 $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): 54 $(call msg,MKDIR,,$@) 54 $(call msg,MKDIR,,$@) 55 $(Q)mkdir -p $(@) 55 $(Q)mkdir -p $(@) 56 56 57 $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubc 57 $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd 58 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$( 58 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \ 59 DESTDIR=$(SUBCMD_DESTDIR) 59 DESTDIR=$(SUBCMD_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \ 60 $(abspath $@) install_head 60 $(abspath $@) install_headers 61 61 62 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(L 62 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) 63 $(Q)$(MAKE) $(submake_extras) -C $(LIB 63 $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ 64 DESTDIR=$(LIBBPF_DESTDIR) 64 DESTDIR=$(LIBBPF_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \ 65 $(abspath $@) install_head 65 $(abspath $@) install_headers 66 66 67 LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libe 67 LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null) 68 LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libe 68 LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf) 69 69 70 HOSTCFLAGS_resolve_btfids += -g \ 70 HOSTCFLAGS_resolve_btfids += -g \ 71 -I$(srctree)/tools/include \ 71 -I$(srctree)/tools/include \ 72 -I$(srctree)/tools/include/uapi \ 72 -I$(srctree)/tools/include/uapi \ 73 -I$(LIBBPF_INCLUDE) \ 73 -I$(LIBBPF_INCLUDE) \ 74 -I$(SUBCMD_INCLUDE) \ 74 -I$(SUBCMD_INCLUDE) \ 75 $(LIBELF_FLAGS) 75 $(LIBELF_FLAGS) 76 76 77 LIBS = $(LIBELF_LIBS) -lz 77 LIBS = $(LIBELF_LIBS) -lz 78 78 79 export srctree OUTPUT HOSTCFLAGS_resolve_btfid 79 export srctree OUTPUT HOSTCFLAGS_resolve_btfids Q HOSTCC HOSTLD HOSTAR 80 include $(srctree)/tools/build/Makefile.includ 80 include $(srctree)/tools/build/Makefile.include 81 81 82 $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) 82 $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) 83 $(Q)$(MAKE) $(build)=resolve_btfids 83 $(Q)$(MAKE) $(build)=resolve_btfids 84 84 85 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) 85 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) 86 $(call msg,LINK,$@) 86 $(call msg,LINK,$@) 87 $(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HO 87 $(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HOSTLDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS) 88 88 89 clean_objects := $(wildcard $(OUTPUT)/*.o 89 clean_objects := $(wildcard $(OUTPUT)/*.o \ 90 $(OUTPUT)/.*.o.cmd 90 $(OUTPUT)/.*.o.cmd \ 91 $(OUTPUT)/.*.o.d 91 $(OUTPUT)/.*.o.d \ 92 $(LIBBPF_OUT) 92 $(LIBBPF_OUT) \ 93 $(LIBBPF_DESTDIR) 93 $(LIBBPF_DESTDIR) \ 94 $(SUBCMD_OUT) 94 $(SUBCMD_OUT) \ 95 $(SUBCMD_DESTDIR) 95 $(SUBCMD_DESTDIR) \ 96 $(OUTPUT)/resolve_ 96 $(OUTPUT)/resolve_btfids) 97 97 98 ifneq ($(clean_objects),) 98 ifneq ($(clean_objects),) 99 clean: fixdep-clean 99 clean: fixdep-clean 100 $(call msg,CLEAN,$(BINARY)) 100 $(call msg,CLEAN,$(BINARY)) 101 $(Q)$(RM) -rf $(clean_objects) 101 $(Q)$(RM) -rf $(clean_objects) 102 else 102 else 103 clean: 103 clean: 104 endif 104 endif 105 105 106 tags: 106 tags: 107 $(call msg,GEN,,tags) 107 $(call msg,GEN,,tags) 108 $(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_ 108 $(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC) 109 109 110 FORCE: 110 FORCE: 111 111 112 .PHONY: all FORCE clean tags prepare 112 .PHONY: all FORCE clean tags prepare
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.