162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci# Copyright (C) 2019 ARM Limited
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci# Additional include paths needed by kselftest.h and local headers
562306a36Sopenharmony_ciCFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciSRCS := $(filter-out testcases/testcases.c,$(wildcard testcases/*.c))
862306a36Sopenharmony_ciPROGS := $(patsubst %.c,%,$(SRCS))
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci# Generated binaries to be installed by top KSFT script
1162306a36Sopenharmony_ciTEST_GEN_PROGS := $(notdir $(PROGS))
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci# Get Kernel headers installed and use them.
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list
1662306a36Sopenharmony_ci# to account for any OUTPUT target-dirs optionally provided by
1762306a36Sopenharmony_ci# the toplevel makefile
1862306a36Sopenharmony_ciinclude ../../lib.mk
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci$(TEST_GEN_PROGS): $(PROGS)
2162306a36Sopenharmony_ci	cp $(PROGS) $(OUTPUT)/
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci# Common test-unit targets to build common-layout test-cases executables
2462306a36Sopenharmony_ci# Needs secondary expansion to properly include the testcase c-file in pre-reqs
2562306a36Sopenharmony_ciCOMMON_SOURCES := test_signals.c test_signals_utils.c testcases/testcases.c \
2662306a36Sopenharmony_ci	signals.S
2762306a36Sopenharmony_ciCOMMON_HEADERS := test_signals.h test_signals_utils.h testcases/testcases.h
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci.SECONDEXPANSION:
3062306a36Sopenharmony_ci$(PROGS): $$@.c ${COMMON_SOURCES} ${COMMON_HEADERS}
3162306a36Sopenharmony_ci	$(CC) $(CFLAGS) ${@}.c ${COMMON_SOURCES} -o $@
32