Makefile 4.1 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
include $(srctree)/arch/mips/Kbuild.platforms

17 18 19 20
# set the default size of the mallocing area for decompressing
BOOT_HEAP_SIZE := 0x400000

# Disable Function Tracer
21
KBUILD_CFLAGS := $(filter-out -pg, $(KBUILD_CFLAGS))
22

23 24
KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))

25
KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ \
26
	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
27

28
KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
29
	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
30
	-DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
31

32
# decompressor objects (linked with vmlinuz)
33
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
34

35
ifdef CONFIG_DEBUG_ZBOOT
36
vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT)		   += $(obj)/dbg.o
37
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
38
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
39
vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY)		   += $(obj)/uart-alchemy.o
40
vmlinuzobjs-$(CONFIG_ATH79)			   += $(obj)/uart-ath79.o
41
endif
42

43 44 45 46
extra-y += uart-ath79.c
$(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
	$(call cmd,shipped)

47
vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
48

49
extra-y += ashldi3.c bswapsi.c
50 51
$(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
52 53 54
	$(call cmd,shipped)

targets := $(notdir $(vmlinuzobjs-y))
55

56
targets += vmlinux.bin
57
OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
58
$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
59 60 61 62
	$(call if_changed,objcopy)

tool_$(CONFIG_KERNEL_GZIP)    = gzip
tool_$(CONFIG_KERNEL_BZIP2)   = bzip2
63
tool_$(CONFIG_KERNEL_LZ4)     = lz4
64
tool_$(CONFIG_KERNEL_LZMA)    = lzma
65
tool_$(CONFIG_KERNEL_LZO)     = lzo
66
tool_$(CONFIG_KERNEL_XZ)      = xzkern
67

68 69
targets += vmlinux.bin.z
$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
70 71
	$(call if_changed,$(tool_y))

72
targets += piggy.o dummy.o
73
OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
R
Ralf Baechle 已提交
74
			--set-section-flags=.image=contents,alloc,load,readonly,data
75
$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
76
	$(call if_changed,objcopy)
77

78 79 80
# Calculate the load address of the compressed kernel image
hostprogs-y := calc_vmlinuz_load_addr

81 82
ifneq ($(zload-y),)
VMLINUZ_LOAD_ADDRESS := $(zload-y)
83
else
84
VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
85
		$(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
86
endif
87
UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS)
88 89 90

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

91
quiet_cmd_zld = LD      $@
92
      cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
R
Ralf Baechle 已提交
93
quiet_cmd_strip = STRIP	  $@
94
      cmd_strip = $(STRIP) -s $@
95 96
vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
	$(call cmd,zld)
97
	$(call cmd,strip)
98 99 100 101 102

#
# Some DECstations need all possible sections of an ECOFF executable
#
ifdef CONFIG_MACH_DECSTATION
103
  e2eflag := -a
104 105 106
endif

# elf2ecoff can only handle 32bit image
107
hostprogs-y += ../elf2ecoff
108 109 110 111 112 113 114

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

115 116
quiet_cmd_32 = OBJCOPY $@
      cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
117
vmlinuz.32: vmlinuz
118
	$(call cmd,32)
119

R
Ralf Baechle 已提交
120
quiet_cmd_ecoff = ECOFF	  $@
121
      cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
122
vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
123
	$(call cmd,ecoff)
124

125
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
126
vmlinuz.bin: vmlinuz
127
	$(call cmd,objcopy)
128

129
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
130
vmlinuz.srec: vmlinuz
131
	$(call cmd,objcopy)
132

133 134 135
uzImage.bin: vmlinuz.bin FORCE
	$(call if_changed,uimage,none)

136 137 138 139 140
clean-files += $(objtree)/vmlinuz
clean-files += $(objtree)/vmlinuz.32
clean-files += $(objtree)/vmlinuz.ecoff
clean-files += $(objtree)/vmlinuz.bin
clean-files += $(objtree)/vmlinuz.srec