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