1# SPDX-License-Identifier: GPL-2.0 2 3LIBBPF_SRCS = $(srctree)/tools/lib/bpf/ 4LIBBPF_OUT = $(abspath $(obj))/libbpf 5LIBBPF_A = $(LIBBPF_OUT)/libbpf.a 6LIBBPF_DESTDIR = $(LIBBPF_OUT) 7LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include 8 9# Although not in use by libbpf's Makefile, set $(O) so that the "dummy" test 10# in tools/scripts/Makefile.include always succeeds when building the kernel 11# with $(O) pointing to a relative path, as in "make O=build bindeb-pkg". 12$(LIBBPF_A): | $(LIBBPF_OUT) 13 $(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ \ 14 DESTDIR=$(LIBBPF_DESTDIR) prefix= \ 15 $(LIBBPF_OUT)/libbpf.a install_headers 16 17libbpf_hdrs: $(LIBBPF_A) 18 19.PHONY: libbpf_hdrs 20 21$(LIBBPF_OUT): 22 $(call msg,MKDIR,$@) 23 $(Q)mkdir -p $@ 24 25userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \ 26 -I $(LIBBPF_INCLUDE) -Wno-unused-result 27 28userprogs := bpf_preload_umd 29 30clean-files := $(userprogs) bpf_helper_defs.h FEATURE-DUMP.libbpf staticobjs/ feature/ 31clean-files += $(LIBBPF_OUT) $(LIBBPF_DESTDIR) 32 33$(obj)/iterators/iterators.o: | libbpf_hdrs 34 35bpf_preload_umd-objs := iterators/iterators.o 36bpf_preload_umd-userldlibs := $(LIBBPF_A) -lelf -lz 37 38$(obj)/bpf_preload_umd: $(LIBBPF_A) 39 40$(obj)/bpf_preload_umd_blob.o: $(obj)/bpf_preload_umd 41 42obj-$(CONFIG_BPF_PRELOAD_UMD) += bpf_preload.o 43bpf_preload-objs += bpf_preload_kern.o bpf_preload_umd_blob.o 44