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 |
Wu Zhangjin | f7a904d | 2010-01-04 17:16:51 +0800 | [diff] [blame] | 12 | # Author: Wu Zhangjin <wuzhangjin@gmail.com> |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 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) |
Alexander Clouter | 9c4a6fc | 2010-01-20 20:50:07 +0000 | [diff] [blame] | 17 | VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo -n $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536)))) |
| 18 | # VMLINUZ_LOAD_ADDRESS = concat "high32 of VMLINUX_LOAD_ADDRESS" and "(low32 of VMLINUX_LOAD_ADDRESS) + VMLINUX_SIZE" |
| 19 | HIGH32 := $(shell A=$(VMLINUX_LOAD_ADDRESS); [ $${\#A} -gt 10 ] && expr substr "$(VMLINUX_LOAD_ADDRESS)" 3 $$(($${\#A} - 10))) |
| 20 | LOW32 := $(shell [ -n "$(HIGH32)" ] && A=11 || A=3; expr substr "$(VMLINUX_LOAD_ADDRESS)" $${A} 8) |
| 21 | VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" -a -n "$(LOW32)" ] && printf "$(HIGH32)%08x" $$(($(VMLINUX_SIZE) + 0x$(LOW32)))) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 22 | |
| 23 | # set the default size of the mallocing area for decompressing |
| 24 | BOOT_HEAP_SIZE := 0x400000 |
| 25 | |
| 26 | # Disable Function Tracer |
| 27 | KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//") |
| 28 | |
| 29 | KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \ |
Wu Zhangjin | dac2965 | 2010-01-26 17:04:02 +0800 | [diff] [blame] | 30 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 31 | |
| 32 | KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ |
Wu Zhangjin | dac2965 | 2010-01-26 17:04:02 +0800 | [diff] [blame] | 33 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ |
| 34 | -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 35 | |
| 36 | obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o |
| 37 | |
| 38 | obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
Manuel Lauss | aae7e8d | 2010-01-13 18:46:58 +0100 | [diff] [blame] | 39 | obj-$(CONFIG_MACH_ALCHEMY) += $(obj)/uart-alchemy.o |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 40 | |
| 41 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
| 42 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) |
| 43 | $(call if_changed,objcopy) |
| 44 | |
| 45 | suffix_$(CONFIG_KERNEL_GZIP) = gz |
| 46 | suffix_$(CONFIG_KERNEL_BZIP2) = bz2 |
| 47 | suffix_$(CONFIG_KERNEL_LZMA) = lzma |
Wu Zhangjin | fe1d45e | 2010-01-15 20:34:46 +0800 | [diff] [blame] | 48 | suffix_$(CONFIG_KERNEL_LZO) = lzo |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 49 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
| 50 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
| 51 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
Wu Zhangjin | fe1d45e | 2010-01-15 20:34:46 +0800 | [diff] [blame] | 52 | tool_$(CONFIG_KERNEL_LZO) = lzo |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 53 | $(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin |
| 54 | $(call if_changed,$(tool_y)) |
| 55 | |
| 56 | $(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o |
| 57 | $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \ |
| 58 | --add-section=.image=$< \ |
| 59 | --set-section-flags=.image=contents,alloc,load,readonly,data \ |
| 60 | $(obj)/dummy.o $@ |
| 61 | |
| 62 | LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T |
| 63 | vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o |
| 64 | $(call if_changed,ld) |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 65 | $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@ |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 66 | |
| 67 | # |
| 68 | # Some DECstations need all possible sections of an ECOFF executable |
| 69 | # |
| 70 | ifdef CONFIG_MACH_DECSTATION |
| 71 | E2EFLAGS = -a |
| 72 | else |
| 73 | E2EFLAGS = |
| 74 | endif |
| 75 | |
| 76 | # elf2ecoff can only handle 32bit image |
| 77 | |
| 78 | ifdef CONFIG_32BIT |
| 79 | VMLINUZ = vmlinuz |
| 80 | else |
| 81 | VMLINUZ = vmlinuz.32 |
| 82 | endif |
| 83 | |
| 84 | vmlinuz.32: vmlinuz |
| 85 | $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ |
| 86 | |
| 87 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
| 88 | $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS) |
| 89 | |
| 90 | $(obj)/../elf2ecoff: $(src)/../elf2ecoff.c |
| 91 | $(Q)$(HOSTCC) -o $@ $^ |
| 92 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 93 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 94 | vmlinuz.bin: vmlinuz |
| 95 | $(call if_changed,objcopy) |
| 96 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 97 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 98 | vmlinuz.srec: vmlinuz |
| 99 | $(call if_changed,objcopy) |
| 100 | |
| 101 | clean: |
| 102 | clean-files += *.o \ |
| 103 | vmlinu* |