diff options
Diffstat (limited to 'arch/mips/boot/compressed/Makefile')
-rw-r--r-- | arch/mips/boot/compressed/Makefile | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index 790ddd397620..ed9bb709c9a3 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile | |||
@@ -12,14 +12,6 @@ | |||
12 | # Author: Wu Zhangjin <wuzhangjin@gmail.com> | 12 | # Author: Wu Zhangjin <wuzhangjin@gmail.com> |
13 | # | 13 | # |
14 | 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 -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)))) | ||
22 | |||
23 | # set the default size of the mallocing area for decompressing | 15 | # set the default size of the mallocing area for decompressing |
24 | BOOT_HEAP_SIZE := 0x400000 | 16 | BOOT_HEAP_SIZE := 0x400000 |
25 | 17 | ||
@@ -33,49 +25,61 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ | |||
33 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ | 25 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ |
34 | -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) | 26 | -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) |
35 | 27 | ||
36 | obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o | 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 | ||
37 | 32 | ||
38 | ifdef CONFIG_DEBUG_ZBOOT | 33 | ifdef CONFIG_DEBUG_ZBOOT |
39 | obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o | 34 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
40 | obj-$(CONFIG_MACH_ALCHEMY) += $(obj)/uart-alchemy.o | 35 | vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o |
41 | endif | 36 | endif |
42 | 37 | ||
38 | targets += vmlinux.bin | ||
43 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S | 39 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
44 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) | 40 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE |
45 | $(call if_changed,objcopy) | 41 | $(call if_changed,objcopy) |
46 | 42 | ||
47 | suffix_$(CONFIG_KERNEL_GZIP) = gz | ||
48 | suffix_$(CONFIG_KERNEL_BZIP2) = bz2 | ||
49 | suffix_$(CONFIG_KERNEL_LZMA) = lzma | ||
50 | suffix_$(CONFIG_KERNEL_LZO) = lzo | ||
51 | tool_$(CONFIG_KERNEL_GZIP) = gzip | 43 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
52 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 | 44 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
53 | tool_$(CONFIG_KERNEL_LZMA) = lzma | 45 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
54 | tool_$(CONFIG_KERNEL_LZO) = lzo | 46 | tool_$(CONFIG_KERNEL_LZO) = lzo |
55 | $(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin | 47 | |
48 | targets += vmlinux.bin.z | ||
49 | $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE | ||
56 | $(call if_changed,$(tool_y)) | 50 | $(call if_changed,$(tool_y)) |
57 | 51 | ||
58 | $(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o | 52 | targets += piggy.o |
59 | $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \ | 53 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ |
60 | --add-section=.image=$< \ | 54 | --set-section-flags=.image=contents,alloc,load,readonly,data |
61 | --set-section-flags=.image=contents,alloc,load,readonly,data \ | 55 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE |
62 | $(obj)/dummy.o $@ | 56 | $(call if_changed,objcopy) |
57 | |||
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 \ | ||
62 | $(objtree)/$(KBUILD_IMAGE) $(VMLINUX_LOAD_ADDRESS)) | ||
63 | 63 | ||
64 | LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T | 64 | vmlinuzobjs-y += $(obj)/piggy.o |
65 | vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o | 65 | |
66 | $(call if_changed,ld) | 66 | quiet_cmd_zld = LD $@ |
67 | $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@ | 67 | cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ |
68 | quiet_cmd_strip = STRIP $@ | ||
69 | cmd_strip = $(STRIP) -s $@ | ||
70 | vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr | ||
71 | $(call cmd,zld) | ||
72 | $(call cmd,strip) | ||
68 | 73 | ||
69 | # | 74 | # |
70 | # Some DECstations need all possible sections of an ECOFF executable | 75 | # Some DECstations need all possible sections of an ECOFF executable |
71 | # | 76 | # |
72 | ifdef CONFIG_MACH_DECSTATION | 77 | ifdef CONFIG_MACH_DECSTATION |
73 | E2EFLAGS = -a | 78 | e2eflag := -a |
74 | else | ||
75 | E2EFLAGS = | ||
76 | endif | 79 | endif |
77 | 80 | ||
78 | # elf2ecoff can only handle 32bit image | 81 | # elf2ecoff can only handle 32bit image |
82 | hostprogs-y += ../elf2ecoff | ||
79 | 83 | ||
80 | ifdef CONFIG_32BIT | 84 | ifdef CONFIG_32BIT |
81 | VMLINUZ = vmlinuz | 85 | VMLINUZ = vmlinuz |
@@ -83,23 +87,22 @@ else | |||
83 | VMLINUZ = vmlinuz.32 | 87 | VMLINUZ = vmlinuz.32 |
84 | endif | 88 | endif |
85 | 89 | ||
90 | quiet_cmd_32 = OBJCOPY $@ | ||
91 | cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ | ||
86 | vmlinuz.32: vmlinuz | 92 | vmlinuz.32: vmlinuz |
87 | $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ | 93 | $(call cmd,32) |
88 | 94 | ||
95 | quiet_cmd_ecoff = ECOFF $@ | ||
96 | cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) | ||
89 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) | 97 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
90 | $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS) | 98 | $(call cmd,ecoff) |
91 | |||
92 | $(obj)/../elf2ecoff: $(src)/../elf2ecoff.c | ||
93 | $(Q)$(HOSTCC) -o $@ $^ | ||
94 | 99 | ||
95 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary | 100 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
96 | vmlinuz.bin: vmlinuz | 101 | vmlinuz.bin: vmlinuz |
97 | $(call if_changed,objcopy) | 102 | $(call cmd,objcopy) |
98 | 103 | ||
99 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec | 104 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
100 | vmlinuz.srec: vmlinuz | 105 | vmlinuz.srec: vmlinuz |
101 | $(call if_changed,objcopy) | 106 | $(call cmd,objcopy) |
102 | 107 | ||
103 | clean: | 108 | clean-files := $(objtree)/vmlinuz.* |
104 | clean-files += *.o \ | ||
105 | vmlinu* | ||