From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: ast@kernel.org, daniel@iogearbox.net
Cc: bpf@vger.kernel.org, kafai@fb.com, songliubraving@fb.com,
yhs@fb.com, andriin@fb.com, john.fastabend@gmail.com,
kpsingh@chromium.org,
Jean-Philippe Brucker <jean-philippe@linaro.org>
Subject: [PATCH bpf-next v3 5/7] tools/runqslower: Enable out-of-tree build
Date: Tue, 10 Nov 2020 17:43:09 +0100 [thread overview]
Message-ID: <20201110164310.2600671-6-jean-philippe@linaro.org> (raw)
In-Reply-To: <20201110164310.2600671-1-jean-philippe@linaro.org>
Enable out-of-tree build for runqslower. Only set OUTPUT=.output if it
wasn't already set by the user.
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
v3:
* Drop clean recipe for bpftool and libbpf, since the whole output
directories are removed by the clean recipe.
* Use ?= for $(OUTPUT)
---
tools/bpf/runqslower/Makefile | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile
index bcc4a7396713..0fc4d4046193 100644
--- a/tools/bpf/runqslower/Makefile
+++ b/tools/bpf/runqslower/Makefile
@@ -1,15 +1,18 @@
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
include ../../scripts/Makefile.include
-OUTPUT := .output
+OUTPUT ?= $(abspath .output)/
+
CLANG ?= clang
LLC ?= llc
LLVM_STRIP ?= llvm-strip
-DEFAULT_BPFTOOL := $(OUTPUT)/sbin/bpftool
+BPFTOOL_OUTPUT := $(OUTPUT)bpftool/
+DEFAULT_BPFTOOL := $(BPFTOOL_OUTPUT)bpftool
BPFTOOL ?= $(DEFAULT_BPFTOOL)
LIBBPF_SRC := $(abspath ../../lib/bpf)
-BPFOBJ := $(OUTPUT)/libbpf.a
-BPF_INCLUDE := $(OUTPUT)
+BPFOBJ_OUTPUT := $(OUTPUT)libbpf/
+BPFOBJ := $(BPFOBJ_OUTPUT)libbpf.a
+BPF_INCLUDE := $(BPFOBJ_OUTPUT)
INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../lib) \
-I$(abspath ../../include/uapi)
CFLAGS := -g -Wall
@@ -20,7 +23,6 @@ VMLINUX_BTF_PATHS := /sys/kernel/btf/vmlinux /boot/vmlinux-$(KERNEL_REL)
VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
$(wildcard $(VMLINUX_BTF_PATHS))))
-abs_out := $(abspath $(OUTPUT))
ifeq ($(V),1)
Q =
else
@@ -38,7 +40,11 @@ runqslower: $(OUTPUT)/runqslower
clean:
$(call QUIET_CLEAN, runqslower)
- $(Q)rm -rf $(OUTPUT) runqslower
+ $(Q)$(RM) -r $(BPFOBJ_OUTPUT) $(BPFTOOL_OUTPUT)
+ $(Q)$(RM) $(OUTPUT)*.o $(OUTPUT)*.d
+ $(Q)$(RM) $(OUTPUT)*.skel.h $(OUTPUT)vmlinux.h
+ $(Q)$(RM) $(OUTPUT)runqslower
+ $(Q)$(RM) -r .output
$(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ)
$(QUIET_LINK)$(CC) $(CFLAGS) $^ -lelf -lz -o $@
@@ -59,8 +65,8 @@ $(OUTPUT)/%.bpf.o: %.bpf.c $(BPFOBJ) | $(OUTPUT)
$(OUTPUT)/%.o: %.c | $(OUTPUT)
$(QUIET_CC)$(CC) $(CFLAGS) $(INCLUDES) -c $(filter %.c,$^) -o $@
-$(OUTPUT):
- $(QUIET_MKDIR)mkdir -p $(OUTPUT)
+$(OUTPUT) $(BPFOBJ_OUTPUT) $(BPFTOOL_OUTPUT):
+ $(QUIET_MKDIR)mkdir -p $@
$(OUTPUT)/vmlinux.h: $(VMLINUX_BTF_PATH) | $(OUTPUT) $(BPFTOOL)
$(Q)if [ ! -e "$(VMLINUX_BTF_PATH)" ] ; then \
@@ -70,10 +76,8 @@ $(OUTPUT)/vmlinux.h: $(VMLINUX_BTF_PATH) | $(OUTPUT) $(BPFTOOL)
fi
$(QUIET_GEN)$(BPFTOOL) btf dump file $(VMLINUX_BTF_PATH) format c > $@
-$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
- $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) \
- OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
+$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(BPFOBJ_OUTPUT)
+ $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(BPFOBJ_OUTPUT) $@
-$(DEFAULT_BPFTOOL):
- $(Q)$(MAKE) $(submake_extras) -C ../bpftool \
- prefix= OUTPUT=$(abs_out)/ DESTDIR=$(abs_out) install
+$(DEFAULT_BPFTOOL): | $(BPFTOOL_OUTPUT)
+ $(Q)$(MAKE) $(submake_extras) -C ../bpftool OUTPUT=$(BPFTOOL_OUTPUT)
--
2.29.1
next prev parent reply other threads:[~2020-11-10 16:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 16:43 [PATCH bpf-next v3 0/7] tools/bpftool: Some build fixes Jean-Philippe Brucker
2020-11-10 16:43 ` [PATCH bpf-next v3 1/7] tools: Factor HOSTCC, HOSTLD, HOSTAR definitions Jean-Philippe Brucker
2020-11-10 16:43 ` [PATCH bpf-next v3 2/7] tools/bpftool: Force clean of out-of-tree build Jean-Philippe Brucker
2020-11-11 4:57 ` Andrii Nakryiko
2020-11-11 8:54 ` Jean-Philippe Brucker
2020-11-11 18:22 ` Andrii Nakryiko
2020-11-10 16:43 ` [PATCH bpf-next v3 3/7] tools/bpftool: Fix cross-build Jean-Philippe Brucker
2020-11-11 5:04 ` Andrii Nakryiko
2020-11-11 20:50 ` Andrii Nakryiko
2020-11-10 16:43 ` [PATCH bpf-next v3 4/7] tools/runqslower: Use Makefile.include Jean-Philippe Brucker
2020-11-11 5:06 ` Andrii Nakryiko
2020-11-10 16:43 ` Jean-Philippe Brucker [this message]
2020-11-11 5:11 ` [PATCH bpf-next v3 5/7] tools/runqslower: Enable out-of-tree build Andrii Nakryiko
2020-11-11 8:53 ` Jean-Philippe Brucker
2020-11-11 18:23 ` Andrii Nakryiko
2020-11-10 16:43 ` [PATCH bpf-next v3 6/7] tools/runqslower: Build bpftool using HOSTCC Jean-Philippe Brucker
2020-11-11 5:11 ` Andrii Nakryiko
2020-11-10 16:43 ` [PATCH bpf-next v3 7/7] tools/bpftool: Fix build slowdown Jean-Philippe Brucker
2020-11-11 5:12 ` Andrii Nakryiko
2020-11-11 20:40 ` [PATCH bpf-next v3 0/7] tools/bpftool: Some build fixes patchwork-bot+netdevbpf
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=20201110164310.2600671-6-jean-philippe@linaro.org \
--to=jean-philippe@linaro.org \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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).