TARGET ?= main
TARGET_MCU ?= CH32V203
TARGET_MCU_PACKAGE ?= CH32V203C8T6

CH32V003FUN ?= ./ch32fun/ch32fun
MINICHLINK ?= ./ch32fun/minichlink

PREFIX ?= riscv64-elf
NEWLIB ?= /usr/riscv64-elf/include/

INCLUDE_DIRS += \
	-I./inc 

PROJECT_C_FILES := $(filter-out ./main.c, $(wildcard ./*.c))
LIB_C_FILES := 

ADDITIONAL_C_FILES := \
	$(PROJECT_C_FILES) \
	$(LIB_C_FILES)

include $(CH32V003FUN)/ch32fun.mk

CFLAGS := $(filter-out -nostdlib,$(CFLAGS))
LDFLAGS := $(filter-out -nostdlib,$(LDFLAGS))
NANO_FLAGS := -nostartfiles --specs=nano.specs --specs=nosys.specs -lc -lm

CFLAGS += -Wall -Wextra $(INCLUDE_DIRS) $(NANO_FLAGS)

all: flash
flash: cv_flash
clean: cv_clean
.PHONY: all flash clean
