162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci# Copyright (C) 2020 ARM Limited
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciCFLAGS += -std=gnu99 -I. -pthread
562306a36Sopenharmony_ciLDFLAGS += -pthread
662306a36Sopenharmony_ciSRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
762306a36Sopenharmony_ciPROGS := $(patsubst %.c,%,$(SRCS))
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciifeq ($(LLVM),)
1062306a36Sopenharmony_ci# For GCC check that the toolchain has MTE support.
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci# preserve CC value from top level Makefile
1362306a36Sopenharmony_ciifeq ($(CC),cc)
1462306a36Sopenharmony_ciCC := $(CROSS_COMPILE)gcc
1562306a36Sopenharmony_ciendif
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#check if the compiler works well
1862306a36Sopenharmony_cimte_cc_support := $(shell if ($(CC) $(CFLAGS) -march=armv8.5-a+memtag -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cielse
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci# All supported clang versions also support MTE.
2362306a36Sopenharmony_cimte_cc_support := 1
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciendif
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciifeq ($(mte_cc_support),1)
2862306a36Sopenharmony_ci# Generated binaries to be installed by top KSFT script
2962306a36Sopenharmony_ciTEST_GEN_PROGS := $(PROGS)
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cielse
3262306a36Sopenharmony_ci    $(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
3362306a36Sopenharmony_ci    $(warning test program "mte" will not be created.)
3462306a36Sopenharmony_ciendif
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci# Include KSFT lib.mk.
3762306a36Sopenharmony_ciinclude ../../lib.mk
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciifeq ($(mte_cc_support),1)
4062306a36Sopenharmony_ci$(TEST_GEN_PROGS): mte_common_util.c mte_helper.S
4162306a36Sopenharmony_ciendif
42