]> git.baikalelectronics.ru Git - kernel.git/commit
selftests: more general make nesting support
authorGreg Thelen <gthelen@google.com>
Tue, 28 Jul 2020 07:32:41 +0000 (00:32 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 31 Aug 2020 21:20:40 +0000 (15:20 -0600)
commit3d448cace9731a099a329c3b60c1dee4c414fa1d
treefe8b28077b40f2601202e035f36e289bb6080052
parentb9dcc7c3d9fda6de29ff7ea574252aeaa67fce12
selftests: more general make nesting support

selftests can be built from the toplevel kernel makefile (e.g. make
kselftest-all) or directly (make -C tools/testing/selftests all).

The toplevel kernel makefile explicitly disables implicit rules with
"MAKEFLAGS += -rR", which is passed to tools/testing/selftests.  Some
selftest makefiles require implicit make rules, which is why
commit 8173983f731e ("selftests: Fix build failures when invoked from
kselftest target") reenables implicit rules by clearing MAKEFLAGS if
MAKELEVEL=1.

So far so good.  However, if the toplevel makefile is called from an
outer makefile then MAKELEVEL will be elevated, which breaks the
MAKELEVEL equality test.
Example wrapped makefile error:
  $ cat ~/Makefile
  all:
   $(MAKE) defconfig
   $(MAKE) kselftest-all
  $ make -sf ~/Makefile
    futex_wait_timeout.c /src/tools/testing/selftests/kselftest_harness.h   /src/tools/testing/selftests/kselftest.h ../include/futextest.h ../include/atomic.h ../include/logging.h -lpthread -lrt -o /src/tools/testing/selftests/futex/functional/futex_wait_timeout
  make[4]: futex_wait_timeout.c: Command not found

Rather than checking $(MAKELEVEL), check for $(LINK.c), which is a more
direct side effect of "make -R".  This enables arbitrary makefile
nesting.

Signed-off-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/Makefile