-
Notifications
You must be signed in to change notification settings - Fork 1
/
bonfire_defs.Makefile.include
70 lines (49 loc) · 1.87 KB
/
bonfire_defs.Makefile.include
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#BASE_DIR?=$(HOME)/development/bonfire/bonfire-software
BASE_DIR?=$(CURDIR)/..
PLATFORM?=ARTY_AXI
ARCH?=rv32im
ABI?=ilp32
DEBUGFLAG?=NODEBUG
BUILD ?=build
UPLOAD_DIR?=~/upload
TARGET_PREFIX ?= riscv32-unknown-elf
TARGET_CC := $(TARGET_PREFIX)-gcc
TARGET_LD := $(TARGET_PREFIX)-gcc
TARGET_AR := $(TARGET_PREFIX)-ar
TARGET_SIZE := $(TARGET_PREFIX)-size
TARGET_OBJCOPY := $(TARGET_PREFIX)-objcopy
HEXDUMP ?= hexdump
PLATFORMDIR=$(BASE_DIR)/platform
LINKDEF_DRAM?=ram_default.ld
LINKDEF?=$(PLATFORMDIR)/$(PLATFORM)/firmware.ld
INCLUDES+= -I$(PLATFORMDIR) -I$(PLATFORMDIR)/$(PLATFORM)
TARGET_CFLAGS += -march=$(ARCH) -mabi=$(ABI) -Wall -Og -g -fomit-frame-pointer -fno-inline-functions-called-once \
-ffreestanding -fno-builtin -mstrict-align \
-Wall -Werror=implicit-function-declaration \
-DBONFIRE -D$(PLATFORM) -D$(DEBUGFLAG) $(INCLUDES) \
TARGET_LDFLAGS_SYSCALL += -march=$(ARCH) -mabi=$(ABI) \
-Wl,--gc-sections -L$(BASE_DIR) -Wl,-T$(LINKDEF_DRAM)
DEPS = $(OBJECTS:%.o=%.d)
-include $(DEPS)
.SECONDARY: $(DEPS) $(OBJECTS)
$(BUILD)/%.o : %.S
$(TARGET_CC) $(TARGET_CFLAGS) -c $< -o $@
$(BUILD)/%.o : %.c
$(TARGET_CC) $(TARGET_CFLAGS) -c $< -o $@
$(BUILD)/%.d : %.c
$(TARGET_CC) -MM $(TARGET_CFLAGS) $< >$(basename $@).d
sed -i '1s;^;$(BUILD)/;' $(basename $@).d
$(BUILD)/%.bin : $(BUILD)/%.elf
$(TARGET_OBJCOPY) -S -O binary $< $@
cp $@ $(UPLOAD_DIR)
$(TARGET_PREFIX)-objdump -S -d $< >$(basename $@).lst
$(TARGET_PREFIX)-objdump -s $< >$(basename $@).dmp
$(TARGET_PREFIX)-size $<
$(BUILD)/%.hex : $(BUILD)/%.elf
$(TARGET_OBJCOPY) -S -O $< $(basename $@).bin
$(HEXDUMP) -v -e '1/4 "%08x\n"' $(basename $@).bin >$@
$(TARGET_PREFIX)-objdump -S -d $< >$(basename $@).lst
$(TARGET_PREFIX)-objdump -s $< >$(basename $@).dmp
$(TARGET_PREFIX)-size $<
$(BUILD)/%.elf : $(OBJECTS)
$(TARGET_LD) -o $@ $(TARGET_LDFLAGS_SYSCALL) $^ $(LIBS) # -lg -lm -lgloss