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=-14.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT 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 8DCF9C43381 for ; Tue, 19 Mar 2019 21:06:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EA59213F2 for ; Tue, 19 Mar 2019 21:06:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727384AbfCSVGr (ORCPT ); Tue, 19 Mar 2019 17:06:47 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54214 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727227AbfCSVGr (ORCPT ); Tue, 19 Mar 2019 17:06:47 -0400 Received: by mail-wm1-f65.google.com with SMTP id e74so18305454wmg.3 for ; Tue, 19 Mar 2019 14:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=YdJxajhCo03hwNxsP/bZ70kFobK+f2/DK7ht46uAYQI=; b=QcDJh94BhIT6YJL8J5ojkw2iKW9Lt3p/fMHXO+Gv+6UwHFdInVQVp8hyzV4Xo/y34H OdFf2XtBTw+ILcF4TvNE53/vBpdqA2iV8LUCPQIM8O16ZIHbYGUtqhhws6Xc1gCTN5w4 fXX5MhgxD1dCzKetCfLYtTAyXcVH0/VtcKOwAwu4ZeZmFxV7SX13bMX8qpf3IqrbsPWP a6jaBF/2IIlFNajKjVcdDhT24nC+bYQcB21jrR3h+CjdRBF+cvd9L5axnhChR7+dZbLW YJdkOcu4HQNb5eD9W5NCSfS4er8F0RmCdCiEtjFae7E+rRPTgOW3/BbcJYNh1LRhWAKQ 9aTQ== X-Gm-Message-State: APjAAAUQRDdEju6F+oLajWpEiwP9qr5K4T748LEwBV4HhdaLw9qD6NAK vesWtY+HQ076QWPout+Xd2EmW2/DT8w= X-Google-Smtp-Source: APXvYqwHzxku2FyLY2TqhMb+c18MTwFt6C0+ytzskTzfjWF2h2vP7B3BKKCy9E0SftDhMYbd2c315g== X-Received: by 2002:a1c:be03:: with SMTP id o3mr5042546wmf.123.1553029604880; Tue, 19 Mar 2019 14:06:44 -0700 (PDT) Received: from localhost ([2a01:4b00:f419:6f00:1cc6:1349:f313:ae0f]) by smtp.gmail.com with ESMTPSA id s130sm259439wms.13.2019.03.19.14.06.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 14:06:43 -0700 (PDT) From: Luca Boccassi To: netdev@vger.kernel.org Subject: [PATCH bpf-next] tools/bpf: generate pkg-config file for libbpf Date: Tue, 19 Mar 2019 21:06:39 +0000 Message-Id: <20190319210639.6282-1-bluca@debian.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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)|" \ + -e "s|@LIBDIR@|$(libdir_SQ)|" \ + -e "s|@VERSION@|$(shell make --no-print-directory -sC ../../.. kernelversion)|" \ + < $@.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