1# SPDX-License-Identifier: GPL-2.0 2 3# When ARCH not overridden for crosscompiling, lookup machine 4ARCH ?= $(shell uname -m 2>/dev/null || echo not) 5 6ifneq (,$(filter $(ARCH),aarch64 arm64)) 7ARM64_SUBTARGETS ?= tags signal pauth fp mte bti 8else 9ARM64_SUBTARGETS := 10endif 11 12CFLAGS := -Wall -O2 -g 13 14# A proper top_srcdir is needed by KSFT(lib.mk) 15top_srcdir = $(realpath ../../../../) 16 17# Additional include paths needed by kselftest.h and local headers 18CFLAGS += -I$(top_srcdir)/tools/testing/selftests/ 19 20# Guessing where the Kernel headers could have been installed 21# depending on ENV config 22ifeq ($(KBUILD_OUTPUT),) 23khdr_dir = $(top_srcdir)/usr/include 24else 25# the KSFT preferred location when KBUILD_OUTPUT is set 26khdr_dir = $(KBUILD_OUTPUT)/kselftest/usr/include 27endif 28 29CFLAGS += -I$(khdr_dir) 30 31export CFLAGS 32export top_srcdir 33 34all: 35 @for DIR in $(ARM64_SUBTARGETS); do \ 36 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 37 mkdir -p $$BUILD_TARGET; \ 38 make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 39 done 40 41install: all 42 @for DIR in $(ARM64_SUBTARGETS); do \ 43 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 44 make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 45 done 46 47run_tests: all 48 @for DIR in $(ARM64_SUBTARGETS); do \ 49 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 50 make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 51 done 52 53# Avoid any output on non arm64 on emit_tests 54emit_tests: all 55 @for DIR in $(ARM64_SUBTARGETS); do \ 56 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 57 make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 58 done 59 60clean: 61 @for DIR in $(ARM64_SUBTARGETS); do \ 62 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 63 make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \ 64 done 65 66.PHONY: all clean install run_tests emit_tests 67