Skip to content

Commit b62a796

Browse files
netoptimizerdavem330
authored andcommitted
samples/bpf: allow make to be run from samples/bpf/ directory
It is not intuitive that 'make' must be run from the top level directory with argument "samples/bpf/" to compile these eBPF samples. Introduce a kbuild make file trick that allow make to be run from the "samples/bpf/" directory itself. It basically change to the top level directory and call "make samples/bpf/" with the "/" slash after the directory name. Also add a clean target that only cleans this directory, by taking advantage of the kbuild external module setting M=$PWD. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1c97566 commit b62a796

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎samples/bpf/Makefile‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ HOSTLOADLIBES_test_overhead += -lelf -lrt
8585
# make samples/bpf/ LLC=~/git/llvm/build/bin/llc
8686
LLC ?= llc
8787

88+
# Trick to allow make to be run from this directory
89+
all:
90+
$(MAKE) -C ../../ $$PWD/
91+
92+
clean:
93+
$(MAKE) -C ../../ M=$$PWD clean
94+
@rm -f *~
95+
8896
# Verify LLVM compiler is available and bpf target is supported
8997
.PHONY: verify_cmd_llc verify_target_bpf
9098

‎samples/bpf/README.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ top level directory::
3636

3737
Do notice the "/" slash after the directory name.
3838

39+
It is also possible to call make from this directory. This will just
40+
hide the the invocation of make as above with the appended "/".
41+
3942
Manually compiling LLVM with 'bpf' support
4043
------------------------------------------
4144

0 commit comments

Comments
 (0)