Makefile 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#
# 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
12
# Author: Wu Zhangjin <wuzhangjin@gmail.com>
13 14 15 16 17 18 19 20 21
#

# 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__ \
22
	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
23 24

KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
25 26
	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
	-DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ )
27

28 29 30 31
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
32

33
ifdef CONFIG_DEBUG_ZBOOT
34
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
35
vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY)		   += $(obj)/uart-alchemy.o
36
endif
37

38
targets += vmlinux.bin
39
OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
40
$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
41 42 43 44 45
	$(call if_changed,objcopy)

tool_$(CONFIG_KERNEL_GZIP)    = gzip
tool_$(CONFIG_KERNEL_BZIP2)   = bzip2
tool_$(CONFIG_KERNEL_LZMA)    = lzma
46
tool_$(CONFIG_KERNEL_LZO)     = lzo
47

48 49
targets += vmlinux.bin.z
$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
50 51
	$(call if_changed,$(tool_y))

52
targets += piggy.o
53
OBJCOPYFLAGS_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 59 60
# Calculate the load address of the compressed kernel image
hostprogs-y := calc_vmlinuz_load_addr

61 62 63
ifeq ($(CONFIG_MACH_JZ4740),y)
VMLINUZ_LOAD_ADDRESS := 0x80600000
else
64
VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
65
		$(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
66
endif
67 68 69 70 71

vmlinuzobjs-y += $(obj)/piggy.o

quiet_cmd_zld = LD      $@
      cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
72 73
quiet_cmd_strip = STRIP   $@
      cmd_strip = $(STRIP) -s $@
74 75
vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
	$(call cmd,zld)
76
	$(call cmd,strip)
77 78 79 80 81

#
# Some DECstations need all possible sections of an ECOFF executable
#
ifdef CONFIG_MACH_DECSTATION
82
  e2eflag := -a
83 84 85
endif

# elf2ecoff can only handle 32bit image
86
hostprogs-y += ../elf2ecoff
87 88 89 90 91 92 93

ifdef CONFIG_32BIT
	VMLINUZ = vmlinuz
else
	VMLINUZ = vmlinuz.32
endif

94 95
quiet_cmd_32 = OBJCOPY $@
      cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
96
vmlinuz.32: vmlinuz
97
	$(call cmd,32)
98

99 100
quiet_cmd_ecoff = ECOFF   $@
      cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
101
vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
102
	$(call cmd,ecoff)
103

104
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
105
vmlinuz.bin: vmlinuz
106
	$(call cmd,objcopy)
107

108
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
109
vmlinuz.srec: vmlinuz
110
	$(call cmd,objcopy)
111

112
clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}