1e9b60476SAmit Daniel Kachhap# SPDX-License-Identifier: GPL-2.0
2e9b60476SAmit Daniel Kachhap# Copyright (C) 2020 ARM Limited
3e9b60476SAmit Daniel Kachhap
45238c2cdSAndre Przywara# preserve CC value from top level Makefile
55238c2cdSAndre Przywaraifeq ($(CC),cc)
65238c2cdSAndre PrzywaraCC := $(CROSS_COMPILE)gcc
75238c2cdSAndre Przywaraendif
85238c2cdSAndre Przywara
9e5decefdSAndre PrzywaraCFLAGS += -std=gnu99 -I. -pthread
10e5decefdSAndre PrzywaraLDFLAGS += -pthread
11e9b60476SAmit Daniel KachhapSRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
12e9b60476SAmit Daniel KachhapPROGS := $(patsubst %.c,%,$(SRCS))
13e9b60476SAmit Daniel Kachhap
14e9b60476SAmit Daniel Kachhap#Add mte compiler option
15e9b60476SAmit Daniel KachhapCFLAGS += -march=armv8.5-a+memtag
16e9b60476SAmit Daniel Kachhap
17e9b60476SAmit Daniel Kachhap#check if the compiler works well
18e9b60476SAmit Daniel Kachhapmte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
19e9b60476SAmit Daniel Kachhap
20e9b60476SAmit Daniel Kachhapifeq ($(mte_cc_support),1)
21e9b60476SAmit Daniel Kachhap# Generated binaries to be installed by top KSFT script
22e9b60476SAmit Daniel KachhapTEST_GEN_PROGS := $(PROGS)
23e9b60476SAmit Daniel Kachhap
24e9b60476SAmit Daniel Kachhap# Get Kernel headers installed and use them.
25e9b60476SAmit Daniel KachhapKSFT_KHDR_INSTALL := 1
268bbb58a3SAndre Przywaraelse
278bbb58a3SAndre Przywara    $(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
288bbb58a3SAndre Przywara    $(warning test program "mte" will not be created.)
29e9b60476SAmit Daniel Kachhapendif
30e9b60476SAmit Daniel Kachhap
31e9b60476SAmit Daniel Kachhap# Include KSFT lib.mk.
32e9b60476SAmit Daniel Kachhapinclude ../../lib.mk
33e9b60476SAmit Daniel Kachhap
34e9b60476SAmit Daniel Kachhapifeq ($(mte_cc_support),1)
35*9466ecacSAndre Przywara$(TEST_GEN_PROGS): mte_common_util.c mte_helper.S
36e9b60476SAmit Daniel Kachhapendif
37