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

selftests: add headers_install to lib.mk

If the kernel headers aren't installed we can't build all the tests.
Add a new make target rule 'khdr' in the file lib.mk to generate the
kernel headers and that gets include for every test-dir Makefile that
includes lib.mk If the testdir in turn have its own sub-dirs the
top_srcdir needs to be set to the linux-rootdir to be able to generate
the kernel headers.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>

authored by

Anders Roxell and committed by
Shuah Khan (Samsung OSG)
b2d35fa5 c31d02d1

+36 -28
+1 -13
Makefile
··· 299 299 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 300 300 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 301 301 302 - # SUBARCH tells the usermode build what the underlying arch is. That is set 303 - # first, and if a usermode build is happening, the "ARCH=um" on the command 304 - # line overrides the setting of ARCH below. If a native build is happening, 305 - # then ARCH is assigned, getting whatever value it gets normally, and 306 - # SUBARCH is subsequently ignored. 307 - 308 - SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ 309 - -e s/sun4u/sparc64/ \ 310 - -e s/arm.*/arm/ -e s/sa110/arm/ \ 311 - -e s/s390x/s390/ -e s/parisc64/parisc/ \ 312 - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ 313 - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ 314 - -e s/riscv.*/riscv/) 302 + include scripts/subarch.include 315 303 316 304 # Cross compiling and selecting different set of gcc/bin-utils 317 305 # ---------------------------------------------------------------------------
+13
scripts/subarch.include
··· 1 + # SUBARCH tells the usermode build what the underlying arch is. That is set 2 + # first, and if a usermode build is happening, the "ARCH=um" on the command 3 + # line overrides the setting of ARCH below. If a native build is happening, 4 + # then ARCH is assigned, getting whatever value it gets normally, and 5 + # SUBARCH is subsequently ignored. 6 + 7 + SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ 8 + -e s/sun4u/sparc64/ \ 9 + -e s/arm.*/arm/ -e s/sa110/arm/ \ 10 + -e s/s390x/s390/ -e s/parisc64/parisc/ \ 11 + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ 12 + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ 13 + -e s/riscv.*/riscv/)
+1 -1
tools/testing/selftests/android/Makefile
··· 6 6 7 7 include ../lib.mk 8 8 9 - all: 9 + all: khdr 10 10 @for DIR in $(SUBDIRS); do \ 11 11 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 12 12 mkdir $$BUILD_TARGET -p; \
+2
tools/testing/selftests/android/ion/Makefile
··· 10 10 11 11 TEST_PROGS := ion_test.sh 12 12 13 + KSFT_KHDR_INSTALL := 1 14 + top_srcdir = ../../../../.. 13 15 include ../../lib.mk 14 16 15 17 $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c
+1
tools/testing/selftests/futex/functional/Makefile
··· 18 18 19 19 TEST_PROGS := run.sh 20 20 21 + top_srcdir = ../../../../.. 21 22 include ../../lib.mk 22 23 23 24 $(TEST_GEN_FILES): $(HEADERS)
+2 -5
tools/testing/selftests/gpio/Makefile
··· 21 21 CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ 22 22 LDLIBS += -lmount -I/usr/include/libmount 23 23 24 - $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h 24 + $(BINARIES):| khdr 25 + $(BINARIES): ../../../gpio/gpio-utils.o 25 26 26 27 ../../../gpio/gpio-utils.o: 27 28 make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio 28 - 29 - ../../../../usr/include/linux/gpio.h: 30 - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ 31 -
+2 -5
tools/testing/selftests/kvm/Makefile
··· 37 37 $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) 38 38 $(AR) crs $@ $^ 39 39 40 - $(LINUX_HDR_PATH): 41 - make -C $(top_srcdir) headers_install 42 - 43 - all: $(STATIC_LIBS) $(LINUX_HDR_PATH) 40 + all: $(STATIC_LIBS) 44 41 $(TEST_GEN_PROGS): $(STATIC_LIBS) 45 - $(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) 42 + $(STATIC_LIBS):| khdr
+12
tools/testing/selftests/lib.mk
··· 16 16 TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) 17 17 TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) 18 18 19 + top_srcdir ?= ../../../.. 20 + include $(top_srcdir)/scripts/subarch.include 21 + ARCH ?= $(SUBARCH) 22 + 19 23 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) 24 + 25 + .PHONY: khdr 26 + khdr: 27 + make ARCH=$(ARCH) -C $(top_srcdir) headers_install 28 + 29 + ifdef KSFT_KHDR_INSTALL 30 + $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr 31 + endif 20 32 21 33 .ONESHELL: 22 34 define RUN_TEST_PRINT_RESULT
+1
tools/testing/selftests/net/Makefile
··· 15 15 TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa 16 16 TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls 17 17 18 + KSFT_KHDR_INSTALL := 1 18 19 include ../lib.mk 19 20 20 21 $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma
+1
tools/testing/selftests/networking/timestamping/Makefile
··· 5 5 6 6 all: $(TEST_PROGS) 7 7 8 + top_srcdir = ../../../../.. 8 9 include ../../lib.mk 9 10 10 11 clean:
-4
tools/testing/selftests/vm/Makefile
··· 26 26 27 27 include ../lib.mk 28 28 29 - $(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h 30 29 $(OUTPUT)/userfaultfd: LDLIBS += -lpthread 31 30 32 31 $(OUTPUT)/mlock-random-test: LDLIBS += -lcap 33 - 34 - ../../../../usr/include/linux/kernel.h: 35 - make -C ../../../.. headers_install