2020-04-06 13:28:56 +00:00
|
|
|
|
|
|
|
RISCV_PATH := ../../../tools/gnu-mcu-eclipse-riscv-none-gcc-8.2.0-2.2-20190521-0004-win64/
|
|
|
|
|
|
|
|
RISCV_GCC := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-gcc)
|
|
|
|
RISCV_AS := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-as)
|
|
|
|
RISCV_GXX := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-g++)
|
|
|
|
RISCV_OBJDUMP := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-objdump)
|
|
|
|
RISCV_GDB := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-gdb)
|
|
|
|
RISCV_AR := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-ar)
|
|
|
|
RISCV_OBJCOPY := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-objcopy)
|
|
|
|
RISCV_READELF := $(abspath $(RISCV_PATH)/bin/riscv-none-embed-readelf)
|
2020-04-11 11:03:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
|
|
|
|
COMMON_DIR = ..
|
|
|
|
|
|
|
|
ASM_SRCS += $(COMMON_DIR)/start.S
|
|
|
|
ASM_SRCS += $(COMMON_DIR)/trap_entry.S
|
|
|
|
C_SRCS += $(COMMON_DIR)/init.c
|
|
|
|
C_SRCS += $(COMMON_DIR)/lib/utils.c
|
|
|
|
C_SRCS += $(COMMON_DIR)/lib/xprintf.c
|
2020-04-12 11:36:06 +00:00
|
|
|
C_SRCS += $(COMMON_DIR)/lib/uart.c
|
2020-04-11 11:03:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
LINKER_SCRIPT := $(COMMON_DIR)/link.lds
|
|
|
|
|
|
|
|
INCLUDES += -I$(COMMON_DIR)
|
|
|
|
|
|
|
|
LDFLAGS += -T $(LINKER_SCRIPT) -nostartfiles -Wl,--gc-sections -Wl,--check-sections
|
|
|
|
|
|
|
|
ASM_OBJS := $(ASM_SRCS:.S=.o)
|
|
|
|
C_OBJS := $(C_SRCS:.c=.o)
|
|
|
|
|
|
|
|
LINK_OBJS += $(ASM_OBJS) $(C_OBJS)
|
|
|
|
LINK_DEPS += $(LINKER_SCRIPT)
|
|
|
|
|
|
|
|
CLEAN_OBJS += $(TARGET) $(LINK_OBJS) $(TARGET).dump $(TARGET).bin
|
|
|
|
|
|
|
|
#CFLAGS += -g
|
|
|
|
CFLAGS += -march=$(RISCV_ARCH)
|
|
|
|
CFLAGS += -mabi=$(RISCV_ABI)
|
|
|
|
CFLAGS += -mcmodel=medany -ffunction-sections -fdata-sections -fno-builtin-printf -fno-builtin-malloc
|
|
|
|
|
|
|
|
$(TARGET): $(LINK_OBJS) $(LINK_DEPS)
|
|
|
|
$(RISCV_GCC) $(CFLAGS) $(INCLUDES) $(LINK_OBJS) -o $@ $(LDFLAGS)
|
|
|
|
$(RISCV_OBJCOPY) -O binary $@ $@.bin
|
|
|
|
$(RISCV_OBJDUMP) --disassemble-all $@ > $@.dump
|
|
|
|
|
|
|
|
$(ASM_OBJS): %.o: %.S
|
|
|
|
$(RISCV_GCC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
|
|
|
|
|
|
|
$(C_OBJS): %.o: %.c
|
|
|
|
$(RISCV_GCC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -f $(CLEAN_OBJS)
|