Commit | Line | Data |
---|---|---|
1b93b3c3 WZ |
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 | |
f7a904df | 12 | # Author: Wu Zhangjin <wuzhangjin@gmail.com> |
1b93b3c3 WZ |
13 | # |
14 | ||
1b93b3c3 WZ |
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__ \ | |
dac2965c | 22 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" |
1b93b3c3 WZ |
23 | |
24 | KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ | |
dac2965c WZ |
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 \ ) | |
1b93b3c3 | 27 | |
35eaa1e9 SR |
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 | |
1b93b3c3 | 32 | |
f86a69b1 | 33 | ifdef CONFIG_DEBUG_ZBOOT |
35eaa1e9 | 34 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
42a4f17d | 35 | vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o |
f86a69b1 | 36 | endif |
1b93b3c3 | 37 | |
35eaa1e9 | 38 | targets += vmlinux.bin |
1b93b3c3 | 39 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
35eaa1e9 | 40 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE |
1b93b3c3 WZ |
41 | $(call if_changed,objcopy) |
42 | ||
1b93b3c3 WZ |
43 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
44 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 | |
45 | tool_$(CONFIG_KERNEL_LZMA) = lzma | |
fe1d45e0 | 46 | tool_$(CONFIG_KERNEL_LZO) = lzo |
35eaa1e9 | 47 | |
c853d945 WZ |
48 | targets += vmlinux.bin.z |
49 | $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE | |
1b93b3c3 WZ |
50 | $(call if_changed,$(tool_y)) |
51 | ||
35eaa1e9 | 52 | targets += piggy.o |
c853d945 | 53 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ |
35eaa1e9 | 54 | --set-section-flags=.image=contents,alloc,load,readonly,data |
c853d945 | 55 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE |
35eaa1e9 | 56 | $(call if_changed,objcopy) |
1b93b3c3 | 57 | |
3c4b7fde WZ |
58 | # Calculate the load address of the compressed kernel image |
59 | hostprogs-y := calc_vmlinuz_load_addr | |
60 | ||
f9c9affc LBR |
61 | ifeq ($(CONFIG_MACH_JZ4740),y) |
62 | VMLINUZ_LOAD_ADDRESS := 0x80600000 | |
63 | else | |
3c4b7fde | 64 | VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ |
2ccc5b15 | 65 | $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) |
f9c9affc | 66 | endif |
3c4b7fde WZ |
67 | |
68 | vmlinuzobjs-y += $(obj)/piggy.o | |
69 | ||
70 | quiet_cmd_zld = LD $@ | |
71 | cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ | |
5089ca9d WZ |
72 | quiet_cmd_strip = STRIP $@ |
73 | cmd_strip = $(STRIP) -s $@ | |
3c4b7fde WZ |
74 | vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr |
75 | $(call cmd,zld) | |
5089ca9d | 76 | $(call cmd,strip) |
1b93b3c3 WZ |
77 | |
78 | # | |
79 | # Some DECstations need all possible sections of an ECOFF executable | |
80 | # | |
81 | ifdef CONFIG_MACH_DECSTATION | |
35eaa1e9 | 82 | e2eflag := -a |
1b93b3c3 WZ |
83 | endif |
84 | ||
85 | # elf2ecoff can only handle 32bit image | |
3c4b7fde | 86 | hostprogs-y += ../elf2ecoff |
1b93b3c3 WZ |
87 | |
88 | ifdef CONFIG_32BIT | |
89 | VMLINUZ = vmlinuz | |
90 | else | |
91 | VMLINUZ = vmlinuz.32 | |
92 | endif | |
93 | ||
35eaa1e9 SR |
94 | quiet_cmd_32 = OBJCOPY $@ |
95 | cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ | |
1b93b3c3 | 96 | vmlinuz.32: vmlinuz |
35eaa1e9 | 97 | $(call cmd,32) |
1b93b3c3 | 98 | |
35eaa1e9 SR |
99 | quiet_cmd_ecoff = ECOFF $@ |
100 | cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) | |
1b93b3c3 | 101 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
35eaa1e9 | 102 | $(call cmd,ecoff) |
1b93b3c3 | 103 | |
d4d9a553 | 104 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
1b93b3c3 | 105 | vmlinuz.bin: vmlinuz |
35eaa1e9 | 106 | $(call cmd,objcopy) |
1b93b3c3 | 107 | |
d4d9a553 | 108 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
1b93b3c3 | 109 | vmlinuz.srec: vmlinuz |
35eaa1e9 | 110 | $(call cmd,objcopy) |
1b93b3c3 | 111 | |
ec335292 | 112 | clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec} |