18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci# Makefile for powerpc selftests
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci# ARCH can be overridden by the user for cross compiling
58c2ecf20Sopenharmony_ciARCH ?= $(shell uname -m)
68c2ecf20Sopenharmony_ciARCH := $(shell echo $(ARCH) | sed -e s/ppc.*/powerpc/)
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ciifeq ($(ARCH),powerpc)
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciGIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciCFLAGS := -std=gnu99 -O2 -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CURDIR)/include $(CFLAGS)
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciexport CFLAGS
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciSUB_DIRS = alignment		\
178c2ecf20Sopenharmony_ci	   benchmarks		\
188c2ecf20Sopenharmony_ci	   cache_shape		\
198c2ecf20Sopenharmony_ci	   copyloops		\
208c2ecf20Sopenharmony_ci	   dscr			\
218c2ecf20Sopenharmony_ci	   mm			\
228c2ecf20Sopenharmony_ci	   nx-gzip		\
238c2ecf20Sopenharmony_ci	   pmu			\
248c2ecf20Sopenharmony_ci	   signal		\
258c2ecf20Sopenharmony_ci	   primitives		\
268c2ecf20Sopenharmony_ci	   stringloops		\
278c2ecf20Sopenharmony_ci	   switch_endian	\
288c2ecf20Sopenharmony_ci	   syscalls		\
298c2ecf20Sopenharmony_ci	   tm			\
308c2ecf20Sopenharmony_ci	   eeh			\
318c2ecf20Sopenharmony_ci	   vphn         \
328c2ecf20Sopenharmony_ci	   math		\
338c2ecf20Sopenharmony_ci	   ptrace	\
348c2ecf20Sopenharmony_ci	   security
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciendif
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciall: $(SUB_DIRS)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci$(SUB_DIRS):
418c2ecf20Sopenharmony_ci	BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciinclude ../lib.mk
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cioverride define RUN_TESTS
468c2ecf20Sopenharmony_ci	@for TARGET in $(SUB_DIRS); do \
478c2ecf20Sopenharmony_ci		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
488c2ecf20Sopenharmony_ci		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
498c2ecf20Sopenharmony_ci	done;
508c2ecf20Sopenharmony_ciendef
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cioverride define INSTALL_RULE
538c2ecf20Sopenharmony_ci	@for TARGET in $(SUB_DIRS); do \
548c2ecf20Sopenharmony_ci		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
558c2ecf20Sopenharmony_ci		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\
568c2ecf20Sopenharmony_ci	done;
578c2ecf20Sopenharmony_ciendef
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cioverride define EMIT_TESTS
608c2ecf20Sopenharmony_ci	@for TARGET in $(SUB_DIRS); do \
618c2ecf20Sopenharmony_ci		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
628c2ecf20Sopenharmony_ci		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\
638c2ecf20Sopenharmony_ci	done;
648c2ecf20Sopenharmony_ciendef
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cioverride define CLEAN
678c2ecf20Sopenharmony_ci	@for TARGET in $(SUB_DIRS); do \
688c2ecf20Sopenharmony_ci		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
698c2ecf20Sopenharmony_ci		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
708c2ecf20Sopenharmony_ci	done;
718c2ecf20Sopenharmony_ci	rm -f tags
728c2ecf20Sopenharmony_ciendef
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_citags:
758c2ecf20Sopenharmony_ci	find . -name '*.c' -o -name '*.h' | xargs ctags
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci.PHONY: tags $(SUB_DIRS)
78