-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.gcc.in
executable file
·35 lines (27 loc) · 931 Bytes
/
Makefile.gcc.in
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
RISCV_PACKAGE := riscv64-linux-gnu
RISCV_DEFAULT := riscv64-unknown-elf
RISCV_DEFAULT_PRESENT := $(shell command -v $(RISCV_DEFAULT)-gcc 2> /dev/null)
ifdef RISCV_DEFAULT_PRESENT
RISCV := $(RISCV_DEFAULT)
else
RISCV := $(RISCV_PACKAGE)
endif
LIB_PATH := ../151_library
LIB_SOURCES := $(wildcard ../151_library/*.c)
CSRCS := $(wildcard *.c)
SSRCS := $(wildcard *.s)
LDSRC := $(TARGET).ld
GCC_OPTS += -mabi=ilp32 -march=rv32i -static -mcmodel=medany -nostdlib -nostartfiles -ffreestanding -T $(LDSRC)
default: $(TARGET).elf
SOURCES = $(CSRCS) $(SSRCS)
ifeq ($(INCLUDE_LIB), true)
SOURCES += $(LIB_SOURCES)
endif
$(TARGET).elf: $(SOURCES)
$(RISCV)-gcc $(GCC_OPTS) -I$(LIB_PATH) $^ -o $@
$(RISCV)-objdump -D -Mnumeric $@ > $(basename $@).dump
$(RISCV)-strip -R .comment -R .note.gnu.build-id $@
$(RISCV)-objcopy $(basename $@).elf -O binary $(basename $@).bin
clean:
rm -f *.elf *.dump *.mif *.bin
.PHONY: target