xref: /openbmc/linux/arch/mips/boot/compressed/Makefile (revision 95e9fd10)
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# set the default size of the mallocing area for decompressing
16BOOT_HEAP_SIZE := 0x400000
17
18# Disable Function Tracer
19KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
20
21KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
22	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
23
24KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
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 \ )
27
28targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o
29
30# decompressor objects (linked with vmlinuz)
31vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
32
33ifdef CONFIG_DEBUG_ZBOOT
34vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
35vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY)		   += $(obj)/uart-alchemy.o
36endif
37
38targets += vmlinux.bin
39OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
40$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
41	$(call if_changed,objcopy)
42
43tool_$(CONFIG_KERNEL_GZIP)    = gzip
44tool_$(CONFIG_KERNEL_BZIP2)   = bzip2
45tool_$(CONFIG_KERNEL_LZMA)    = lzma
46tool_$(CONFIG_KERNEL_LZO)     = lzo
47
48targets += vmlinux.bin.z
49$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
50	$(call if_changed,$(tool_y))
51
52targets += piggy.o
53OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
54                        --set-section-flags=.image=contents,alloc,load,readonly,data
55$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
56	$(call if_changed,objcopy)
57
58# Calculate the load address of the compressed kernel image
59hostprogs-y := calc_vmlinuz_load_addr
60
61ifeq ($(CONFIG_MACH_JZ4740),y)
62VMLINUZ_LOAD_ADDRESS := 0x80600000
63else
64VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
65		$(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
66endif
67
68vmlinuzobjs-y += $(obj)/piggy.o
69
70quiet_cmd_zld = LD      $@
71      cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
72quiet_cmd_strip = STRIP   $@
73      cmd_strip = $(STRIP) -s $@
74vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
75	$(call cmd,zld)
76	$(call cmd,strip)
77
78#
79# Some DECstations need all possible sections of an ECOFF executable
80#
81ifdef CONFIG_MACH_DECSTATION
82  e2eflag := -a
83endif
84
85# elf2ecoff can only handle 32bit image
86hostprogs-y += ../elf2ecoff
87
88ifdef CONFIG_32BIT
89	VMLINUZ = vmlinuz
90else
91	VMLINUZ = vmlinuz.32
92endif
93
94quiet_cmd_32 = OBJCOPY $@
95      cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
96vmlinuz.32: vmlinuz
97	$(call cmd,32)
98
99quiet_cmd_ecoff = ECOFF   $@
100      cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
101vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
102	$(call cmd,ecoff)
103
104OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
105vmlinuz.bin: vmlinuz
106	$(call cmd,objcopy)
107
108OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
109vmlinuz.srec: vmlinuz
110	$(call cmd,objcopy)
111
112clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}
113