Backport in f49907472f ("sync: latest libbpf changes from kernel")
missed to bump Makefile's EXTRAVERSION to 3.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
LIBBPF_VERSION is already used to generate libbpf.pc file but was not
actuall set.
Set it same way it's done in kernel tree. Version is in sync with
version script for DSO.
Before:
% grep Version src/libbpf.pc
Version:
After:
% grep Version src/libbpf.pc
Version: 0.0.2
Fixes: 93bc1d0 ("makefile: sync generate pkg-config file for libbpf")
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Version script was synced from kernel tree but not enabled in Makefile.
Enable it same way it's done in kernel tree.
% readelf -s --wide src/libbpf.so | grep -Eo '[^ ]+@LIBBPF_.*' | \
cut -d@ -f 3 | sort | uniq -c
121 LIBBPF_0.0.1
29 LIBBPF_0.0.2
Signed-off-by: Andrey Ignatov <rdna@fb.com>
OBJDIR was not specified for libbpf.pc. It works by default since
default value of OBJDIR is current directory, but breaks as soon as
OBJDIR is set to some other directory:
% OBJDIR=build DESTDIR=root make install
...
ar rcs build/libbpf.a build/bpf.o build/btf.o build/libbpf.o
build/libbpf_errno.o build/netlink.o build/nlattr.o build/str_error.o
build/libbpf_probes.o build/bpf_prog_linfo.o build/xsk.o
cc -shared -lelf build/bpf.o build/btf.o build/libbpf.o build/libbpf_errno.o
build/netlink.o build/nlattr.o build/str_error.o build/libbpf_probes.o
build/bpf_prog_linfo.o build/xsk.o -o build/libbpf.so
make: *** No rule to make target `libbpf.pc', needed by `all'. Stop.
Fix it.
Signed-off-by: Andrey Ignatov <rdna@fb.com>
The vast majority of use cases want a shared library, so to be more
user and packager friendly invert the makefile logic and always build
both static and shared libraries by default.
Add BUILD_STATIC_ONLY variable for the corner cases where only a static
library is needed
Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
Distro tools like dpkg-buildpackage use the preprocessor flags to pass
important flags, like hardening features. Pass CPPFLAGS to CC.
Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
This patch makes sure we build AF_XDP-related code as part of libbpf. This
also required copying few uapi/linux headers and adding few used definitions
in include headers.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
bpf_common.h is hardly ever changed so it was not installed together
with other uapi headers. Some environments are still prefer to be
consistent and install all relevant uapi headers so add bpf_common.h to
uapi headers.
Signed-off-by: Andrey Ignatov <rdna@fb.com>
* Sync from bpf-next
Sync the following commits from bpf-next:
commit ab9e08482122 ("libbpf: Per-symbol visibility for DSO")
commit c034a177d3c8 ("bpf: bpftool, add flag to allow non-compat map definitions")
Signed-off-by: Andrey Ignatov <rdna@fb.com>
* Use -fvisibility=hidden by default for DSO
This is Makefile part of:
commit ab9e08482122 ("libbpf: Per-symbol visibility for DSO")
See original commit for details.
Introduce multiple improvements to Makefile to make the build more
flexible and support install:
* Support overriding CFLAGS by user but keep required flags in place.
ALL_FLAGS is used in Makefile as recommended in [1].
* Add additional BUILD_SHARED flag to build dynamically linked flavor of
the library. If the flag is set, -fPIC is also passed to make it
possible to build .so.
* Support building in a separate directory provided by OBJDIR variable.
* Add multiple install targets. By default the library itself and libbpf
headers are installed (install target). UAPI headers can be optionally
installed by user.
* All installation paths, including PREFIX, library and include
directories can be overridden. UAPI can be made different from include
directory for libbpf headers. That makes it possible to keep latest
<linux/bpf.h> in a place that doesn't conflict with the one installed
e.g. by kernel-headers package and use it in user's build system.
* Support DESTDIR (see [2]).
* Support overriding LDFLAGS.
* Use utilities such as rm directly as recommended in [3].
* Use compiler and related programs (such as ar) via make variables as
recommended in [3].
* In clean rule remove all possible build artifacts not to rely on passed
options (e.g. if build was done w/ BUILD_SHARED, but clean w/o it).
* Document new build options in README.
[1] https://www.gnu.org/software/make/manual/html_node/Command-Variables.html#Command-Variables
[2] https://www.gnu.org/prep/standards/html_node/DESTDIR.html
[3] https://www.gnu.org/software/make/manual/html_node/Utilities-in-Makefiles.html#Utilities-in-Makefiles
Signed-off-by: Andrey Ignatov <rdna@fb.com>