Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael Ellerman and committed by
Shuah Khan
b68c1c65 449539da

+9 -5
+9 -5
tools/testing/selftests/gpio/Makefile
··· 17 17 include ../lib.mk 18 18 19 19 GPIODIR := $(realpath ../../../gpio) 20 - GPIOOBJ := gpio-utils.o 20 + GPIOOUT := $(OUTPUT)/tools-gpio/ 21 + GPIOOBJ := $(GPIOOUT)/gpio-utils.o 21 22 22 23 override define CLEAN 23 24 $(RM) $(TEST_GEN_PROGS_EXTENDED) 24 - $(MAKE) -C $(GPIODIR) OUTPUT=$(GPIODIR)/ clean 25 + $(RM) -rf $(GPIOOUT) 25 26 endef 26 27 27 - $(TEST_GEN_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ) 28 + $(TEST_GEN_PROGS_EXTENDED): $(GPIOOBJ) 28 29 29 - $(GPIODIR)/$(GPIOOBJ): 30 - $(MAKE) OUTPUT=$(GPIODIR)/ -C $(GPIODIR) 30 + $(GPIOOUT): 31 + mkdir -p $@ 32 + 33 + $(GPIOOBJ): $(GPIOOUT) 34 + $(MAKE) OUTPUT=$(GPIOOUT) -C $(GPIODIR)