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 4CAD9C43381 for ; Tue, 19 Mar 2019 23:12:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0123A20857 for ; Tue, 19 Mar 2019 23:12:41 +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="Hp0d14L6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbfCSXMj (ORCPT ); Tue, 19 Mar 2019 19:12:39 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32849 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfCSXMj (ORCPT ); Tue, 19 Mar 2019 19:12:39 -0400 Received: by mail-pf1-f194.google.com with SMTP id i19so471102pfd.0 for ; Tue, 19 Mar 2019 16:12:38 -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:content-transfer-encoding:in-reply-to :user-agent; bh=lRI5GRZrmgjOh5lKKh3LYkVl9ogYDUsrlRewqzlQCRU=; b=Hp0d14L6rkoziAgDrxhyPB7xT7L5LXlgRHjnJuTxdipPPbhfSwmBnv6wHH/ZoT97/J K4M0ieWRHl7e2cNSj+WGRzsOjOPEmtdLXTgBzRyAJ3Z3Bi26LPRq9axuakrzJaL3aDGO j8ia3PGan+PqtWkhqR6wKTzzBkdPQU3DsMo9xst3Kjv8fAHd+Dak/NXqZN8n5PoCpGoE 5uWqWgiXkZqoCuD0HSxR78Cjv7LcB+s0z/LW2s3QueAfpgkMQyxL8DB57hS62K+qzb9i 88BQd6JScRHqLyKl6AZhGerIF+P+mOa5qIuAcADmMMsAs3HHT+pUIWO+JMl5Ernk4HsP +PYA== 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:content-transfer-encoding :in-reply-to:user-agent; bh=lRI5GRZrmgjOh5lKKh3LYkVl9ogYDUsrlRewqzlQCRU=; b=l7jCFpXPZjR9NiDWfDT+/zZn2jzilCH2b+FIFC8xDkDfb3vpocq7ZKDQ33IBr5FRR0 gkfA6VLa0LWd60uHFd7BHPv0UctGT2C0L2qf84Jo4DirLZTLOHQbwSjQlzols/eptSBq YYQm1OzsAU4ylo7pvpIcffNZ4rkBB4FI4X927YFwtQVASsTYFky1DQaCGSzmkiP+PFAn 1ZQLFbO3/VzUjewuVDwEoeMU3wbGsJfEy/bu3v24pRgajOQjixWsO8Ouhj35/B+lSDQi k4ttYxSxSwjYUhgKFjkBl/FTI4MYx0kiKLgvlB+cUsYcuYmC3R1NZ6I8zX98VNMnpd6Q BCgQ== X-Gm-Message-State: APjAAAUQLMAiiSsHYgCnU4Vl8NKygHqYHrP8aKbmraM65yWWnHUO8nkb 86gSGEiIHHb62Cf16Z0pMRFSJkB9pAI= X-Google-Smtp-Source: APXvYqxtRlcr2fcRxXW/J3j7pEQzw8v4SpcJrg/ZGv5zAHUlK0/xvy+Wi0138/afUQX6vcdH50xBJQ== X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr4931273plq.293.1553037158398; Tue, 19 Mar 2019 16:12:38 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id x1sm100513pge.73.2019.03.19.16.12.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 16:12:37 -0700 (PDT) Date: Tue, 19 Mar 2019 16:12:36 -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: <20190319231236.GF7431@mini-arch.hsd1.ca.comcast.net> References: <20190319210639.6282-1-bluca@debian.org> <20190319212303.GE7431@mini-arch.hsd1.ca.comcast.net> <1553036535.28350.2.camel@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1553036535.28350.2.camel@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: > 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 > > > --- > > >  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)? > > Changed to QUIET_GEN in v2. > > > > + -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/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? Yes, it's autosynched, but it autosyncs only tools/lib/bpf directory and it lacks top-level makefile with kernelversion target. I guess in this case make will spill out an error to stderr and version will be empty. > > -- > Kind regards, > Luca Boccassi