# Copyright (C) 2021 SCARV project <info@scarv.org>
#
# Use of this source code is restricted per the MIT license, a copy of which 
# can be found at https://opensource.org/licenses/MIT (or should be included 
# as LICENSE.txt within the associated archive or repository).

export  REPO_HOME = ${PWD}

# =============================================================================

export ALG  ?= ascon

#hash or aead
export API  ?= aead
#generic, rv32 or rv64
export ARCH ?= rv32
#nist, rv32 or rv64m if imp is nist does not allow for ASCON_RVXX_TYPE
export IMP  ?= rv32
#rvxx requires a ACSCON_RVXX_TYPEX
#export CONF ?= -DASCON_RV32_TYPE1 # -DASCON_RV32_TYPE1 or -DASCON_RV32_TYPE2 (with custom instrs)

TARGET  = ascon
ISA?=gc_zbb_zbkb_zbkx

C_SRCS  = $(wildcard *.c) 
HEADERS = $(wildcard *.h)
OPT ?= -O0
CFLAGS += $(OPT) -g
#CFLAGS += -DDRIVER_BYPASS_TEST
CFLAGS += -DDRIVER_BYPASS_TIME #Time throws a trap somewhere

BOARD=iss
LINK_TARGET=link
RISCV_ARCH:=rv32$(ISA)
ifeq ($(ISA),e)
    RISCV_ABI:=ilp32e
else
    RISCV_ABI:=ilp32
endif
LDFLAGS += -g -Wl,--wrap=printf

compiler := $(shell which riscv64-unknown-elf-gcc)
TOOL_DIR=$(dir $(compiler))

TRIPLET=riscv64-unknown-elf
BSP_BASE = ../bare-metal-bsp

all: ${TARGET}.elf

include  ${REPO_HOME}/src/Makefile
CFLAGS += ${GCC_FLAGS}

include $(BSP_BASE)/env/common-gcc.mk

