lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Mar 2019 23:02:15 +0000
From:   Luca Boccassi <bluca@...ian.org>
To:     Stanislav Fomichev <sdf@...ichev.me>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next] tools/bpf: generate pkg-config file for libbpf

On Tue, 2019-03-19 at 14:23 -0700, Stanislav Fomichev wrote:
> On 03/19, Luca Boccassi wrote:
> > Generate a libbpf.pc file at build time so that users can rely
> > on pkg-config to find the library, its CFLAGS and LDFLAGS.
> > 
> > Signed-off-by: Luca Boccassi <bluca@...ian.org>
> > ---
> >  tools/lib/bpf/.gitignore         |  1 +
> >  tools/lib/bpf/Makefile           | 18 +++++++++++++++---
> >  tools/lib/bpf/libbpf.pc.template | 11 +++++++++++
> >  3 files changed, 27 insertions(+), 3 deletions(-)
> >  create mode 100644 tools/lib/bpf/libbpf.pc.template
> > 
> > diff --git a/tools/lib/bpf/.gitignore b/tools/lib/bpf/.gitignore
> > index 4db74758c674..7d9e182a1f51 100644
> > --- a/tools/lib/bpf/.gitignore
> > +++ b/tools/lib/bpf/.gitignore
> > @@ -1,3 +1,4 @@
> >  libbpf_version.h
> > +libbpf.pc
> >  FEATURE-DUMP.libbpf
> >  test_libbpf
> > diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
> > index a05c43468bd0..542c64e2a6d9 100644
> > --- a/tools/lib/bpf/Makefile
> > +++ b/tools/lib/bpf/Makefile
> > @@ -80,6 +80,7 @@ libdir_SQ = $(subst ','\'',$(libdir))
> >  libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
> >  
> >  LIB_FILE = libbpf.a libbpf.so
> > +PC_FILE = libbpf.pc
> >  
> >  VERSION		= $(BPF_VERSION)
> >  PATCHLEVEL	= $(BPF_PATCHLEVEL)
> > @@ -137,7 +138,7 @@ GLOBAL_SYM_COUNT = $(shell readelf -s --wide
> > $(BPF_IN) | \
> >  VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so
> > | \
> >  			      grep -Eo '[^ ]+@...BPF_' | cut -d@
> > -f1 | sort -u | wc -l)
> >  
> > -CMD_TARGETS = $(LIB_FILE)
> > +CMD_TARGETS = $(LIB_FILE) $(PC_FILE)
> >  
> >  CXX_TEST_TARGET = $(OUTPUT)test_libbpf
> >  
> > @@ -179,6 +180,12 @@ $(OUTPUT)libbpf.a: $(BPF_IN)
> >  $(OUTPUT)test_libbpf: test_libbpf.cpp $(OUTPUT)libbpf.a
> >  	$(QUIET_LINK)$(CXX) $(INCLUDES) $^ -lelf -o $@
> >  
> > +$(OUTPUT)libbpf.pc:
> > +	$(QUIET_LINK)sed -e "s|@...FIX@|$(prefix)|" \
> 
> Maybe QUIET_GEN instead? Or QUIET_INSTALL
> (tools/lib/traceevent/Makefile)?

Changed to QUIET_GEN in v2.

> > +		-e "s|@...DIR@|$(libdir_SQ)|" \
> > +		-e "s|@...SION@|$(shell make --no-print-directory
> > -sC ../../.. kernelversion)|" \
> 
> Make it its own variable, like we do in bpftool?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tr
> ee/tools/bpf/bpftool/Makefile#n26

Done in v2.

> Also, I wonder what would happen in the case of out-of-tree libbpf:
> https://github.com/libbpf/libbpf
> 
> Should there be some fallback?

That tree looks like it's autosynced from the kernel tree, isn't it?
Then it will just pick up the change and start generating the pc file
as well, won't it?

-- 
Kind regards,
Luca Boccassi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ