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 | |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 15 | # set the default size of the mallocing area for decompressing |
| 16 | BOOT_HEAP_SIZE := 0x400000 |
| 17 | |
| 18 | # Disable Function Tracer |
| 19 | KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//") |
| 20 | |
| 21 | KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \ |
Wu Zhangjin | dac2965 | 2010-01-26 17:04:02 +0800 | [diff] [blame] | 22 | -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] | 23 | |
| 24 | KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ |
Wu Zhangjin | dac2965 | 2010-01-26 17:04:02 +0800 | [diff] [blame] | 25 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ |
| 26 | -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] | 27 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 28 | targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o |
| 29 | |
| 30 | # decompressor objects (linked with vmlinuz) |
| 31 | vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 32 | |
Wu Zhangjin | f86a69b | 2010-01-31 20:39:40 +0800 | [diff] [blame] | 33 | ifdef CONFIG_DEBUG_ZBOOT |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 34 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
Manuel Lauss | 42a4f17 | 2010-07-15 21:45:04 +0200 | [diff] [blame] | 35 | vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o |
Wu Zhangjin | f86a69b | 2010-01-31 20:39:40 +0800 | [diff] [blame] | 36 | endif |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 37 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 38 | targets += vmlinux.bin |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 39 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 40 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 41 | $(call if_changed,objcopy) |
| 42 | |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 43 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
| 44 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
| 45 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
Wu Zhangjin | fe1d45e | 2010-01-15 20:34:46 +0800 | [diff] [blame] | 46 | tool_$(CONFIG_KERNEL_LZO) = lzo |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 47 | |
Wu Zhangjin | c853d94 | 2010-06-02 16:35:24 +0800 | [diff] [blame] | 48 | targets += vmlinux.bin.z |
| 49 | $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 50 | $(call if_changed,$(tool_y)) |
| 51 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 52 | targets += piggy.o |
Wu Zhangjin | c853d94 | 2010-06-02 16:35:24 +0800 | [diff] [blame] | 53 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 54 | --set-section-flags=.image=contents,alloc,load,readonly,data |
Wu Zhangjin | c853d94 | 2010-06-02 16:35:24 +0800 | [diff] [blame] | 55 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 56 | $(call if_changed,objcopy) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 57 | |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 58 | # Calculate the load address of the compressed kernel image |
| 59 | hostprogs-y := calc_vmlinuz_load_addr |
| 60 | |
| 61 | VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ |
Shmulik Ladkani | 2ccc5b1 | 2010-08-31 13:24:19 +0300 | [diff] [blame] | 62 | $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 63 | |
| 64 | vmlinuzobjs-y += $(obj)/piggy.o |
| 65 | |
| 66 | quiet_cmd_zld = LD $@ |
| 67 | cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ |
Wu Zhangjin | 5089ca9 | 2010-06-16 15:52:21 +0800 | [diff] [blame] | 68 | quiet_cmd_strip = STRIP $@ |
| 69 | cmd_strip = $(STRIP) -s $@ |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 70 | vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr |
| 71 | $(call cmd,zld) |
Wu Zhangjin | 5089ca9 | 2010-06-16 15:52:21 +0800 | [diff] [blame] | 72 | $(call cmd,strip) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 73 | |
| 74 | # |
| 75 | # Some DECstations need all possible sections of an ECOFF executable |
| 76 | # |
| 77 | ifdef CONFIG_MACH_DECSTATION |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 78 | e2eflag := -a |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 79 | endif |
| 80 | |
| 81 | # elf2ecoff can only handle 32bit image |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 82 | hostprogs-y += ../elf2ecoff |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 83 | |
| 84 | ifdef CONFIG_32BIT |
| 85 | VMLINUZ = vmlinuz |
| 86 | else |
| 87 | VMLINUZ = vmlinuz.32 |
| 88 | endif |
| 89 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 90 | quiet_cmd_32 = OBJCOPY $@ |
| 91 | cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 92 | vmlinuz.32: vmlinuz |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 93 | $(call cmd,32) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 94 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 95 | quiet_cmd_ecoff = ECOFF $@ |
| 96 | cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 97 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 98 | $(call cmd,ecoff) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 99 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 100 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 101 | vmlinuz.bin: vmlinuz |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 102 | $(call cmd,objcopy) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 103 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 104 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 105 | vmlinuz.srec: vmlinuz |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 106 | $(call cmd,objcopy) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 107 | |
Wu Zhangjin | ec33529 | 2010-09-22 14:03:57 +0800 | [diff] [blame] | 108 | clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec} |