420617edb7ecc031f521c4e7eac1e5207a6737d9
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

1) SRCS=main.c leds.c
2) 
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

3) CC=mipsel-elf-gcc
4) LD=mipsel-elf-ld
5) OBJCOPY=mipsel-elf-objcopy
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

6) CFLAGS=-Wall -Wextra -mips1 -mno-abicalls
7) LFLAGS=-mips1
8) 
9) BASES=$(patsubst %.c,%,$(SRCS))
10) DEPS=$(addsuffix .d,$(BASES))
11) OBJS=$(addsuffix .o,$(BASES))
12) 
13) .PHONY: all clean
14) 
15) all: rom.vhd
16) 
17) ifneq ($(MAKECMDGOALS),clean)
18)   include deps
19) endif
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

20) 
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

21) deps: $(DEPS)
22) 	cat /dev/null $^ >$@
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

23) 
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

24) %.d: %.c Makefile
25) 	$(CC) $(CFLAGS) -M -o $@ $<
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

26) 
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

27) %.o: %.c Makefile
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

28) 	$(CC) $(CFLAGS) -c -o $@ $<
29) 
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

30) %.o: %.s Makefile
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

31) 	$(CC) $(CFLAGS) -c -o $@ $<
32) 
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

33) fw.o: $(OBJS)
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

34) 	$(LD) $(LFLAGS) -r -o $@ $^
35) 
36) fw: lnk.cmd boot.o fw.o
37) 	$(LD) $(LFLAGS) -T lnk.cmd -o $@ boot.o fw.o
38) 
39) fw.bin: fw
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

40) 	$(OBJCOPY) -j .text -O binary $< $@
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

41) 
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

42) rom.vhd: rom.head.vhd rom.tail.vhd fw.bin
43) 	cat rom.head.vhd >$@
44) 	hexdump -e '1/4 "%08X\n"' -v fw.bin | \
45) 	  sed 's/^/=> X"/;s/$$/",/' | \
46) 	  nl -p -v 0 | \
47) 	  sed 's/^/        /' >>$@
48) 	cat rom.tail.vhd >>$@
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

49) 
50) clean:
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

51) 	rm -f $(OBJS) boot.o fw.o fw fw.bin rom.vhd