selftests/gpio: Fix build when source tree is read only

Currently the gpio selftests fail to build if the source tree is read
only:

  make -j 160 -C tools/testing/selftests TARGETS=gpio
  make[1]: Entering directory '/linux/tools/testing/selftests/gpio'
  make OUTPUT=/linux/tools/gpio/ -C /linux/tools/gpio
  make[2]: Entering directory '/linux/tools/gpio'
  mkdir -p /linux/tools/gpio/include/linux 2>&1 || true
  ln -sf /linux/tools/gpio/../../include/uapi/linux/gpio.h /linux/tools/gpio/include/linux/gpio.h
  ln: failed to create symbolic link '/linux/tools/gpio/include/linux/gpio.h': Read-only file system

This happens because we ask make to build ../../../gpio (tools/gpio)
without pointing OUTPUT away from the source directory.

To fix it we create a subdirectory of the existing OUTPUT directory,
called tools-gpio, and tell tools/gpio to build in there.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
Michael Ellerman 2020-11-04 21:08:42 +11:00 committed by Shuah Khan
parent 449539da2e
commit b68c1c65de

View File

@ -17,14 +17,18 @@ KSFT_KHDR_INSTALL := 1
include ../lib.mk
GPIODIR := $(realpath ../../../gpio)
GPIOOBJ := gpio-utils.o
GPIOOUT := $(OUTPUT)/tools-gpio/
GPIOOBJ := $(GPIOOUT)/gpio-utils.o
override define CLEAN
$(RM) $(TEST_GEN_PROGS_EXTENDED)
$(MAKE) -C $(GPIODIR) OUTPUT=$(GPIODIR)/ clean
$(RM) -rf $(GPIOOUT)
endef
$(TEST_GEN_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ)
$(TEST_GEN_PROGS_EXTENDED): $(GPIOOBJ)
$(GPIODIR)/$(GPIOOBJ):
$(MAKE) OUTPUT=$(GPIODIR)/ -C $(GPIODIR)
$(GPIOOUT):
mkdir -p $@
$(GPIOOBJ): $(GPIOOUT)
$(MAKE) OUTPUT=$(GPIOOUT) -C $(GPIODIR)