1#
2# MAKEFILE FOR THE MIPS LINUX BOOTLOADER AND ROM DEBUGGER
3#
4# i-data Networks
5#
6# Author: Thomas Horsten <thh@i-data.com>
7#
8
9ifndef Version
10 Version = "$(USER)-test"
11endif
12
13MKLASATIMG = mklasatimg
14MKLASATIMG_ARCH = mq2,mqpro,sp100,sp200
15KERNEL_IMAGE = vmlinux
16
17LDSCRIPT= -L$(srctree)/$(src) -Tromscript.normal
18
19HEAD_DEFINES := -D_kernel_start=$(VMLINUX_LOAD_ADDRESS) \
20		-D_kernel_entry=$(VMLINUX_ENTRY_ADDRESS) \
21		-D VERSION="\"$(Version)\"" \
22		-D TIMESTAMP=$(shell date +%s)
23
24$(obj)/head.o: $(obj)/head.S $(KERNEL_IMAGE)
25	$(CC) -fno-pic $(HEAD_DEFINES) $(LINUXINCLUDE) -c -o $@ $<
26
27OBJECTS = head.o kImage.o
28
29rom.sw: $(obj)/rom.sw
30rom.bin:	$(obj)/rom.bin
31
32$(obj)/rom.sw:	$(obj)/rom.bin
33	$(MKLASATIMG) -o $@ -k $^ -m $(MKLASATIMG_ARCH)
34
35$(obj)/rom.bin: $(obj)/rom
36	$(OBJCOPY) -O binary -S $^ $@
37
38# Rule to make the bootloader
39$(obj)/rom: $(addprefix $(obj)/,$(OBJECTS))
40	$(LD) $(LDFLAGS) $(LDSCRIPT) -o $@ $^
41
42$(obj)/%.o: $(obj)/%.gz
43	$(LD) -r -o $@ -b binary $<
44
45$(obj)/%.gz: $(obj)/%.bin
46	gzip -cf -9 $< > $@
47
48$(obj)/kImage.bin: $(KERNEL_IMAGE)
49	$(OBJCOPY) -O binary -S $^ $@
50
51clean:
52	rm -f rom rom.bin rom.sw kImage.bin kImage.o
53