Brian Murphy | 1f21d2b | 2007-08-21 22:34:16 +0200 | [diff] [blame] | 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 | |
| 9 | ifndef Version |
| 10 | Version = "$(USER)-test" |
| 11 | endif |
| 12 | |
| 13 | MKLASATIMG = mklasatimg |
| 14 | MKLASATIMG_ARCH = mq2,mqpro,sp100,sp200 |
WANG Cong | 778bc14 | 2008-01-02 14:21:36 +0800 | [diff] [blame] | 15 | KERNEL_IMAGE = vmlinux |
Brian Murphy | 1f21d2b | 2007-08-21 22:34:16 +0200 | [diff] [blame] | 16 | KERNEL_START = $(shell $(NM) $(KERNEL_IMAGE) | grep " _text" | cut -f1 -d\ ) |
| 17 | KERNEL_ENTRY = $(shell $(NM) $(KERNEL_IMAGE) | grep kernel_entry | cut -f1 -d\ ) |
| 18 | |
WANG Cong | 778bc14 | 2008-01-02 14:21:36 +0800 | [diff] [blame] | 19 | LDSCRIPT= -L$(srctree)/$(src) -Tromscript.normal |
Brian Murphy | 1f21d2b | 2007-08-21 22:34:16 +0200 | [diff] [blame] | 20 | |
| 21 | HEAD_DEFINES := -D_kernel_start=0x$(KERNEL_START) \ |
| 22 | -D_kernel_entry=0x$(KERNEL_ENTRY) \ |
| 23 | -D VERSION="\"$(Version)\"" \ |
| 24 | -D TIMESTAMP=$(shell date +%s) |
| 25 | |
| 26 | $(obj)/head.o: $(obj)/head.S $(KERNEL_IMAGE) |
WANG Cong | 778bc14 | 2008-01-02 14:21:36 +0800 | [diff] [blame] | 27 | $(CC) -fno-pic $(HEAD_DEFINES) $(LINUXINCLUDE) -c -o $@ $< |
Brian Murphy | 1f21d2b | 2007-08-21 22:34:16 +0200 | [diff] [blame] | 28 | |
| 29 | OBJECTS = head.o kImage.o |
| 30 | |
| 31 | rom.sw: $(obj)/rom.sw |
| 32 | rom.bin: $(obj)/rom.bin |
| 33 | |
| 34 | $(obj)/rom.sw: $(obj)/rom.bin |
| 35 | $(MKLASATIMG) -o $@ -k $^ -m $(MKLASATIMG_ARCH) |
| 36 | |
| 37 | $(obj)/rom.bin: $(obj)/rom |
| 38 | $(OBJCOPY) -O binary -S $^ $@ |
| 39 | |
| 40 | # Rule to make the bootloader |
| 41 | $(obj)/rom: $(addprefix $(obj)/,$(OBJECTS)) |
| 42 | $(LD) $(LDFLAGS) $(LDSCRIPT) -o $@ $^ |
| 43 | |
| 44 | $(obj)/%.o: $(obj)/%.gz |
| 45 | $(LD) -r -o $@ -b binary $< |
| 46 | |
| 47 | $(obj)/%.gz: $(obj)/%.bin |
| 48 | gzip -cf -9 $< > $@ |
| 49 | |
| 50 | $(obj)/kImage.bin: $(KERNEL_IMAGE) |
| 51 | $(OBJCOPY) -O binary -S $^ $@ |
| 52 | |
| 53 | clean: |
| 54 | rm -f rom rom.bin rom.sw kImage.bin kImage.o |