Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # This file is subject to the terms and conditions of the GNU General Public |
| 3 | # License. |
| 4 | # |
| 5 | # Adapted for MIPS Pete Popov, Dan Malek |
| 6 | # |
| 7 | # Copyright (C) 1994 by Linus Torvalds |
| 8 | # Adapted for PowerPC by Gary Thomas |
| 9 | # modified by Cort (cort@cs.nmt.edu) |
| 10 | # |
| 11 | # Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University |
| 12 | # Author: Wu Zhangjin <wuzj@lemote.com> |
| 13 | # |
| 14 | |
| 15 | # compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE |
| 16 | VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1) |
| 17 | VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536)))) |
| 18 | VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" ] && printf %x $$(($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE)))) |
| 19 | |
| 20 | # set the default size of the mallocing area for decompressing |
| 21 | BOOT_HEAP_SIZE := 0x400000 |
| 22 | |
| 23 | # Disable Function Tracer |
| 24 | KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//") |
| 25 | |
| 26 | KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \ |
| 27 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" \ |
| 28 | |
| 29 | KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ |
| 30 | -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) \ |
| 31 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) |
| 32 | |
| 33 | obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o |
| 34 | |
| 35 | obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
| 36 | |
| 37 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
| 38 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) |
| 39 | $(call if_changed,objcopy) |
| 40 | |
| 41 | suffix_$(CONFIG_KERNEL_GZIP) = gz |
| 42 | suffix_$(CONFIG_KERNEL_BZIP2) = bz2 |
| 43 | suffix_$(CONFIG_KERNEL_LZMA) = lzma |
Wu Zhangjin | fe1d45e | 2010-01-15 20:34:46 +0800 | [diff] [blame^] | 44 | suffix_$(CONFIG_KERNEL_LZO) = lzo |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 45 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
| 46 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
| 47 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
Wu Zhangjin | fe1d45e | 2010-01-15 20:34:46 +0800 | [diff] [blame^] | 48 | tool_$(CONFIG_KERNEL_LZO) = lzo |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 49 | $(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin |
| 50 | $(call if_changed,$(tool_y)) |
| 51 | |
| 52 | $(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o |
| 53 | $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \ |
| 54 | --add-section=.image=$< \ |
| 55 | --set-section-flags=.image=contents,alloc,load,readonly,data \ |
| 56 | $(obj)/dummy.o $@ |
| 57 | |
| 58 | LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T |
| 59 | vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o |
| 60 | $(call if_changed,ld) |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 61 | $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@ |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 62 | |
| 63 | # |
| 64 | # Some DECstations need all possible sections of an ECOFF executable |
| 65 | # |
| 66 | ifdef CONFIG_MACH_DECSTATION |
| 67 | E2EFLAGS = -a |
| 68 | else |
| 69 | E2EFLAGS = |
| 70 | endif |
| 71 | |
| 72 | # elf2ecoff can only handle 32bit image |
| 73 | |
| 74 | ifdef CONFIG_32BIT |
| 75 | VMLINUZ = vmlinuz |
| 76 | else |
| 77 | VMLINUZ = vmlinuz.32 |
| 78 | endif |
| 79 | |
| 80 | vmlinuz.32: vmlinuz |
| 81 | $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ |
| 82 | |
| 83 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
| 84 | $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS) |
| 85 | |
| 86 | $(obj)/../elf2ecoff: $(src)/../elf2ecoff.c |
| 87 | $(Q)$(HOSTCC) -o $@ $^ |
| 88 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 89 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 90 | vmlinuz.bin: vmlinuz |
| 91 | $(call if_changed,objcopy) |
| 92 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 93 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 94 | vmlinuz.srec: vmlinuz |
| 95 | $(call if_changed,objcopy) |
| 96 | |
| 97 | clean: |
| 98 | clean-files += *.o \ |
| 99 | vmlinu* |