2009-10-14 18:12:16 +08:00
#
# This file is subject to the terms and conditions of the GNU General Public
# License.
#
# Adapted for MIPS Pete Popov, Dan Malek
#
# Copyright (C) 1994 by Linus Torvalds
# Adapted for PowerPC by Gary Thomas
# modified by Cort (cort@cs.nmt.edu)
#
# Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
2010-01-04 17:16:51 +08:00
# Author: Wu Zhangjin <wuzhangjin@gmail.com>
2009-10-14 18:12:16 +08:00
#
# set the default size of the mallocing area for decompressing
BOOT_HEAP_SIZE := 0x400000
# Disable Function Tracer
KBUILD_CFLAGS := $( shell echo $( KBUILD_CFLAGS) | sed -e "s/-pg//" )
KBUILD_CFLAGS := $( LINUXINCLUDE) $( KBUILD_CFLAGS) -D__KERNEL__ \
2010-01-26 17:04:02 +08:00
-DBOOT_HEAP_SIZE= $( BOOT_HEAP_SIZE) -D" VMLINUX_LOAD_ADDRESS_ULL= $( VMLINUX_LOAD_ADDRESS) ull "
2009-10-14 18:12:16 +08:00
KBUILD_AFLAGS := $( LINUXINCLUDE) $( KBUILD_AFLAGS) -D__ASSEMBLY__ \
2010-01-26 17:04:02 +08:00
-DBOOT_HEAP_SIZE= $( BOOT_HEAP_SIZE) \
-DKERNEL_ENTRY= 0x$( shell $( NM) $( objtree) /$( KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ )
2009-10-14 18:12:16 +08:00
2010-05-30 16:28:03 +02:00
targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o
# decompressor objects (linked with vmlinuz)
vmlinuzobjs-y := $( obj) /head.o $( obj) /decompress.o $( obj) /dbg.o
2009-10-14 18:12:16 +08:00
2010-01-31 20:39:40 +08:00
i f d e f C O N F I G _ D E B U G _ Z B O O T
2010-05-30 16:28:03 +02:00
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $( obj) /uart-16550.o
2010-07-15 21:45:04 +02:00
vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $( obj) /uart-alchemy.o
2010-01-31 20:39:40 +08:00
e n d i f
2009-10-14 18:12:16 +08:00
2010-05-30 16:28:03 +02:00
targets += vmlinux.bin
2009-10-14 18:12:16 +08:00
OBJCOPYFLAGS_vmlinux.bin := $( OBJCOPYFLAGS) -O binary -R .comment -S
2010-05-30 16:28:03 +02:00
$(obj)/vmlinux.bin : $( KBUILD_IMAGE ) FORCE
2009-10-14 18:12:16 +08:00
$( call if_changed,objcopy)
tool_$(CONFIG_KERNEL_GZIP) = gzip
tool_$(CONFIG_KERNEL_BZIP2) = bzip2
tool_$(CONFIG_KERNEL_LZMA) = lzma
2010-01-15 20:34:46 +08:00
tool_$(CONFIG_KERNEL_LZO) = lzo
2010-05-30 16:28:03 +02:00
2010-06-02 16:35:24 +08:00
targets += vmlinux.bin.z
$(obj)/vmlinux.bin.z : $( obj ) /vmlinux .bin FORCE
2009-10-14 18:12:16 +08:00
$( call if_changed,$( tool_y) )
2010-05-30 16:28:03 +02:00
targets += piggy.o
2010-06-02 16:35:24 +08:00
OBJCOPYFLAGS_piggy.o := --add-section= .image= $( obj) /vmlinux.bin.z \
2013-01-22 12:59:30 +01:00
--set-section-flags= .image= contents,alloc,load,readonly,data
2010-06-02 16:35:24 +08:00
$(obj)/piggy.o : $( obj ) /dummy .o $( obj ) /vmlinux .bin .z FORCE
2010-05-30 16:28:03 +02:00
$( call if_changed,objcopy)
2009-10-14 18:12:16 +08:00
2010-06-02 16:35:25 +08:00
# Calculate the load address of the compressed kernel image
hostprogs-y := calc_vmlinuz_load_addr
2012-03-30 16:48:05 +02:00
i f e q ( $( CONFIG_MACH_JZ 4740) , y )
VMLINUZ_LOAD_ADDRESS := 0x80600000
e l s e
2010-06-02 16:35:25 +08:00
VMLINUZ_LOAD_ADDRESS = $( shell $( obj) /calc_vmlinuz_load_addr \
2010-08-31 13:24:19 +03:00
$( obj) /vmlinux.bin $( VMLINUX_LOAD_ADDRESS) )
2012-03-30 16:48:05 +02:00
e n d i f
2010-06-02 16:35:25 +08:00
vmlinuzobjs-y += $( obj) /piggy.o
2013-01-22 12:59:30 +01:00
quiet_cmd_zld = LD $@
2010-06-02 16:35:25 +08:00
cmd_zld = $( LD) $( LDFLAGS) -Ttext $( VMLINUZ_LOAD_ADDRESS) -T $< $( vmlinuzobjs-y) -o $@
2013-01-22 12:59:30 +01:00
quiet_cmd_strip = STRIP $@
2010-06-16 15:52:21 +08:00
cmd_strip = $( STRIP) -s $@
2010-06-02 16:35:25 +08:00
vmlinuz : $( src ) /ld .script $( vmlinuzobjs -y ) $( obj ) /calc_vmlinuz_load_addr
$( call cmd,zld)
2010-06-16 15:52:21 +08:00
$( call cmd,strip)
2009-10-14 18:12:16 +08:00
#
# Some DECstations need all possible sections of an ECOFF executable
#
i f d e f C O N F I G _ M A C H _ D E C S T A T I O N
2010-05-30 16:28:03 +02:00
e2eflag := -a
2009-10-14 18:12:16 +08:00
e n d i f
# elf2ecoff can only handle 32bit image
2010-06-02 16:35:25 +08:00
hostprogs-y += ../elf2ecoff
2009-10-14 18:12:16 +08:00
i f d e f C O N F I G _ 3 2 B I T
VMLINUZ = vmlinuz
e l s e
VMLINUZ = vmlinuz.32
e n d i f
2010-05-30 16:28:03 +02:00
quiet_cmd_32 = OBJCOPY $@
cmd_32 = $( OBJCOPY) -O $( 32bit-bfd) $( OBJCOPYFLAGS) $< $@
2009-10-14 18:12:16 +08:00
vmlinuz.32 : vmlinuz
2010-05-30 16:28:03 +02:00
$( call cmd,32)
2009-10-14 18:12:16 +08:00
2013-01-22 12:59:30 +01:00
quiet_cmd_ecoff = ECOFF $@
2010-05-30 16:28:03 +02:00
cmd_ecoff = $< $( VMLINUZ) $@ $( e2eflag)
2009-10-14 18:12:16 +08:00
vmlinuz.ecoff : $( obj ) /../elf 2ecoff $( VMLINUZ )
2010-05-30 16:28:03 +02:00
$( call cmd,ecoff)
2009-10-14 18:12:16 +08:00
2009-12-10 22:55:13 +08:00
OBJCOPYFLAGS_vmlinuz.bin := $( OBJCOPYFLAGS) -O binary
2009-10-14 18:12:16 +08:00
vmlinuz.bin : vmlinuz
2010-05-30 16:28:03 +02:00
$( call cmd,objcopy)
2009-10-14 18:12:16 +08:00
2009-12-10 22:55:13 +08:00
OBJCOPYFLAGS_vmlinuz.srec := $( OBJCOPYFLAGS) -S -O srec
2009-10-14 18:12:16 +08:00
vmlinuz.srec : vmlinuz
2010-05-30 16:28:03 +02:00
$( call cmd,objcopy)
2009-10-14 18:12:16 +08:00
2010-09-22 14:03:57 +08:00
clean-files := $( objtree) /vmlinuz $( objtree) /vmlinuz.{ 32,ecoff,bin,srec}