blob: d5bdee115f22f73058d464e5cc88aee8abc7cf46 [file] [log] [blame]
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +08001#
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
Wu Zhangjinf7a904d2010-01-04 17:16:51 +080012# Author: Wu Zhangjin <wuzhangjin@gmail.com>
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080013#
14
Andrew Brestickerb76a4c12015-03-16 14:43:08 -070015include $(srctree)/arch/mips/Kbuild.platforms
16
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080017# 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
Markos Chandras23df3412013-07-01 09:38:30 +000023KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
24
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080025KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080026 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080027
28KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080029 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
James Hogan31855572013-08-30 16:42:41 +010030 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080031
Antony Pavlovdc4d7b32014-01-14 01:30:56 +040032targets := head.o decompress.o string.o dbg.o uart-16550.o uart-alchemy.o
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020033
34# decompressor objects (linked with vmlinuz)
Wu Zhangjin7ae7ef32010-12-25 23:11:49 +080035vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080036
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080037ifdef CONFIG_DEBUG_ZBOOT
Wu Zhangjin7ae7ef32010-12-25 23:11:49 +080038vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020039vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
Manuel Lauss42a4f172010-07-15 21:45:04 +020040vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080041endif
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080042
Florian Fainelli4e23eb62013-09-11 11:51:41 +010043ifdef CONFIG_KERNEL_XZ
44vmlinuzobjs-y += $(obj)/../../lib/ashldi3.o
45endif
46
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020047targets += vmlinux.bin
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080048OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020049$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080050 $(call if_changed,objcopy)
51
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080052tool_$(CONFIG_KERNEL_GZIP) = gzip
53tool_$(CONFIG_KERNEL_BZIP2) = bzip2
Florian Fainelli31c48672013-09-16 16:55:20 +010054tool_$(CONFIG_KERNEL_LZ4) = lz4
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080055tool_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080056tool_$(CONFIG_KERNEL_LZO) = lzo
Florian Fainelli4e23eb62013-09-11 11:51:41 +010057tool_$(CONFIG_KERNEL_XZ) = xzkern
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020058
Wu Zhangjinc853d942010-06-02 16:35:24 +080059targets += vmlinux.bin.z
60$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080061 $(call if_changed,$(tool_y))
62
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020063targets += piggy.o
Wu Zhangjinc853d942010-06-02 16:35:24 +080064OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
Ralf Baechle70342282013-01-22 12:59:30 +010065 --set-section-flags=.image=contents,alloc,load,readonly,data
Wu Zhangjinc853d942010-06-02 16:35:24 +080066$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020067 $(call if_changed,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080068
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080069# Calculate the load address of the compressed kernel image
70hostprogs-y := calc_vmlinuz_load_addr
71
Andrew Brestickerb76a4c12015-03-16 14:43:08 -070072ifneq ($(zload-y),)
73VMLINUZ_LOAD_ADDRESS := $(zload-y)
Lluís Batlle i Rossellf9c9aff2012-03-30 16:48:05 +020074else
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080075VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
Shmulik Ladkani2ccc5b12010-08-31 13:24:19 +030076 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
Lluís Batlle i Rossellf9c9aff2012-03-30 16:48:05 +020077endif
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080078
79vmlinuzobjs-y += $(obj)/piggy.o
80
Alex Smithfb2646a2015-08-18 15:03:10 +010081quiet_cmd_zld = LD $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080082 cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
Ralf Baechle70342282013-01-22 12:59:30 +010083quiet_cmd_strip = STRIP $@
Wu Zhangjin5089ca92010-06-16 15:52:21 +080084 cmd_strip = $(STRIP) -s $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080085vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
86 $(call cmd,zld)
Wu Zhangjin5089ca92010-06-16 15:52:21 +080087 $(call cmd,strip)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080088
89#
90# Some DECstations need all possible sections of an ECOFF executable
91#
92ifdef CONFIG_MACH_DECSTATION
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020093 e2eflag := -a
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080094endif
95
96# elf2ecoff can only handle 32bit image
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080097hostprogs-y += ../elf2ecoff
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080098
99ifdef CONFIG_32BIT
100 VMLINUZ = vmlinuz
101else
102 VMLINUZ = vmlinuz.32
103endif
104
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200105quiet_cmd_32 = OBJCOPY $@
106 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800107vmlinuz.32: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200108 $(call cmd,32)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800109
Ralf Baechle70342282013-01-22 12:59:30 +0100110quiet_cmd_ecoff = ECOFF $@
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200111 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800112vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200113 $(call cmd,ecoff)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800114
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800115OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800116vmlinuz.bin: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200117 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800118
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800119OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800120vmlinuz.srec: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200121 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800122
Wu Zhangjinec335292010-09-22 14:03:57 +0800123clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}