12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- MAKEFLAGS += -R -r
- 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
- CPPFLAGS = $(INCLUDE) \
- -march=rv32imc -mabi=ilp32 -mdiv -Os -ggdb3 \
- -fwrapv -fvisibility=hidden -fno-strict-aliasing \
- -fno-pic -mno-plt -msmall-data-limit=8192 \
- -frename-registers \
- -mshorten-memrefs -mno-strict-align
- # These require newlib to be built with the same options; would be nice
- CPPFLAGS_NOT = -fshort-enums -fshort-wchar
- CFLAGS = $(CPPFLAGS)
- SFLAGS = $(CPPFLAGS) -D__ASSEMBLY__
- LDFLAGS = $(CFLAGS) \
- -Wl,--section-start=.init=0 -Wl,-q \
- -Wl,-z,common-page-size=16 -Wl,-z,max-page-size=16
- # Delete output files on error
- .DELETE_ON_ERROR:
- # Don't delete intermediate files
- .SECONDARY:
- all: boot.mif
- # Generate MIF files for 4 8×2K RAMs
- boot_depth := 2048
- boot_width := 8
- boot_stride := 4
- boot.elf: head.o hello.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_$<) -c -o $@ $<
- %.s: %.c
- $(CC) $(CFLAGS) $(CFLAGS_$<) -S -o $@ $<
- %.i: %.c
- $(CC) $(CFLAGS) $(CFLAGS_$<) -E -o $@ $<
- %.o: %.S
- $(CC) $(SFLAGS) $(SFLAGS_$<) -c -o $@ $<
- %.s: %.S
- $(CC) $(SFLAGS) $(SFLAGS_$<) -E -o $@ $<
- clean:
- rm -f *.o *.i *.s *.elf *.bin
- spotless: clean
- rm -f *.mem *.hex *.mif
|