RISC-V/V003/hdo/Makefile

56 lines
1.2 KiB
Makefile
Raw Permalink Normal View History

2024-03-07 13:46:47 +01:00
# ch32v003 | stm32f051
2024-03-04 22:23:14 +01:00
TARGET?= ch32v003
2024-03-07 13:46:47 +01:00
#TARGET?= stm32f051
2024-03-04 22:23:14 +01:00
TOOL ?= gcc
2024-03-07 13:46:47 +01:00
# do not use for ch32v003
#TOOL ?= clang
2024-03-04 22:23:14 +01:00
PRJ = example
VPATH = . ./$(TARGET) ./common
BLD = ./build/
DFLAGS = -d
LFLAGS = -g
LDLIBS =
BFLAGS = --strip-unneeded
CFLAGS = -MMD -Wall -ggdb -fno-exceptions -ffunction-sections -fdata-sections
CFLAGS+= -I. -I./common -I./$(TARGET) -I/usr/include/newlib -DUSE_HSE=1
DEL = rm -f
# zdrojaky
2024-03-07 12:23:44 +01:00
OBJS = main.o adcdma.o hdo.o
OBJS += usart.o print.o
2024-03-04 22:23:14 +01:00
include $(TARGET)/$(TOOL).mk
BOBJS = $(addprefix $(BLD),$(OBJS))
all: $(BLD) $(PRJ).elf
# ... atd.
-include $(BLD)*.d
# linker
$(PRJ).elf: $(BOBJS)
-@echo [LD $(TOOL),$(TARGET)] $@
@$(LD) $(LFLAGS) -o $(PRJ).elf $(BOBJS) $(LDLIBS)
-@echo "size:"
@$(SIZE) $(PRJ).elf
-@echo "listing:"
$(DUMP) $(DFLAGS) $(PRJ).elf > $(PRJ).lst
-@echo "OK."
$(COPY) $(BFLAGS) -O binary $(PRJ).elf $(PRJ).bin
# preloz co je potreba
$(BLD)%.o: %.c
-@echo [CC $(TOOL),$(TARGET)] $@
@$(CC) -c $(CFLAGS) $< -o $@
$(BLD)%.o: %.cpp
-@echo [CX $(TOOL),$(TARGET)] $@
@$(CXX) -std=c++17 -fno-rtti -c $(CFLAGS) $< -o $@
$(BLD):
mkdir $(BLD)
2024-03-07 13:46:47 +01:00
flash: $(BLD) $(PRJ).elf
2024-03-04 22:23:14 +01:00
minichlink -w $(PRJ).bin flash -b
# vycisti
clean:
$(DEL) $(BLD)* *.lst *.bin *.elf *.map sin.c *~
2024-03-07 13:46:47 +01:00
.PHONY: all clean flash