Re: [RFC PATCH bpf-next v5 7/8] selftests/bpf: move shared build definitions into Makefile.buildvars

Eduard Zingerman <[email protected]>
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
On Tue, 2026-08-04 at 10:01 -0700, Mykola Lysenko wrote:

...

Thank you for taking time to reshuffle the diff, such that the
Makefile.buildvars preserves the original relative order.
Much easier to review.

...

> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -3,60 +3,15 @@ include ../../../build/Build.include

...

> -GENHDR := $(GENDIR)/autoconf.h
>  PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It seems this can be removed as well, all uses are after
Makefile.buildvars is included. Or is it needed for one of the other
includes?

...

> @@ -220,21 +151,8 @@ ifeq ($(feature-llvm),1)

...

> -HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a
> -RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids
> +include Makefile.buildvars

It appears that this include can be moved up, to the lib.mk include.
In this case the duplicate definitions for `srctree` and `PKG_CONFIG`
can be removed (and both can reside in Makefile.buildvars).
Wdyt?

...

> --- /dev/null
> +++ b/tools/testing/selftests/bpf/Makefile.buildvars

...

> +PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config

...

> +ifeq ($(srctree),)
> +srctree := $(patsubst %/,%,$(dir $(CURDIR)))
> +srctree := $(patsubst %/,%,$(dir $(srctree)))
> +srctree := $(patsubst %/,%,$(dir $(srctree)))
> +srctree := $(patsubst %/,%,$(dir $(srctree)))
> +endif

In case if shuffling includes around does not work, can we export
`srctree` in the main makefile and not copy it here?

...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.