blob: 4df4c77d272275798df20b18bb3d54643972a806 [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
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080015# 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__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080022 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080023
24KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080025 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
26 -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ )
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080027
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020028targets := 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
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080032
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080033ifdef CONFIG_DEBUG_ZBOOT
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020034vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
Manuel Lauss42a4f172010-07-15 21:45:04 +020035vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080036endif
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080037
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020038targets += vmlinux.bin
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080039OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020040$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080041 $(call if_changed,objcopy)
42
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080043tool_$(CONFIG_KERNEL_GZIP) = gzip
44tool_$(CONFIG_KERNEL_BZIP2) = bzip2
45tool_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080046tool_$(CONFIG_KERNEL_LZO) = lzo
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020047
Wu Zhangjinc853d942010-06-02 16:35:24 +080048targets += vmlinux.bin.z
49$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080050 $(call if_changed,$(tool_y))
51
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020052targets += piggy.o
Wu Zhangjinc853d942010-06-02 16:35:24 +080053OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020054 --set-section-flags=.image=contents,alloc,load,readonly,data
Wu Zhangjinc853d942010-06-02 16:35:24 +080055$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020056 $(call if_changed,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080057
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080058# Calculate the load address of the compressed kernel image
59hostprogs-y := calc_vmlinuz_load_addr
60
61VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
62 $(objtree)/$(KBUILD_IMAGE) $(VMLINUX_LOAD_ADDRESS))
63
64vmlinuzobjs-y += $(obj)/piggy.o
65
66quiet_cmd_zld = LD $@
67 cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
Wu Zhangjin5089ca92010-06-16 15:52:21 +080068quiet_cmd_strip = STRIP $@
69 cmd_strip = $(STRIP) -s $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080070vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
71 $(call cmd,zld)
Wu Zhangjin5089ca92010-06-16 15:52:21 +080072 $(call cmd,strip)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080073
74#
75# Some DECstations need all possible sections of an ECOFF executable
76#
77ifdef CONFIG_MACH_DECSTATION
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020078 e2eflag := -a
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080079endif
80
81# elf2ecoff can only handle 32bit image
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080082hostprogs-y += ../elf2ecoff
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080083
84ifdef CONFIG_32BIT
85 VMLINUZ = vmlinuz
86else
87 VMLINUZ = vmlinuz.32
88endif
89
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020090quiet_cmd_32 = OBJCOPY $@
91 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080092vmlinuz.32: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020093 $(call cmd,32)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080094
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020095quiet_cmd_ecoff = ECOFF $@
96 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080097vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020098 $(call cmd,ecoff)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080099
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800100OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800101vmlinuz.bin: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200102 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800103
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800104OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800105vmlinuz.srec: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200106 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800107
Wu Zhangjinec335292010-09-22 14:03:57 +0800108clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}