1# SPDX-License-Identifier: GPL-2.0
2# Makefile for powerpc selftests
3
4# ARCH can be overridden by the user for cross compiling
5ARCH ?= $(shell uname -m)
6ARCH := $(shell echo $(ARCH) | sed -e s/ppc.*/powerpc/)
7
8ifeq ($(ARCH),powerpc)
9
10GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
11
12CFLAGS := -std=gnu99 -O2 -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CURDIR)/include $(CFLAGS)
13
14export CFLAGS
15
16SUB_DIRS = alignment		\
17	   benchmarks		\
18	   cache_shape		\
19	   copyloops		\
20	   dscr			\
21	   mm			\
22	   pmu			\
23	   signal		\
24	   primitives		\
25	   stringloops		\
26	   switch_endian	\
27	   syscalls		\
28	   tm			\
29	   vphn         \
30	   math		\
31	   ptrace	\
32	   security
33
34endif
35
36all: $(SUB_DIRS)
37
38$(SUB_DIRS):
39	BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all
40
41include ../lib.mk
42
43override define RUN_TESTS
44	@for TARGET in $(SUB_DIRS); do \
45		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
46		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
47	done;
48endef
49
50override define INSTALL_RULE
51	@for TARGET in $(SUB_DIRS); do \
52		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
53		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\
54	done;
55endef
56
57override define EMIT_TESTS
58	@for TARGET in $(SUB_DIRS); do \
59		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
60		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\
61	done;
62endef
63
64override define CLEAN
65	@for TARGET in $(SUB_DIRS); do \
66		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
67		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
68	done;
69	rm -f tags
70endef
71
72tags:
73	find . -name '*.c' -o -name '*.h' | xargs ctags
74
75.PHONY: tags $(SUB_DIRS)
76