bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin@isovalent.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
	Quentin Monnet <quentin@isovalent.com>
Subject: [PATCH bpf-next v4 01/12] libbpf: skip re-installing headers file if source is older than target
Date: Thu,  7 Oct 2021 20:44:27 +0100	[thread overview]
Message-ID: <20211007194438.34443-2-quentin@isovalent.com> (raw)
In-Reply-To: <20211007194438.34443-1-quentin@isovalent.com>

The "install_headers" target in libbpf's Makefile would unconditionally
export all API headers to the target directory. When those headers are
installed to compile another application, this means that make always
finds newer dependencies for the source files relying on those headers,
and deduces that the targets should be rebuilt.

Avoid that by making "install_headers" depend on the source header
files, and (re-)install them only when necessary.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
---
 tools/lib/bpf/Makefile | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 41e4f78dbad5..a92d3b9692a8 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -241,15 +241,23 @@ install_lib: all_cmd
 		$(call do_install_mkdir,$(libdir_SQ)); \
 		cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ)
 
-INSTALL_HEADERS = bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h xsk.h \
-		  bpf_helpers.h $(BPF_GENERATED) bpf_tracing.h		     \
-		  bpf_endian.h bpf_core_read.h skel_internal.h		     \
-		  libbpf_version.h
+SRC_HDRS := bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h xsk.h	       \
+	    bpf_helpers.h bpf_tracing.h bpf_endian.h bpf_core_read.h	       \
+	    skel_internal.h libbpf_version.h
+GEN_HDRS := $(BPF_GENERATED)
+INSTALL_SRC_HDRS := $(addprefix $(DESTDIR)$(prefix)/include/bpf/,$(SRC_HDRS))
+INSTALL_GEN_HDRS := $(addprefix $(DESTDIR)$(prefix)/include/bpf/, \
+				$(notdir $(GEN_HDRS)))
+$(INSTALL_SRC_HDRS): $(DESTDIR)$(prefix)/include/bpf/%.h: %.h
+	$(call QUIET_INSTALL, $@) \
+		$(call do_install,$<,$(prefix)/include/bpf,644)
+$(INSTALL_GEN_HDRS): $(DESTDIR)$(prefix)/include/bpf/%.h: $(OUTPUT)%.h
+	$(call QUIET_INSTALL, $@) \
+		$(call do_install,$<,$(prefix)/include/bpf,644)
 
-install_headers: $(BPF_GENERATED)
-	$(call QUIET_INSTALL, headers)					     \
-		$(foreach hdr,$(INSTALL_HEADERS),			     \
-			$(call do_install,$(hdr),$(prefix)/include/bpf,644);)
+INSTALL_HEADERS := $(INSTALL_SRC_HDRS) $(INSTALL_GEN_HDRS)
+
+install_headers: $(BPF_GENERATED) $(INSTALL_HEADERS)
 
 install_pkgconfig: $(PC_FILE)
 	$(call QUIET_INSTALL, $(PC_FILE)) \
-- 
2.30.2


  reply	other threads:[~2021-10-07 19:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 19:44 [PATCH bpf-next v4 00/12] install libbpf headers when using the library Quentin Monnet
2021-10-07 19:44 ` Quentin Monnet [this message]
2021-10-08 19:13   ` [PATCH bpf-next v4 01/12] libbpf: skip re-installing headers file if source is older than target Andrii Nakryiko
2021-10-07 19:44 ` [PATCH bpf-next v4 02/12] bpftool: remove unused includes to <bpf/bpf_gen_internal.h> Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 03/12] bpftool: install libbpf headers instead of including the dir Quentin Monnet
2021-10-08 19:13   ` Andrii Nakryiko
2021-10-07 19:44 ` [PATCH bpf-next v4 04/12] tools/resolve_btfids: install libbpf headers when building Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 05/12] tools/runqslower: " Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 06/12] bpf: preload: " Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 07/12] bpf: iterators: " Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 08/12] samples/bpf: update .gitignore Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 09/12] samples/bpf: install libbpf headers when building Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 10/12] samples/bpf: do not FORCE-recompile libbpf Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 11/12] selftests/bpf: better clean up for runqslower in test_bpftool_build.sh Quentin Monnet
2021-10-07 19:44 ` [PATCH bpf-next v4 12/12] bpftool: add install-bin target to install binary only Quentin Monnet
2021-10-08 19:13 ` [PATCH bpf-next v4 00/12] install libbpf headers when using the library Andrii Nakryiko
2021-10-09 21:03   ` Quentin Monnet
2021-10-11  6:46     ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211007194438.34443-2-quentin@isovalent.com \
    --to=quentin@isovalent.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).