-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
26 lines (19 loc) · 682 Bytes
/
Copy pathMakefile
File metadata and controls
26 lines (19 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
SRC_DIR ?= ./
OBJ_DIR ?= ./
SOURCES ?= $(shell find $(SRC_DIR) -name '*.c' -or -name '*.S')
OBJECTS ?= $(addsuffix .o, $(basename $(notdir $(SOURCES))))
LINKER ?= $(SRC_DIR)/dtekv-script.lds
TOOLCHAIN ?= riscv32-unknown-elf-
CFLAGS ?= -Wall -nostdlib -O3 -mabi=ilp32 -march=rv32imzicsr -fno-builtin
build: clean main.bin
main.elf:
$(TOOLCHAIN)gcc -c $(CFLAGS) $(SOURCES)
$(TOOLCHAIN)ld -o $@ -T $(LINKER) $(filter-out boot.o, $(OBJECTS)) softfloat.a
main.bin: main.elf
$(TOOLCHAIN)objcopy --output-target binary $< $@
$(TOOLCHAIN)objdump -D $< > $<.txt
clean:
rm -f *.o *.elf *.bin *.txt
TOOL_DIR ?= ./tools
run: main.bin
make -C $(TOOL_DIR) "FILE_TO_RUN=$(CURDIR)/$<"