gadget-weather-station/src/Makefile
2022-09-01 09:45:49 +02:00

95 lines
1.7 KiB
Makefile

CROSS_COMPILE=riscv32-unknown-elf-
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)gcc
AR=$(CROSS_COMPILE)ar
AS=$(CROSS_COMPILE)gcc
LSCRIPT=RISCV/env_Eclipse/GD32VF103xB.lds
#LSCRIPT=target.ld
LDFLAGS+=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -ffreestanding -nostartfiles -fdata-sections -ffunction-sections
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -march=rv32imac -mabi=ilp32 -mcmodel=medlow -fmessage-length=0
#CFLAGS+=--specs=nosys.specs
CFLAGS+=--specs=nano.specs
CFLAGS+=-Os
CFLAGS+=-DGD32VF103C_START
CFLAGS+=-IGD32VF103 -IGD32VF103/Include
CFLAGS+=-I.. -I../include
CFLAGS+=-IRISCV/drivers
OBJS= \
main.o \
start.o \
entry.o \
n200_func.o \
handlers.o \
system_gd32vf103.o \
gd32vf103_adc.o \
gd32vf103_bkp.o \
gd32vf103_can.o \
gd32vf103_crc.o \
gd32vf103_dac.o \
gd32vf103_dbg.o \
gd32vf103_dma.o \
gd32vf103_eclic.o \
gd32vf103_exmc.o \
gd32vf103_exti.o \
gd32vf103_fmc.o \
gd32vf103_fwdgt.o \
gd32vf103_gpio.o \
gd32vf103_i2c.o \
gd32vf103_pmu.o \
gd32vf103_rcu.o \
gd32vf103_rtc.o \
gd32vf103_spi.o \
gd32vf103_timer.o \
gd32vf103_usart.o \
gd32vf103_wwdgt.o \
ff.o \
ffsystem.o \
ffunicode.o \
tf_card.o \
lcd.o \
systick.o
all: image.bin
image.bin: image.elf
$(CROSS_COMPILE)objcopy -O binary $< $@
vpath %.c ./GD32VF103/Source
vpath %.c ./GD32VF103
vpath %.c ./RISCV/drivers
vpath %.c ./RISCV/env_Eclipse
vpath %.c ./fatfs
vpath %.c ./lcd
image.elf: $(OBJS)
@echo [LD] $@
@$(LD) $(CFLAGS) $(LDFLAGS) $(^) -o $(@)
start.o: ./RISCV/env_Eclipse/start.S
@echo [AS] $@
@$(AS) $(CFLAGS) -c -o $(@) $(^)
entry.o: ./RISCV/env_Eclipse/entry.S
@echo [AS] $@
@$(AS) $(CFLAGS) -c -o $(@) $(^)
%.o: %.c
@echo [CC] $@
@$(CC) -o $@ -c $^ $(CFLAGS)
clean:
@echo [CLEAN]
@rm -f $(OBJS)
@rm -f *.bin *.elf