• Quentin Monnet's avatar
    samples/bpf: Install libbpf headers when building · 3f7a3318
    Quentin Monnet authored
    API headers from libbpf should not be accessed directly from the source
    directory. Instead, they should be exported with "make install_headers".
    Make sure that samples/bpf/Makefile installs the headers properly when
    building.
    
    The object compiled from and exported by libbpf are now placed into a
    subdirectory of sample/bpf/ instead of remaining in tools/lib/bpf/. We
    attempt to remove this directory on "make clean". However, the "clean"
    target re-enters the samples/bpf/ directory from the root of the
    repository ("$(MAKE) -C ../../ M=$(CURDIR) clean"), in such a way that
    $(srctree) and $(src) are not defined, making it impossible to use
    $(LIBBPF_OUTPUT) and $(LIBBPF_DESTDIR) in the recipe. So we only attempt
    to clean $(CURDIR)/libbpf, which is the default value.
    
    Add a dependency on libbpf's headers for the $(TRACE_HELPERS).
    
    We also change the output directory for bpftool, to place the generated
    objects under samples/bpf/bpftool/ instead of building in bpftool's
    directory directly. Doing so, we make sure bpftool reuses the libbpf
    library previously compiled and installed.
    Signed-off-by: default avatarQuentin Monnet <quentin@isovalent.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211007194438.34443-10-quentin@isovalent.com
    3f7a3318
Makefile 15.2 KB