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=-12.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED 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 66CF5C43381 for ; Tue, 19 Mar 2019 23:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AE902175B for ; Tue, 19 Mar 2019 23:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbfCSXCS convert rfc822-to-8bit (ORCPT ); Tue, 19 Mar 2019 19:02:18 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:33758 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbfCSXCR (ORCPT ); Tue, 19 Mar 2019 19:02:17 -0400 Received: by mail-wm1-f67.google.com with SMTP id z6so5573886wmi.0 for ; Tue, 19 Mar 2019 16:02:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-transfer-encoding:mime-version; bh=M6snVJpmWWXV8vAdFNymZyX3H/7GM8yLfGePVyBU4+Y=; b=DOb6dylxCayxWZdtEgerru7gadqrSYwFCdrilmmtp/P3lKw6+OkBWgOlsqXx3GdD6x AfwGiQcKqq6D5m36azpPoV/Rte9w5K3LlHvhv0Y7sKnE5+pyYZ13M13DtBynMOdF2Dsu yvKQmsuMGT0HS5zWZoRC4e9ZHz3otVe2M8pMUX3faQSwe/PEpLuciP8xuVLG261fdxTB DTZaN5jAxlk87/VbDTNOfkTrptdNsRNYkR22Bb5jzDjJfIEyNWXO2tqMbwZXpVHIotyS oX4caxJC4DUrWNLqNEzTSXquDKKB8QDsI1Zc/8ZT21Xjiex9D9L5fpA5AR2eaeGUfxmz sH8g== X-Gm-Message-State: APjAAAWQx+hl5suOxv7Nh9C24eApqw2Nt5YYIgm1It8Av8b5i3k0SmKe HlWIPFlOXleXq4myfzfHQAo= X-Google-Smtp-Source: APXvYqxD3iu7uhj35GiYu8vB0iBaAxYb/4MjfVNVarZ5aiEZQBglVIfLWrWSuiK38UrzzCC7HizSDA== X-Received: by 2002:a05:600c:2309:: with SMTP id 9mr5727649wmo.52.1553036536407; Tue, 19 Mar 2019 16:02:16 -0700 (PDT) Received: from localhost ([2a01:4b00:f419:6f00:1cc6:1349:f313:ae0f]) by smtp.gmail.com with ESMTPSA id v20sm4713825wmj.2.2019.03.19.16.02.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 16:02:15 -0700 (PDT) Message-ID: <1553036535.28350.2.camel@debian.org> Subject: Re: [PATCH bpf-next] tools/bpf: generate pkg-config file for libbpf From: Luca Boccassi To: Stanislav Fomichev Cc: netdev@vger.kernel.org Date: Tue, 19 Mar 2019 23:02:15 +0000 In-Reply-To: <20190319212303.GE7431@mini-arch.hsd1.ca.comcast.net> References: <20190319210639.6282-1-bluca@debian.org> <20190319212303.GE7431@mini-arch.hsd1.ca.comcast.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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? -- Kind regards, Luca Boccassi