MIPS: zboot: Avoid useless rebuilds
[linux-drm-fsl-dcu.git] / arch / mips / boot / compressed / Makefile
1 #
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
12 # Author: Wu Zhangjin <wuzhangjin@gmail.com>
13 #
14
15 include $(srctree)/arch/mips/Kbuild.platforms
16
17 # set the default size of the mallocing area for decompressing
18 BOOT_HEAP_SIZE := 0x400000
19
20 # Disable Function Tracer
21 KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
22
23 KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
24
25 KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
26         -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
27
28 KBUILD_AFLAGS := $(LINUXINCLUDE) $(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_MIPS_ALCHEMY)                 += $(obj)/uart-alchemy.o
39 endif
40
41 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
42
43 $(obj)/ashldi3.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
44 $(obj)/ashldi3.c: $(srctree)/arch/mips/lib/ashldi3.c
45         $(call cmd,shipped)
46
47 targets := $(notdir $(vmlinuzobjs-y))
48
49 targets += vmlinux.bin
50 OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
51 $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
52         $(call if_changed,objcopy)
53
54 tool_$(CONFIG_KERNEL_GZIP)    = gzip
55 tool_$(CONFIG_KERNEL_BZIP2)   = bzip2
56 tool_$(CONFIG_KERNEL_LZ4)     = lz4
57 tool_$(CONFIG_KERNEL_LZMA)    = lzma
58 tool_$(CONFIG_KERNEL_LZO)     = lzo
59 tool_$(CONFIG_KERNEL_XZ)      = xzkern
60
61 targets += vmlinux.bin.z
62 $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
63         $(call if_changed,$(tool_y))
64
65 targets += piggy.o dummy.o
66 OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
67                         --set-section-flags=.image=contents,alloc,load,readonly,data
68 $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
69         $(call if_changed,objcopy)
70
71 # Calculate the load address of the compressed kernel image
72 hostprogs-y := calc_vmlinuz_load_addr
73
74 ifneq ($(zload-y),)
75 VMLINUZ_LOAD_ADDRESS := $(zload-y)
76 else
77 VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
78                 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
79 endif
80
81 vmlinuzobjs-y += $(obj)/piggy.o
82
83 quiet_cmd_zld = LD      $@
84       cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
85 quiet_cmd_strip = STRIP   $@
86       cmd_strip = $(STRIP) -s $@
87 vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
88         $(call cmd,zld)
89         $(call cmd,strip)
90
91 #
92 # Some DECstations need all possible sections of an ECOFF executable
93 #
94 ifdef CONFIG_MACH_DECSTATION
95   e2eflag := -a
96 endif
97
98 # elf2ecoff can only handle 32bit image
99 hostprogs-y += ../elf2ecoff
100
101 ifdef CONFIG_32BIT
102         VMLINUZ = vmlinuz
103 else
104         VMLINUZ = vmlinuz.32
105 endif
106
107 quiet_cmd_32 = OBJCOPY $@
108       cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
109 vmlinuz.32: vmlinuz
110         $(call cmd,32)
111
112 quiet_cmd_ecoff = ECOFF   $@
113       cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
114 vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
115         $(call cmd,ecoff)
116
117 OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
118 vmlinuz.bin: vmlinuz
119         $(call cmd,objcopy)
120
121 OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
122 vmlinuz.srec: vmlinuz
123         $(call cmd,objcopy)
124
125 clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}