Commit 3290996e authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Andrii Nakryiko

tools/runqslower: Use Makefile.include

Makefile.include defines variables such as OUTPUT and CC for out-of-tree
build and cross-build. Include it into the runqslower Makefile and use
its $(QUIET*) helpers.
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20201110164310.2600671-5-jean-philippe@linaro.org
parent 8859b0da
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
include ../../scripts/Makefile.include
OUTPUT := .output OUTPUT := .output
CLANG ?= clang CLANG ?= clang
LLC ?= llc LLC ?= llc
...@@ -21,10 +23,8 @@ VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \ ...@@ -21,10 +23,8 @@ VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
abs_out := $(abspath $(OUTPUT)) abs_out := $(abspath $(OUTPUT))
ifeq ($(V),1) ifeq ($(V),1)
Q = Q =
msg =
else else
Q = @ Q = @
msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
MAKEFLAGS += --no-print-directory MAKEFLAGS += --no-print-directory
submake_extras := feature_display=0 submake_extras := feature_display=0
endif endif
...@@ -37,12 +37,11 @@ all: runqslower ...@@ -37,12 +37,11 @@ all: runqslower
runqslower: $(OUTPUT)/runqslower runqslower: $(OUTPUT)/runqslower
clean: clean:
$(call msg,CLEAN) $(call QUIET_CLEAN, runqslower)
$(Q)rm -rf $(OUTPUT) runqslower $(Q)rm -rf $(OUTPUT) runqslower
$(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ) $(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ)
$(call msg,BINARY,$@) $(QUIET_LINK)$(CC) $(CFLAGS) $^ -lelf -lz -o $@
$(Q)$(CC) $(CFLAGS) $^ -lelf -lz -o $@
$(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \ $(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \
$(OUTPUT)/runqslower.bpf.o $(OUTPUT)/runqslower.bpf.o
...@@ -50,31 +49,26 @@ $(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \ ...@@ -50,31 +49,26 @@ $(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \
$(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h $(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h
$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(BPFTOOL) $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(BPFTOOL)
$(call msg,GEN-SKEL,$@) $(QUIET_GEN)$(BPFTOOL) gen skeleton $< > $@
$(Q)$(BPFTOOL) gen skeleton $< > $@
$(OUTPUT)/%.bpf.o: %.bpf.c $(BPFOBJ) | $(OUTPUT) $(OUTPUT)/%.bpf.o: %.bpf.c $(BPFOBJ) | $(OUTPUT)
$(call msg,BPF,$@) $(QUIET_GEN)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
$(Q)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
-c $(filter %.c,$^) -o $@ && \ -c $(filter %.c,$^) -o $@ && \
$(LLVM_STRIP) -g $@ $(LLVM_STRIP) -g $@
$(OUTPUT)/%.o: %.c | $(OUTPUT) $(OUTPUT)/%.o: %.c | $(OUTPUT)
$(call msg,CC,$@) $(QUIET_CC)$(CC) $(CFLAGS) $(INCLUDES) -c $(filter %.c,$^) -o $@
$(Q)$(CC) $(CFLAGS) $(INCLUDES) -c $(filter %.c,$^) -o $@
$(OUTPUT): $(OUTPUT):
$(call msg,MKDIR,$@) $(QUIET_MKDIR)mkdir -p $(OUTPUT)
$(Q)mkdir -p $(OUTPUT)
$(OUTPUT)/vmlinux.h: $(VMLINUX_BTF_PATH) | $(OUTPUT) $(BPFTOOL) $(OUTPUT)/vmlinux.h: $(VMLINUX_BTF_PATH) | $(OUTPUT) $(BPFTOOL)
$(call msg,GEN,$@)
$(Q)if [ ! -e "$(VMLINUX_BTF_PATH)" ] ; then \ $(Q)if [ ! -e "$(VMLINUX_BTF_PATH)" ] ; then \
echo "Couldn't find kernel BTF; set VMLINUX_BTF to" \ echo "Couldn't find kernel BTF; set VMLINUX_BTF to" \
"specify its location." >&2; \ "specify its location." >&2; \
exit 1;\ exit 1;\
fi fi
$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF_PATH) format c > $@ $(QUIET_GEN)$(BPFTOOL) btf dump file $(VMLINUX_BTF_PATH) format c > $@
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT) $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) \ $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment