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
62emit_tests:
63	+@for TARGET in $(SUB_DIRS); do \
64		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
65		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET $@;\
66	done;
67
68override define CLEAN
69	+@for TARGET in $(SUB_DIRS); do \
70		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
71		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
72	done;
73	rm -f tags
74endef
75
76tags:
77	find . -name '*.c' -o -name '*.h' | xargs ctags
78
79.PHONY: tags $(SUB_DIRS) emit_tests
80