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	   eeh			\
30	   vphn         \
31	   math		\
32	   ptrace	\
33	   security
34
35endif
36
37all: $(SUB_DIRS)
38
39$(SUB_DIRS):
40	BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all
41
42include ../lib.mk
43
44override define RUN_TESTS
45	@for TARGET in $(SUB_DIRS); do \
46		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
47		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
48	done;
49endef
50
51override define INSTALL_RULE
52	@for TARGET in $(SUB_DIRS); do \
53		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
54		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\
55	done;
56endef
57
58override define EMIT_TESTS
59	@for TARGET in $(SUB_DIRS); do \
60		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
61		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\
62	done;
63endef
64
65override define CLEAN
66	@for TARGET in $(SUB_DIRS); do \
67		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
68		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
69	done;
70	rm -f tags
71endef
72
73tags:
74	find . -name '*.c' -o -name '*.h' | xargs ctags
75
76.PHONY: tags $(SUB_DIRS)
77