Generate and install libbpf.pc

Backport patch from bpf-next and install libbpf.pc in libbpf-dev
This commit is contained in:
Luca Boccassi 2019-03-28 16:44:07 +00:00
parent 1acfe734b7
commit 5a39ad2910
4 changed files with 90 additions and 0 deletions

4
debian/changelog vendored
View File

@ -803,6 +803,10 @@ linux (4.19.34-1) UNRELEASED; urgency=medium
[ Stefan Fritsch ] [ Stefan Fritsch ]
* [armhf] Enable SND_SOC_SPDIF for Cubietruck (Closes: #884562) * [armhf] Enable SND_SOC_SPDIF for Cubietruck (Closes: #884562)
[ Luca Boccassi ]
* libbpf-dev: generate pkg-config file for libbpf by backporting
libbpf-generate-pkg-config.patch from bpf-next.
-- Ben Hutchings <ben@decadent.org.uk> Mon, 18 Mar 2019 22:50:08 +0000 -- Ben Hutchings <ben@decadent.org.uk> Mon, 18 Mar 2019 22:50:08 +0000
linux (4.19.28-2) unstable; urgency=medium linux (4.19.28-2) unstable; urgency=medium

View File

@ -1,3 +1,4 @@
usr/include/bpf usr/include/bpf
usr/lib/*/libbpf.a usr/lib/*/libbpf.a
usr/lib/*/libbpf.so usr/lib/*/libbpf.so
usr/lib/*/pkgconfig/*

View File

@ -0,0 +1,84 @@
Author: Luca Boccassi <bluca@debian.org>
Description: generate pkg-config file for libbpf
Generate a libbpf.pc file at build time so that users can rely
on pkg-config to find the library, its CFLAGS and LDFLAGS.
Origin: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=dd399ac9e343c7573c47d6820e4a23013c54749d
Applied-Upstream: yes
--- a/tools/lib/bpf/.gitignore
+++ b/tools/lib/bpf/.gitignore
@@ -1,2 +1,3 @@
libbpf_version.h
+libbpf.pc
FEATURE-DUMP.libbpf
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -93,6 +93,7 @@
LIBBPF_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion)
LIB_FILE = libbpf.a libbpf.so.$(LIBBPF_VERSION)
+PC_FILE = libbpf.pc
OBJ = $@
N =
@@ -136,8 +137,9 @@
BPF_IN := $(OUTPUT)libbpf-in.o
LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE))
+PC_FILE := $(addprefix $(OUTPUT),$(PC_FILE))
-CMD_TARGETS = $(LIB_FILE)
+CMD_TARGETS = $(LIB_FILE) $(PC_FILE)
TARGETS = $(CMD_TARGETS)
@@ -166,6 +168,12 @@
$(OUTPUT)libbpf.a: $(BPF_IN)
$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
+$(OUTPUT)libbpf.pc:
+ $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
+ -e "s|@LIBDIR@|$(libdir_SQ)|" \
+ -e "s|@VERSION@|$(LIBBPF_VERSION)|" \
+ < libbpf.pc.template > $@
+
define do_install
if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
@@ -184,7 +192,12 @@
$(call do_install,libbpf.h,$(prefix)/include/bpf,644);
$(call do_install,btf.h,$(prefix)/include/bpf,644);
-install: install_lib
+install_pkgconfig: $(PC_FILE)
+ $(call QUIET_INSTALL, $(PC_FILE)) \
+ $(call do_install,$(PC_FILE),$(libdir_SQ)/pkgconfig,644)
+
+
+install: install_lib install_pkgconfig
### Cleaning rules
@@ -193,7 +206,7 @@
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
clean:
- $(call QUIET_CLEAN, libbpf) $(RM) *.o *~ $(TARGETS) *.a *.so .*.d .*.cmd \
+ $(call QUIET_CLEAN, libbpf) $(RM) *.o *~ $(TARGETS) *.a *.so .*.d .*.cmd *.pc \
$(RM) LIBBPF-CFLAGS
$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
--- /dev/null
+++ b/tools/lib/bpf/libbpf.pc.template
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libbpf
+Description: BPF library
+Version: @VERSION@
+Libs: -L${libdir} -lbpf
+Requires.private: libelf
+Cflags: -I${includedir}

View File

@ -163,6 +163,7 @@ bugfix/x86/tools-x86_energy_perf_policy-fix-uninitialized-varia.patch
bugfix/x86/tools-turbostat-Add-checks-for-failure-of-fgets-and-.patch bugfix/x86/tools-turbostat-Add-checks-for-failure-of-fgets-and-.patch
bugfix/all/libbpf-add-soname-to-shared-object.patch bugfix/all/libbpf-add-soname-to-shared-object.patch
bugfix/all/libbpf-link-shared-object-with-libelf.patch bugfix/all/libbpf-link-shared-object-with-libelf.patch
bugfix/all/libbpf-generate-pkg-config.patch
# wireless: Disable regulatory.db direct loading (until we sort out signing) # wireless: Disable regulatory.db direct loading (until we sort out signing)
debian/wireless-disable-regulatory.db-direct-loading.patch debian/wireless-disable-regulatory.db-direct-loading.patch