SRCS=cyc_cnt.c lcd.c leds.c main.c CC=mipsel-elf-gcc LD=mipsel-elf-ld OBJCOPY=mipsel-elf-objcopy CFLAGS=-Wall -Wextra -mips1 -mno-abicalls LFLAGS=-mips1 BASES=$(patsubst %.c,%,$(SRCS)) DEPS=$(addsuffix .d,$(BASES)) OBJS=$(addsuffix .o,$(BASES)) .PHONY: all clean all: rom.vhd ifneq ($(MAKECMDGOALS),clean) include deps endif deps: $(DEPS) cat /dev/null $^ >$@ %.d: %.c Makefile $(CC) $(CFLAGS) -M -o $@ $< %.o: %.c Makefile $(CC) $(CFLAGS) -c -o $@ $< %.o: %.s Makefile $(CC) $(CFLAGS) -c -o $@ $< fw.o: $(OBJS) $(LD) $(LFLAGS) -r -o $@ $^ fw: lnk.cmd boot.o fw.o $(LD) $(LFLAGS) -T lnk.cmd -o $@ boot.o fw.o fw.bin: fw $(OBJCOPY) -j .text -O binary $< $@ rom.vhd: rom.head.vhd rom.tail.vhd fw.bin cat rom.head.vhd >$@ hexdump -e '1/4 "%08X\n"' -v fw.bin | \ sed 's/^/=> X"/;s/$$/",/' | \ nl -p -v 0 | \ sed 's/^/ /' >>$@ cat rom.tail.vhd >>$@ clean: rm -f $(OBJS) boot.o fw.o fw fw.bin rom.vhd