Re: [PATCH] selftests: lib.mk: fix out-of-tree builds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/14/23 14:16, Anders Roxell wrote:
(It's too bad that we have all this duplication between the Makefile
and lib.mk.)

I agree, also the duplication of get_sys_includes in bpf, hid and net Makefile's
Do you have any idea how we can remove the duplication?


Well, since you asked... :)

Yes. Given that the goal is to support two similar, related activities:
	a) make -C tools/testing/selftests
	b) make -C tools/testing/selftests/<subtest>

, we could move common functionality into common_vars.mk and
common_targets.mk, and include those from both the top level
tools/testing/selftests/Makefile, and the subtest Makefiles.

This allows deduplication in a fairly safe sort of way, because it also
simultaneously moves everything to a non-recursive Make design. That's
especially nice, because then dependencies work reliably, and you also
don't have to worry about propagating Make variables (via Make's export
directive).

I haven't done this, because a few years ago I somehow got the vague
impression that it would not be well-received. But maybe that's
pessimistic and/or obsolete--times change, after all!

***************************************************************
Contents of tools/testing/selftests/Makefile:

include common_vars.mk

include alsa/alsa.mk
include amd-pstate/amd-pstate.mk
include arm64/arm64.mk
...etc, there are 100+ subdirs

include common_targets.mk

(This is instead of doing "TARGETS += xxx" in the Makefile. Including
the subtest *.mk fragments allows each subtest to add features and
quirks as necessary, while also enabling full dependency checking via a
true non-recursive Make.)

***************************************************************
Contents of tools/testing/selftests/common_targets.mk:

all: kernel_headers
    ...

Other rules/targets here.

***************************************************************
Contents of tools/testing/selftests/common_vars.mk:

Common variables, some of which may be overridden by a Makefile.

***************************************************************

Using alsa as an example of a subtest:

***************************************************************
Contents of tools/testing/selftests/alsa/alsa.mk:
TARGETS += alsa

TEST* items

Plus: alsa-specific items, such as:
CFLAGS += $(shell pkg-config --cflags alsa)

***************************************************************
Contents of tools/testing/selftests/alsa/Makefile:

include ../common_vars.mk
include alsa.mk

...maybe very little else needs to go here.

include ../common_targets.mk


thanks,
--
John Hubbard
NVIDIA




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux