12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- MAKEFLAGS += -R -r
- CROSS = ../tools/gnu/bin/riscv32-unknown-elf-
- CC = $(CROSS)gcc
- LD = $(CROSS)ld
- OBJCOPY = $(CROSS)objcopy
- AR = $(CROSS)ar
- PERL = perl
- INCLUDE = -I. -I./include -I./fatfs/source
- include ../riscv-opts.mk
- CPPFLAGS = $(INCLUDE) $(riscv_flags)
- CFLAGS = $(CPPFLAGS)
- SFLAGS = $(CPPFLAGS) -D__ASSEMBLY__
- LDSCRIPT = max80.ild
- LDFLAGS = $(CFLAGS) \
- -Wl,--gc-sections \
- -Wl,-T,$(LDSCRIPT) \
- -Wl,-z,common-page-size=16 \
- -Wl,-z,max-page-size=16
- gendeps = -MD -MF .$(@F).d -MT $@
- # Delete output files on error
- .DELETE_ON_ERROR:
- # Don't delete intermediate files
- .SECONDARY:
- all: boot.mif testdata.hex
- # Generate MIF file for 8Kx32 RAM
- boot_depth := 8192
- boot_width := 32
- boot_stride := 1
- boot.elf: head.o die.o dummy.o irq.o irqasm.o sbrk.o hello.o \
- console.o sdcard.o fatfs.a
- FATFS_C = $(wildcard fatfs/source/*.c)
- FATFS_O = $(FATFS_C:.c=.o)
- fatfs.a: $(FATFS_O)
- rm -f $@
- $(AR) cq $@ $(FATFS_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: $(LDSCRIPT)
- $(CC) $(LDFLAGS) -o $@ $(filter-out $(LDSCRIPT),$^)
- %.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 $@ $<
- %.ild: %.ld
- $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) \
- -x assembler-with-cpp \
- -fdollars-in-identifiers \
- -C -P -E $< | $(PERL) -pe 's:^(#.*)$$:/* $$1 */:' > $@
- testdata.bin: testdata.pl
- $(PERL) $< > $@
- testdata.hex: testdata.bin
- $(OBJCOPY) -I binary -O ihex $< $@
- clean:
- rm -f *.o *.i *.s *.elf *.bin .*.d *.ild
- spotless: clean
- rm -f *.mem *.hex *.mif
- -include .*.d
|