Skip to content

Commit 9e8929f

Browse files
jpbruckeranakryiko
authored andcommitted
tools/bpftool: Force clean of out-of-tree build
Cleaning a partial build can fail if the output directory for libbpf wasn't created: $ make -C tools/bpf/bpftool O=/tmp/bpf clean /bin/sh: line 0: cd: /tmp/bpf/libbpf/: No such file or directory tools/scripts/Makefile.include:17: *** output directory "/tmp/bpf/libbpf/" does not exist. Stop. make: *** [Makefile:36: /tmp/bpf/libbpf/libbpf.a-clean] Error 2 As a result make never gets around to clearing the leftover objects. Add the libbpf output directory as clean dependency to ensure clean always succeeds (similarly to the "descend" macro). The directory is later removed by the clean recipe. Signed-off-by: Jean-Philippe Brucker <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c8a950d commit 9e8929f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/bpf/bpftool/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ LIBBPF = $(LIBBPF_PATH)libbpf.a
2727

2828
BPFTOOL_VERSION ?= $(shell make -rR --no-print-directory -sC ../../.. kernelversion)
2929

30-
$(LIBBPF): FORCE
31-
$(if $(LIBBPF_OUTPUT),@mkdir -p $(LIBBPF_OUTPUT))
30+
$(LIBBPF_OUTPUT):
31+
$(QUIET_MKDIR)mkdir -p $@
32+
33+
$(LIBBPF): FORCE | $(LIBBPF_OUTPUT)
3234
$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) $(LIBBPF_OUTPUT)libbpf.a
3335

34-
$(LIBBPF)-clean:
36+
$(LIBBPF)-clean: $(LIBBPF_OUTPUT)
3537
$(call QUIET_CLEAN, libbpf)
3638
$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) clean >/dev/null
3739

0 commit comments

Comments
 (0)