From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B9C6C43381 for ; Tue, 19 Mar 2019 21:23:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5A9F20850 for ; Tue, 19 Mar 2019 21:23:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=fomichev-me.20150623.gappssmtp.com header.i=@fomichev-me.20150623.gappssmtp.com header.b="GLwca3IE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbfCSVXH (ORCPT ); Tue, 19 Mar 2019 17:23:07 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43093 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbfCSVXH (ORCPT ); Tue, 19 Mar 2019 17:23:07 -0400 Received: by mail-pg1-f194.google.com with SMTP id l11so75567pgq.10 for ; Tue, 19 Mar 2019 14:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=reahbtRFUgHbL74cVvOu7UPS4B1MkTvYKykRRfzSfi0=; b=GLwca3IEtMIkZqYadrqgpDthq3CZ5qi+bPmfBp7SK+vbQoaKZ74m6pmEhlLr2hyyTq NDoYkkF6tJKJEIMJmf7W1oqrX7itWpAJ8DSCmK7SDWjdvUUZGl1X6nn3pqqnCouhfEUv p6MY96ogkbTjJqweXwQbynsqPxNO2lBxJDNr8lc1FLoINt9R67njHXhLSOOQ0zut2KWG Ddv2hjFTfppANTAdU4tMS9v/d89CxWWgORbUANs6wDXmBBllEjn44Cc/CdmwfNSwa3Vo ceqK6MVizhhqPKsLcYpoaBj3FLaroopgC6CK1IMuq9ydshL6qsOuJVFDxhbH7iU7guob 0i9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=reahbtRFUgHbL74cVvOu7UPS4B1MkTvYKykRRfzSfi0=; b=nU1EgjQun+bI1Z1H8eLYVzQwrVO7oVJqqkPYsEgubcE8VwJN4lrVhUM1KIYKGgOftU wv70FEEs45Umt58eXbPjUGQKaj4Qz3yDrfdj+PPAIgG5K/gzHu0dqN0OhNubF/oRoc2F W9zjnIqwQu46raMkBI9IwAbYZdXsIYhdjkKyT3iHJqvEMaXskx/swsxYKC3nC9Qi0WIN 8ybuzumVj+tm7ojwmAkwnk5GGIyxKhaF8G0l1KyyNwFWf6dwlHzAb2HnhoWJVee4BjPC oTgA/hjHzYuAyygoAj6cQpGkaf/lXFj4EDg/QcmMiPeL9YuD0Pxmg7kBSVhFaJBbYLKp QCkA== X-Gm-Message-State: APjAAAU2cN95LFhNYbC+WxbL/LJUNiUcAJDNYEgnof2+I6lJa0KettQU fqZHNIpiu3X8/NACsL4C0GmOFQ== X-Google-Smtp-Source: APXvYqz9gPkWJJn1nZqlwpwM/mV1I6PaA3JKxcLawIGUwPVdqtwI3/NRaI7Bc1NEJywRyuoJ88XroA== X-Received: by 2002:a63:3244:: with SMTP id y65mr3802929pgy.417.1553030585957; Tue, 19 Mar 2019 14:23:05 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id 185sm8643537pfd.128.2019.03.19.14.23.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 14:23:04 -0700 (PDT) Date: Tue, 19 Mar 2019 14:23:03 -0700 From: Stanislav Fomichev To: Luca Boccassi Cc: netdev@vger.kernel.org Subject: Re: [PATCH bpf-next] tools/bpf: generate pkg-config file for libbpf Message-ID: <20190319212303.GE7431@mini-arch.hsd1.ca.comcast.net> References: <20190319210639.6282-1-bluca@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190319210639.6282-1-bluca@debian.org> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 > --- > 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 '[^ ]+@LIBBPF_' | 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|@PREFIX@|$(prefix)|" \ Maybe QUIET_GEN instead? Or QUIET_INSTALL (tools/lib/traceevent/Makefile)? > + -e "s|@LIBDIR@|$(libdir_SQ)|" \ > + -e "s|@VERSION@|$(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/tree/tools/bpf/bpftool/Makefile#n26 Also, I wonder what would happen in the case of out-of-tree libbpf: https://github.com/libbpf/libbpf Should there be some fallback? > + < $@.template > $@ > + > check: check_abi > > check_abi: $(OUTPUT)libbpf.so > @@ -208,7 +215,12 @@ install_headers: > $(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 > > @@ -218,7 +230,7 @@ config-clean: > > clean: > $(call QUIET_CLEAN, libbpf) $(RM) $(TARGETS) $(CXX_TEST_TARGET) \ > - *.o *~ *.a *.so .*.d .*.cmd LIBBPF-CFLAGS > + *.o *~ *.a *.so .*.d .*.cmd *.pc LIBBPF-CFLAGS > $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf > > > diff --git a/tools/lib/bpf/libbpf.pc.template b/tools/lib/bpf/libbpf.pc.template > new file mode 100644 > index 000000000000..0cac2f5f54a6 > --- /dev/null > +++ b/tools/lib/bpf/libbpf.pc.template > @@ -0,0 +1,11 @@ > +prefix=@PREFIX@ > +libdir=@LIBDIR@ > +includedir=${prefix}/include/bpf > + > +Name: libbpf > +URL: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > +Description: Linux kernel BPF library > +Version: @VERSION@ > +Libs: -L${libdir} -lbpf > +Requires.private: libelf > +Cflags: -I${includedir} > -- > 2.20.1 >