-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mk
47 lines (34 loc) · 766 Bytes
/
build.mk
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
PREFIX = riscv64-unknown-elf
OC = $(PREFIX)-objcopy
CC = $(PREFIX)-gcc
SZ = $(PREFIX)-size
READELF = $(PREFIX)-readelf
OBJDUMP = $(PREFIX)-objdump
NM = $(PREFIX)-nm
FLAGS = -Os -mabi=ilp32 -nostdlib -ffreestanding -Wall -Wl,-Map,$(TARGET).map
all: $(TARGET).elf
$(TARGET).elf: $(SRC)
$(CC) $(FLAGS) -o $@ $^
$(TARGET).bin: $(TARGET).elf
$(OC) -O binary $^ $@
clean:
$(RM) *.elf
$(RM) *.bin
$(RM) *.map
$(RM) *.dmp
$(RM) *.html
bin: $(TARGET).bin
load: $(TARGET).bin
../openocd -f ../wch-riscv.cfg -c "program $(TARGET).bin reset exit"
edit:
nano main.c
touch:
touch $(SRC)
size: $(TARGET).elf
$(SZ) --format=SysV $^
readelf: $(TARGET).elf
$(READELF) $^ -a
objdump: $(TARGET).elf
$(OBJDUMP) -D > $(TARGET).dmp $^
nm: $(TARGET).elf
$(NM) $^