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