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 abi
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
20CFLAGS += $(KHDR_INCLUDES)
21
22export CFLAGS
23export top_srcdir
24
25all:
26	@for DIR in $(ARM64_SUBTARGETS); do				\
27		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
28		mkdir -p $$BUILD_TARGET;			\
29		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
30	done
31
32install: all
33	@for DIR in $(ARM64_SUBTARGETS); do				\
34		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
35		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
36	done
37
38run_tests: all
39	@for DIR in $(ARM64_SUBTARGETS); do				\
40		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
41		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
42	done
43
44# Avoid any output on non arm64 on emit_tests
45emit_tests:
46	@for DIR in $(ARM64_SUBTARGETS); do				\
47		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
48		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
49	done
50
51clean:
52	@for DIR in $(ARM64_SUBTARGETS); do				\
53		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
54		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
55	done
56
57.PHONY: all clean install run_tests emit_tests
58