12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- export PATH := $(CURDIR)/tools/gnu/bin:$(PATH)
- CROSS = riscv32-unknown-elf-
- CC = $(CROSS)gcc
- LD = $(CROSS)ld
- OBJCOPY = $(CROSS)objcopy
- PERL = perl
- INCLUDE = -I. -I./include
- include ../riscv-opts.mk
- CPPFLAGS = $(INCLUDE) $(riscv_flags)
- CFLAGS = $(CPPFLAGS)
- SFLAGS = $(CPPFLAGS) -D__ASSEMBLY__
- LDFLAGS = $(CFLAGS) \
- -Wl,--gc-sections \
- -Wl,--section-start=.init=0 \
- -Wl,-z,common-page-size=16 \
- -Wl,-z,max-page-size=16
- gendeps = -MD -MF .$(@F).d
- # Delete output files on error
- .DELETE_ON_ERROR:
- # Don't delete intermediate files
- .SECONDARY:
- all: boot.mif
- # Generate MIF file for 2Kx32 RAM
- boot_depth := 2048
- boot_width := 32
- boot_stride := 1
- boot.elf: head.o die.o hello.o console.o
- %.mif: %.bin bin2mif.pl
- $(PERL) bin2mif.pl $< $@ $($*_depth) $($*_width) $($*_stride)
- %.hex: %.elf
- $(OBJCOPY) -O ihex $< $@
- %.mem: %.bin
- $(BIN2MEM) $< > $@
- %.bin: %.elf
- $(OBJCOPY) -O binary $< $@
- %.elf:
- $(CC) $(LDFLAGS) -o $@ $^
- %.o: %.c
- $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -c -o $@ $<
- %.s: %.c
- $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -S -o $@ $<
- %.i: %.c
- $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -E -o $@ $<
- %.o: %.S
- $(CC) $(SFLAGS) $(SFLAGS_$<) $(gendeps) -c -o $@ $<
- %.s: %.S
- $(CC) $(SFLAGS) $(SFLAGS_$<) $(gendeps) -E -o $@ $<
- clean:
- rm -f *.o *.i *.s *.elf *.bin .*.d
- spotless: clean
- rm -f *.mem *.hex *.mif
- -include .*.d
|