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