kernel/bpf/preload/Makefile was recently updated to have it install libbpf's headers locally instead of pulling them from tools/lib/bpf. But two items still need to be addressed. First, the local .gitignore file was not adjusted to ignore the files generated in the new kernel/bpf/preload/libbpf output directory. Second, the "clean-files" target is now incorrect. The old artefacts names were not removed from the target, while the new ones were added incorrectly. This is because "clean-files" expects names relative to $(obj), but we passed the absolute path instead. This results in the output and header-destination directories for libbpf (and their contents) not being removed from kernel/bpf/preload on "make clean" from the root of the repository. This commit fixes both issues. Note that $(userprogs) needs not be added to "clean-files", because the cleaning infrastructure already accounts for it. Cleaning the files properly also prevents make from printing the following message, for builds coming after a "make clean": "make[4]: Nothing to be done for 'install_headers'." v2: Simplify the "clean-files" target. Fixes: bf60791741d4 ("bpf: preload: Install libbpf headers when building") Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20211020094647.15564-1-quentin@isovalent.com
43 lines
1.2 KiB
Makefile
43 lines
1.2 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
LIBBPF_SRCS = $(srctree)/tools/lib/bpf/
|
|
LIBBPF_OUT = $(abspath $(obj))/libbpf
|
|
LIBBPF_A = $(LIBBPF_OUT)/libbpf.a
|
|
LIBBPF_DESTDIR = $(LIBBPF_OUT)
|
|
LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
|
|
|
|
# Although not in use by libbpf's Makefile, set $(O) so that the "dummy" test
|
|
# in tools/scripts/Makefile.include always succeeds when building the kernel
|
|
# with $(O) pointing to a relative path, as in "make O=build bindeb-pkg".
|
|
$(LIBBPF_A): | $(LIBBPF_OUT)
|
|
$(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ \
|
|
DESTDIR=$(LIBBPF_DESTDIR) prefix= \
|
|
$(LIBBPF_OUT)/libbpf.a install_headers
|
|
|
|
libbpf_hdrs: $(LIBBPF_A)
|
|
|
|
.PHONY: libbpf_hdrs
|
|
|
|
$(LIBBPF_OUT):
|
|
$(call msg,MKDIR,$@)
|
|
$(Q)mkdir -p $@
|
|
|
|
userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \
|
|
-I $(LIBBPF_INCLUDE) -Wno-unused-result
|
|
|
|
userprogs := bpf_preload_umd
|
|
|
|
clean-files := libbpf/
|
|
|
|
$(obj)/iterators/iterators.o: | libbpf_hdrs
|
|
|
|
bpf_preload_umd-objs := iterators/iterators.o
|
|
bpf_preload_umd-userldlibs := $(LIBBPF_A) -lelf -lz
|
|
|
|
$(obj)/bpf_preload_umd: $(LIBBPF_A)
|
|
|
|
$(obj)/bpf_preload_umd_blob.o: $(obj)/bpf_preload_umd
|
|
|
|
obj-$(CONFIG_BPF_PRELOAD_UMD) += bpf_preload.o
|
|
bpf_preload-objs += bpf_preload_kern.o bpf_preload_umd_blob.o
|