1# SPDX-License-Identifier: GPL-2.0
2# Copyright (C) 2020 ARM Limited
3
4# preserve CC value from top level Makefile
5ifeq ($(CC),cc)
6CC := $(CROSS_COMPILE)gcc
7endif
8
9CFLAGS += -std=gnu99 -I. -pthread
10LDFLAGS += -pthread
11SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
12PROGS := $(patsubst %.c,%,$(SRCS))
13
14#Add mte compiler option
15CFLAGS += -march=armv8.5-a+memtag
16
17#check if the compiler works well
18mte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
19
20ifeq ($(mte_cc_support),1)
21# Generated binaries to be installed by top KSFT script
22TEST_GEN_PROGS := $(PROGS)
23
24# Get Kernel headers installed and use them.
25KSFT_KHDR_INSTALL := 1
26else
27    $(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
28    $(warning test program "mte" will not be created.)
29endif
30
31# Include KSFT lib.mk.
32include ../../lib.mk
33
34ifeq ($(mte_cc_support),1)
35$(TEST_GEN_PROGS): mte_common_util.c mte_helper.S
36endif
37