1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
20e56dacdSMichael Ellerman# Makefile for powerpc selftests
30e56dacdSMichael Ellerman
40e56dacdSMichael Ellerman# ARCH can be overridden by the user for cross compiling
50e56dacdSMichael EllermanARCH ?= $(shell uname -m)
60e56dacdSMichael EllermanARCH := $(shell echo $(ARCH) | sed -e s/ppc.*/powerpc/)
70e56dacdSMichael Ellerman
80e56dacdSMichael Ellermanifeq ($(ARCH),powerpc)
90e56dacdSMichael Ellerman
100e56dacdSMichael EllermanGIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
110e56dacdSMichael Ellerman
123d2e03f8SChijun SimaCFLAGS := -std=gnu99 -O2 -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CURDIR)/include $(CFLAGS)
130e56dacdSMichael Ellerman
1484f887bfSMichael Ellermanexport CFLAGS
150e56dacdSMichael Ellerman
1643750880SChris SmartSUB_DIRS = alignment		\
1743750880SChris Smart	   benchmarks		\
18b8b6ff01SMichael Ellerman	   cache_shape		\
1965b6ba63SMichael Ellerman	   copyloops		\
2065b6ba63SMichael Ellerman	   dscr			\
2165b6ba63SMichael Ellerman	   mm			\
2265b6ba63SMichael Ellerman	   pmu			\
23ef186331SCyril Bur	   signal		\
2465b6ba63SMichael Ellerman	   primitives		\
2565b6ba63SMichael Ellerman	   stringloops		\
2665b6ba63SMichael Ellerman	   switch_endian	\
2765b6ba63SMichael Ellerman	   syscalls		\
2865b6ba63SMichael Ellerman	   tm			\
2901127f1eSCyril Bur	   vphn         \
30f666ad41SAnshuman Khandual	   math		\
31*d2bf7932SNaveen N. Rao	   ptrace	\
32*d2bf7932SNaveen N. Rao	   security
330e56dacdSMichael Ellerman
340e56dacdSMichael Ellermanendif
350e56dacdSMichael Ellerman
36a908f5deSMichael Ellermanall: $(SUB_DIRS)
37cbfd7dabSMichael Ellerman
38a908f5deSMichael Ellerman$(SUB_DIRS):
392db2c250SMichael Ellerman	BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all
400e56dacdSMichael Ellerman
416faeeea4SMichael Ellermaninclude ../lib.mk
426faeeea4SMichael Ellerman
436faeeea4SMichael Ellermanoverride define RUN_TESTS
44a908f5deSMichael Ellerman	@for TARGET in $(SUB_DIRS); do \
452db2c250SMichael Ellerman		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
46a8ba798bS[email protected]		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
470e56dacdSMichael Ellerman	done;
486faeeea4SMichael Ellermanendef
496faeeea4SMichael Ellerman
506faeeea4SMichael Ellermanoverride define INSTALL_RULE
51d19d5efdSLinus Torvalds	@for TARGET in $(SUB_DIRS); do \
522db2c250SMichael Ellerman		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
53a8ba798bS[email protected]		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\
546faeeea4SMichael Ellerman	done;
556faeeea4SMichael Ellermanendef
566faeeea4SMichael Ellerman
576faeeea4SMichael Ellermanoverride define EMIT_TESTS
58d19d5efdSLinus Torvalds	@for TARGET in $(SUB_DIRS); do \
592db2c250SMichael Ellerman		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
60a8ba798bS[email protected]		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\
616faeeea4SMichael Ellerman	done;
626faeeea4SMichael Ellermanendef
630e56dacdSMichael Ellerman
64337f1e36SShuah Khanoverride define CLEAN
65a908f5deSMichael Ellerman	@for TARGET in $(SUB_DIRS); do \
662db2c250SMichael Ellerman		BUILD_TARGET=$(OUTPUT)/$$TARGET;	\
672e8ec87dSMichael Ellerman		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
682e8ec87dSMichael Ellerman	done;
690e56dacdSMichael Ellerman	rm -f tags
70337f1e36SShuah Khanendef
710e56dacdSMichael Ellerman
720e56dacdSMichael Ellermantags:
730e56dacdSMichael Ellerman	find . -name '*.c' -o -name '*.h' | xargs ctags
740e56dacdSMichael Ellerman
75d19d5efdSLinus Torvalds.PHONY: tags $(SUB_DIRS)
76