• Q
    bpftool: Install libbpf headers instead of including the dir · f012ade1
    Quentin Monnet 提交于
    Bpftool relies on libbpf, therefore it relies on a number of headers
    from the library and must be linked against the library. The Makefile
    for bpftool exposes these objects by adding tools/lib as an include
    directory ("-I$(srctree)/tools/lib"). This is a working solution, but
    this is not the cleanest one. The risk is to involuntarily include
    objects that are not intended to be exposed by the libbpf.
    
    The headers needed to compile bpftool should in fact be "installed" from
    libbpf, with its "install_headers" Makefile target. In addition, there
    is one header which is internal to the library and not supposed to be
    used by external applications, but that bpftool uses anyway.
    
    Adjust the Makefile in order to install the header files properly before
    compiling bpftool. Also copy the additional internal header file
    (nlattr.h), but call it out explicitly. Build (and install headers) in a
    subdirectory under bpftool/ instead of tools/lib/bpf/. When descending
    from a parent Makefile, this is configurable by setting the OUTPUT,
    LIBBPF_OUTPUT and LIBBPF_DESTDIR variables.
    
    Also adjust the Makefile for BPF selftests, so as to reuse the (host)
    libbpf compiled earlier and to avoid compiling a separate version of the
    library just for bpftool.
    Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
    Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
    Acked-by: NAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211007194438.34443-4-quentin@isovalent.com
    f012ade1
Makefile 7.2 KB