Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 787360f8 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Alexei Starovoitov
Browse files

samples: bpf: fix build after move to compiling full libbpf.a



There are many ways users may compile samples, some of them got
broken by commit 5f938057 ("samples: bpf: compile and link
against full libbpf").  Improve path resolution and make libbpf
building a dependency of source files to force its build.

Samples should now again build with any of:
 cd samples/bpf; make
 make samples/bpf/
 make -C samples/bpf
 cd samples/bpf; make O=builddir
 make samples/bpf/ O=builddir
 make -C samples/bpf O=builddir
 export KBUILD_OUTPUT=builddir
 make samples/bpf/
 make -C samples/bpf

Fixes: 5f938057 ("samples: bpf: compile and link against full libbpf")
Reported-by: default avatarBjörn Töpel <bjorn.topel@gmail.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 8d930450
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
# SPDX-License-Identifier: GPL-2.0

BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools

# List of programs to build
# List of programs to build
hostprogs-y := test_lru_dist
hostprogs-y := test_lru_dist
hostprogs-y += sock_example
hostprogs-y += sock_example
@@ -49,7 +53,8 @@ hostprogs-y += xdpsock
hostprogs-y += xdp_fwd
hostprogs-y += xdp_fwd


# Libbpf dependencies
# Libbpf dependencies
LIBBPF := ../../tools/lib/bpf/libbpf.a
LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a

CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o
TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o


@@ -233,15 +238,16 @@ CLANG_ARCH_ARGS = -target $(ARCH)
endif
endif


# Trick to allow make to be run from this directory
# Trick to allow make to be run from this directory
all: $(LIBBPF)
all:
	$(MAKE) -C ../../ $(CURDIR)/
	$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)


clean:
clean:
	$(MAKE) -C ../../ M=$(CURDIR) clean
	$(MAKE) -C ../../ M=$(CURDIR) clean
	@rm -f *~
	@rm -f *~


$(LIBBPF): FORCE
$(LIBBPF): FORCE
	$(MAKE) -C $(dir $@)
# Fix up variables inherited from Kbuild that tools/ build system won't like
	$(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O=


$(obj)/syscall_nrs.s:	$(src)/syscall_nrs.c
$(obj)/syscall_nrs.s:	$(src)/syscall_nrs.c
	$(call if_changed_dep,cc_s_c)
	$(call if_changed_dep,cc_s_c)
@@ -272,7 +278,8 @@ verify_target_bpf: verify_cmds
		exit 2; \
		exit 2; \
	else true; fi
	else true; fi


$(src)/*.c: verify_target_bpf
$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
$(src)/*.c: verify_target_bpf $(LIBBPF)


$(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
$(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h