162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_cinoarg:
362306a36Sopenharmony_ci	$(MAKE) -C ../
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciTEST_GEN_PROGS := count_instructions count_stcx_fail l3_bank_test per_event_excludes
662306a36Sopenharmony_ciEXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c
762306a36Sopenharmony_ci
862306a36Sopenharmony_citop_srcdir = ../../../../..
962306a36Sopenharmony_ciinclude ../../lib.mk
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciall: $(TEST_GEN_PROGS) ebb sampling_tests event_code_tests
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci# loop.S can only be built 64-bit
1662306a36Sopenharmony_ci$(OUTPUT)/count_instructions: CFLAGS += -m64
1762306a36Sopenharmony_ci$(OUTPUT)/count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci$(OUTPUT)/count_stcx_fail: CFLAGS += -m64
2062306a36Sopenharmony_ci$(OUTPUT)/count_stcx_fail: loop.S $(EXTRA_SOURCES)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci$(OUTPUT)/per_event_excludes: ../utils.c
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciDEFAULT_RUN_TESTS := $(RUN_TESTS)
2662306a36Sopenharmony_cioverride define RUN_TESTS
2762306a36Sopenharmony_ci	$(DEFAULT_RUN_TESTS)
2862306a36Sopenharmony_ci	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests
2962306a36Sopenharmony_ci	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests
3062306a36Sopenharmony_ci	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests
3162306a36Sopenharmony_ciendef
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciemit_tests:
3462306a36Sopenharmony_ci	for TEST in $(TEST_GEN_PROGS); do \
3562306a36Sopenharmony_ci		BASENAME_TEST=`basename $$TEST`;	\
3662306a36Sopenharmony_ci		echo "$(COLLECTION):$$BASENAME_TEST";	\
3762306a36Sopenharmony_ci	done
3862306a36Sopenharmony_ci	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests
3962306a36Sopenharmony_ci	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests
4062306a36Sopenharmony_ci	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciDEFAULT_INSTALL_RULE := $(INSTALL_RULE)
4362306a36Sopenharmony_cioverride define INSTALL_RULE
4462306a36Sopenharmony_ci	$(DEFAULT_INSTALL_RULE)
4562306a36Sopenharmony_ci	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
4662306a36Sopenharmony_ci	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
4762306a36Sopenharmony_ci	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
4862306a36Sopenharmony_ciendef
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciDEFAULT_CLEAN := $(CLEAN)
5162306a36Sopenharmony_cioverride define CLEAN
5262306a36Sopenharmony_ci	$(DEFAULT_CLEAN)
5362306a36Sopenharmony_ci	$(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o
5462306a36Sopenharmony_ci	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
5562306a36Sopenharmony_ci	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
5662306a36Sopenharmony_ci	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
5762306a36Sopenharmony_ciendef
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciebb:
6062306a36Sopenharmony_ci	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cisampling_tests:
6362306a36Sopenharmony_ci	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_cievent_code_tests:
6662306a36Sopenharmony_ci	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci.PHONY: all run_tests ebb sampling_tests event_code_tests emit_tests
69