WIP FPC-III support
[linux/fpc-iii.git] / arch / mips / boot / compressed / Makefile
blob47cd9dc7454afc7e51d83aa3774341605105f220
2 # This file is subject to the terms and conditions of the GNU General Public
3 # License.
5 # Adapted for MIPS Pete Popov, Dan Malek
7 # Copyright (C) 1994 by Linus Torvalds
8 # Adapted for PowerPC by Gary Thomas
9 # modified by Cort (cort@cs.nmt.edu)
11 # Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
12 # Author: Wu Zhangjin <wuzhangjin@gmail.com>
15 include $(srctree)/arch/mips/Kbuild.platforms
17 # set the default size of the mallocing area for decompressing
18 BOOT_HEAP_SIZE := 0x400000
20 # Disable Function Tracer
21 KBUILD_CFLAGS := $(filter-out -pg, $(KBUILD_CFLAGS))
23 KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
25 # Disable lq/sq in zboot
26 ifdef CONFIG_CPU_LOONGSON64
27 KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
28 endif
30 KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \
31 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
33 KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
34 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
35 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
37 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
38 KCOV_INSTRUMENT := n
39 GCOV_PROFILE := n
41 # decompressor objects (linked with vmlinuz)
42 vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
44 ifdef CONFIG_DEBUG_ZBOOT
45 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
46 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
47 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
48 vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
49 vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o
50 endif
52 extra-y += uart-ath79.c
53 $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
54 $(call cmd,shipped)
56 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
58 extra-y += ashldi3.c
59 $(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE
60 $(call if_changed,shipped)
62 extra-y += bswapsi.c
63 $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE
64 $(call if_changed,shipped)
66 targets := $(notdir $(vmlinuzobjs-y))
68 targets += vmlinux.bin
70 OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
72 $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
73 $(call if_changed,objcopy)
75 tool_$(CONFIG_KERNEL_GZIP) = gzip
76 tool_$(CONFIG_KERNEL_BZIP2) = bzip2
77 tool_$(CONFIG_KERNEL_LZ4) = lz4
78 tool_$(CONFIG_KERNEL_LZMA) = lzma
79 tool_$(CONFIG_KERNEL_LZO) = lzo
80 tool_$(CONFIG_KERNEL_XZ) = xzkern
81 tool_$(CONFIG_KERNEL_ZSTD) = zstd22
83 targets += vmlinux.bin.z
85 $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
86 $(call if_changed,$(tool_y))
88 targets += piggy.o dummy.o
90 OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
91 --set-section-flags=.image=contents,alloc,load,readonly,data
93 $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
94 $(call if_changed,objcopy)
96 HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE)
98 # Calculate the load address of the compressed kernel image
99 hostprogs := calc_vmlinuz_load_addr
101 ifneq ($(zload-y),)
102 VMLINUZ_LOAD_ADDRESS := $(zload-y)
103 else
104 VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
105 $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS))
106 endif
107 UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS)
109 vmlinuzobjs-y += $(obj)/piggy.o
111 targets += ../../../../vmlinuz
113 quiet_cmd_zld = LD $@
114 cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
115 quiet_cmd_strip = STRIP $@
116 cmd_strip = $(STRIP) -s $@
118 $(objtree)/vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
119 $(call cmd,zld)
120 $(call cmd,strip)
122 objboot := $(objtree)/arch/mips/boot
124 $(objboot)/vmlinuz: $(objtree)/vmlinuz FORCE
127 # Some DECstations need all possible sections of an ECOFF executable
129 ifdef CONFIG_MACH_DECSTATION
130 e2eflag := -a
131 endif
133 # elf2ecoff can only handle 32bit image
134 hostprogs += ../elf2ecoff
136 ifdef CONFIG_32BIT
137 VMLINUZ = $(objtree)/vmlinuz
138 else
139 VMLINUZ = $(objboot)/vmlinuz.32
140 endif
142 targets += ../vmlinuz.32
144 quiet_cmd_32 = OBJCOPY $@
145 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
147 $(objboot)/vmlinuz.32: $(objtree)/vmlinuz
148 $(call cmd,32)
150 targets += ../vmlinuz.ecoff
152 quiet_cmd_ecoff = ECOFF $@
153 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
155 $(objboot)/vmlinuz.ecoff: $(objboot)/elf2ecoff $(VMLINUZ)
156 $(call cmd,ecoff)
158 targets += ../vmlinuz.bin
160 OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
162 $(objboot)/vmlinuz.bin: $(objtree)/vmlinuz
163 $(call cmd,objcopy)
165 targets += ../vmlinuz.srec
167 OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
169 $(objboot)/vmlinuz.srec: $(objtree)/vmlinuz
170 $(call cmd,objcopy)
172 targets += ../uzImage.bin
174 $(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE
175 $(call if_changed,uimage,none)
178 # Flattened Image Tree (.itb) image
181 ifeq ($(ADDR_BITS),32)
182 itb_addr_cells = 1
183 endif
184 ifeq ($(ADDR_BITS),64)
185 itb_addr_cells = 2
186 endif
188 targets += ../vmlinuz.its.S
190 quiet_cmd_its_cat = CAT $@
191 cmd_its_cat = cat $(real-prereqs) >$@
193 $(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
194 $(call if_changed,its_cat)
196 targets += ../vmlinuz.its
198 quiet_cmd_cpp_its_S = ITS $@
199 cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \
200 -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
201 -DVMLINUX_BINARY="\"$(2)\"" \
202 -DVMLINUX_COMPRESSION="\"none\"" \
203 -DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
204 -DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
205 -DADDR_BITS=$(ADDR_BITS) \
206 -DADDR_CELLS=$(itb_addr_cells)
208 $(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE
209 $(call if_changed,cpp_its_S,vmlinuz.bin)
211 targets += ../vmlinuz.itb
213 quiet_cmd_itb-image = ITB $@
214 cmd_itb-image = \
215 env PATH="$(objtree)/scripts/dtc:$(PATH)" \
216 $(BASH) $(MKIMAGE) \
217 -D "-I dts -O dtb -p 500 \
218 --include $(objtree)/arch/mips \
219 --warning no-unit_address_vs_reg" \
220 -f $(2) $@
222 $(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE
223 $(call if_changed,itb-image,$<)