Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6.git] / arch / mips / boot / compressed / Makefile
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 <wuzhangjin@gmail.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 -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
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__ \
30         -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
31
32 KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
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 \ )
35
36 obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
37
38 ifdef CONFIG_DEBUG_ZBOOT
39 obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
40 obj-$(CONFIG_MACH_ALCHEMY)                 += $(obj)/uart-alchemy.o
41 endif
42
43 OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
44 $(obj)/vmlinux.bin: $(KBUILD_IMAGE)
45         $(call if_changed,objcopy)
46
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
52 tool_$(CONFIG_KERNEL_BZIP2)   = bzip2
53 tool_$(CONFIG_KERNEL_LZMA)    = lzma
54 tool_$(CONFIG_KERNEL_LZO)     = lzo
55 $(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin
56         $(call if_changed,$(tool_y))
57
58 $(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o
59         $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \
60                 --add-section=.image=$< \
61                 --set-section-flags=.image=contents,alloc,load,readonly,data \
62                 $(obj)/dummy.o $@
63
64 LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
65 vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o
66         $(call if_changed,ld)
67         $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@
68
69 #
70 # Some DECstations need all possible sections of an ECOFF executable
71 #
72 ifdef CONFIG_MACH_DECSTATION
73   E2EFLAGS = -a
74 else
75   E2EFLAGS =
76 endif
77
78 # elf2ecoff can only handle 32bit image
79
80 ifdef CONFIG_32BIT
81         VMLINUZ = vmlinuz
82 else
83         VMLINUZ = vmlinuz.32
84 endif
85
86 vmlinuz.32: vmlinuz
87         $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
88
89 vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
90         $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS)
91
92 $(obj)/../elf2ecoff: $(src)/../elf2ecoff.c
93         $(Q)$(HOSTCC) -o $@ $^
94
95 OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
96 vmlinuz.bin: vmlinuz
97         $(call if_changed,objcopy)
98
99 OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
100 vmlinuz.srec: vmlinuz
101         $(call if_changed,objcopy)
102
103 clean:
104 clean-files += *.o \
105                vmlinu*