xref: /openbmc/linux/arch/powerpc/boot/Makefile (revision 165f2d28)
1# SPDX-License-Identifier: GPL-2.0
2# Makefile for making ELF bootable images for booting on CHRP
3# using Open Firmware.
4#
5# Geert Uytterhoeven	September 1997
6#
7# Based on coffboot by Paul Mackerras
8# Simplified for ppc64 by Todd Inglett
9#
10# NOTE:	this code is built for 32 bit in ELF32 format even though
11#	it packages a 64 bit kernel.  We do this to simplify the
12#	bootloader and increase compatibility with OpenFirmware.
13#
14#	To this end we need to define BOOTCC, etc, as the tools
15#	needed to build the 32 bit image.  That's normally the same
16#	compiler for the rest of the kernel, with the -m32 flag added.
17#	To make it easier to setup a cross compiler,
18#	CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
19#	in the toplevel makefile.
20
21all: $(obj)/zImage
22
23ifdef CROSS32_COMPILE
24    BOOTCC := $(CROSS32_COMPILE)gcc
25    BOOTAR := $(CROSS32_COMPILE)ar
26else
27    BOOTCC := $(CC)
28    BOOTAR := $(AR)
29endif
30
31BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
32		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
33		 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
34		 $(LINUXINCLUDE)
35
36ifdef CONFIG_PPC64_BOOT_WRAPPER
37BOOTCFLAGS	+= -m64
38else
39BOOTCFLAGS	+= -m32
40endif
41
42BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
43
44ifdef CONFIG_CPU_BIG_ENDIAN
45BOOTCFLAGS	+= -mbig-endian
46else
47BOOTCFLAGS	+= -mlittle-endian
48BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
49endif
50
51BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc
52
53BOOTARFLAGS	:= -crD
54
55ifdef CONFIG_CC_IS_CLANG
56BOOTCFLAGS += $(CLANG_FLAGS)
57BOOTAFLAGS += $(CLANG_FLAGS)
58endif
59
60ifdef CONFIG_DEBUG_INFO
61BOOTCFLAGS	+= -g
62endif
63
64ifeq ($(call cc-option-yn, -fstack-protector),y)
65BOOTCFLAGS	+= -fno-stack-protector
66endif
67
68BOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)
69
70DTC_FLAGS	?= -p 1024
71
72$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
73$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
74$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
75$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
76$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
77$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
78$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
79$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
80$(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
81$(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
82$(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
83
84# The pre-boot decompressors pull in a lot of kernel headers and other source
85# files. This creates a bit of a dependency headache since we need to copy
86# these files into the build dir, fix up any includes and ensure that dependent
87# files are copied in the right order.
88
89# these need to be seperate variables because they are copied out of different
90# directories in the kernel tree. Sure you COULd merge them, but it's a
91# cure-is-worse-than-disease situation.
92zlib-decomp-$(CONFIG_KERNEL_GZIP) := decompress_inflate.c
93zlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c
94zlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h infutil.h
95zliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h
96
97$(addprefix $(obj)/, decompress.o): \
98	$(addprefix $(obj)/,$(zlib-decomp-y))
99
100$(addprefix $(obj)/, $(zlib-decomp-y)): \
101	$(addprefix $(obj)/,$(zliblinuxheader-y)) \
102	$(addprefix $(obj)/,$(zlibheader-y)) \
103	$(addprefix $(obj)/,$(zlib-y))
104
105$(addprefix $(obj)/,$(zlib-y)): \
106	$(addprefix $(obj)/,$(zliblinuxheader-y)) \
107	$(addprefix $(obj)/,$(zlibheader-y))
108
109libfdt       := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
110libfdtheader := fdt.h libfdt.h libfdt_internal.h
111
112$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \
113	treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \
114	$(addprefix $(obj)/,$(libfdtheader))
115
116src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
117		$(libfdt) libfdt-wrapper.c \
118		ns16550.c serial.c simple_alloc.c div64.S util.S \
119		elf_util.c $(zlib-y) devtree.c stdlib.c \
120		oflib.c ofconsole.c cuboot.c
121
122src-wlib-$(CONFIG_PPC_MPC52XX) += mpc52xx-psc.c
123src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S opal.c
124ifndef CONFIG_PPC64_BOOT_WRAPPER
125src-wlib-y += crtsavres.S
126endif
127src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
128src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
129src-wlib-$(CONFIG_PPC_8xx) += mpc8xx.c planetcore.c fsl-soc.c
130src-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c
131src-wlib-$(CONFIG_EMBEDDED6xx) += ugecon.c fsl-soc.c
132src-wlib-$(CONFIG_XILINX_VIRTEX) += uartlite.c
133src-wlib-$(CONFIG_CPM) += cpm-serial.c
134
135src-plat-y := of.c epapr.c
136src-plat-$(CONFIG_40x) += fixed-head.S ep405.c cuboot-hotfoot.c \
137				treeboot-walnut.c cuboot-acadia.c \
138				cuboot-kilauea.c simpleboot.c \
139				virtex405-head.S virtex.c
140src-plat-$(CONFIG_44x) += treeboot-ebony.c cuboot-ebony.c treeboot-bamboo.c \
141				cuboot-bamboo.c cuboot-sam440ep.c \
142				cuboot-sequoia.c cuboot-rainier.c \
143				cuboot-taishan.c cuboot-katmai.c \
144				cuboot-warp.c cuboot-yosemite.c \
145				treeboot-iss4xx.c treeboot-currituck.c \
146				treeboot-akebono.c \
147				simpleboot.c fixed-head.S virtex.c
148src-plat-$(CONFIG_PPC_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c
149src-plat-$(CONFIG_PPC_MPC52xx) += cuboot-52xx.c
150src-plat-$(CONFIG_PPC_82xx) += cuboot-pq2.c fixed-head.S ep8248e.c cuboot-824x.c
151src-plat-$(CONFIG_PPC_83xx) += cuboot-83xx.c fixed-head.S redboot-83xx.c
152src-plat-$(CONFIG_FSL_SOC_BOOKE) += cuboot-85xx.c cuboot-85xx-cpm2.c
153src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
154					gamecube-head.S gamecube.c \
155					wii-head.S wii.c holly.c \
156					fixed-head.S mvme5100.c
157src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
158src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
159src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
160src-plat-$(CONFIG_PPC_PSERIES) += pseries-head.S
161src-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S
162src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
163src-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c
164
165src-wlib := $(sort $(src-wlib-y))
166src-plat := $(sort $(src-plat-y))
167src-boot := $(src-wlib) $(src-plat) empty.c
168
169src-boot := $(addprefix $(obj)/, $(src-boot))
170obj-boot := $(addsuffix .o, $(basename $(src-boot)))
171obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
172obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
173obj-plat: $(libfdt)
174
175quiet_cmd_copy_kern_src = COPY    $@
176      cmd_copy_kern_src = sed -f $(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
177
178$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
179	$(call cmd,copy_kern_src)
180
181$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
182	$(call cmd,copy_kern_src)
183
184$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
185	$(call cmd,copy_kern_src)
186
187$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/%
188	$(call cmd,copy_kern_src)
189
190quiet_cmd_copy_libfdt = COPY    $@
191      cmd_copy_libfdt = cp $< $@
192
193$(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
194	$(call cmd,copy_libfdt)
195
196$(obj)/empty.c:
197	$(Q)touch $@
198
199$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
200	$(Q)cp $< $@
201
202clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
203		$(zlib-decomp-) $(libfdt) $(libfdtheader) \
204		empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
205
206quiet_cmd_bootcc = BOOTCC  $@
207      cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
208
209quiet_cmd_bootas = BOOTAS  $@
210      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
211
212quiet_cmd_bootar = BOOTAR  $@
213      cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@
214
215$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
216	$(call if_changed_dep,bootcc)
217$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
218	$(Q)mkdir -p $(dir $@)
219	$(call if_changed_dep,bootcc)
220$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
221	$(Q)mkdir -p $(dir $@)
222	$(call if_changed_dep,bootas)
223
224$(obj)/wrapper.a: $(obj-wlib) FORCE
225	$(call if_changed,bootar)
226
227hostprogs	:= addnote hack-coff mktree
228
229targets		+= $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
230extra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
231		   $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
232
233dtstree		:= $(srctree)/$(src)/dts
234
235wrapper		:=$(srctree)/$(src)/wrapper
236wrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
237			$(wrapper) FORCE
238
239#############
240# Bits for building various flavours of zImage
241
242ifneq ($(CROSS32_COMPILE),)
243CROSSWRAP := -C "$(CROSS32_COMPILE)"
244else
245ifneq ($(CROSS_COMPILE),)
246CROSSWRAP := -C "$(CROSS_COMPILE)"
247endif
248endif
249
250compressor-$(CONFIG_KERNEL_GZIP) := gz
251compressor-$(CONFIG_KERNEL_XZ)   := xz
252compressor-$(CONFIG_KERNEL_LZMA)   := lzma
253compressor-$(CONFIG_KERNEL_LZO) := lzo
254
255# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
256quiet_cmd_wrap	= WRAP    $@
257      cmd_wrap	=$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
258		$(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
259		vmlinux
260
261image-$(CONFIG_PPC_PSERIES)		+= zImage.pseries
262image-$(CONFIG_PPC_POWERNV)		+= zImage.pseries
263image-$(CONFIG_PPC_MAPLE)		+= zImage.maple
264image-$(CONFIG_PPC_IBM_CELL_BLADE)	+= zImage.pseries
265image-$(CONFIG_PPC_PS3)			+= dtbImage.ps3
266image-$(CONFIG_PPC_CHRP)		+= zImage.chrp
267image-$(CONFIG_PPC_EFIKA)		+= zImage.chrp
268image-$(CONFIG_PPC_PMAC)		+= zImage.pmac
269image-$(CONFIG_PPC_HOLLY)		+= dtbImage.holly
270image-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
271image-$(CONFIG_EPAPR_BOOT)		+= zImage.epapr
272
273#
274# Targets which embed a device tree blob
275#
276# Theses are default targets to build images which embed device tree blobs.
277# They are only required on boards which do not have FDT support in firmware.
278# Boards with newish u-boot firmware can use the uImage target above
279#
280
281# Board ports in arch/powerpc/platform/40x/Kconfig
282image-$(CONFIG_EP405)			+= dtbImage.ep405
283image-$(CONFIG_HOTFOOT)			+= cuImage.hotfoot
284image-$(CONFIG_WALNUT)			+= treeImage.walnut
285image-$(CONFIG_ACADIA)			+= cuImage.acadia
286image-$(CONFIG_OBS600)			+= uImage.obs600
287
288# Board ports in arch/powerpc/platform/44x/Kconfig
289image-$(CONFIG_EBONY)			+= treeImage.ebony cuImage.ebony
290image-$(CONFIG_BAMBOO)			+= treeImage.bamboo cuImage.bamboo
291image-$(CONFIG_SAM440EP)		+= cuImage.sam440ep
292image-$(CONFIG_SEQUOIA)			+= cuImage.sequoia
293image-$(CONFIG_RAINIER)			+= cuImage.rainier
294image-$(CONFIG_TAISHAN)			+= cuImage.taishan
295image-$(CONFIG_KATMAI)			+= cuImage.katmai
296image-$(CONFIG_WARP)			+= cuImage.warp
297image-$(CONFIG_YOSEMITE)		+= cuImage.yosemite
298image-$(CONFIG_ISS4xx)			+= treeImage.iss4xx \
299					   treeImage.iss4xx-mpic
300image-$(CONFIG_CURRITUCK)			+= treeImage.currituck
301image-$(CONFIG_AKEBONO)			+= treeImage.akebono
302
303# Board ports in arch/powerpc/platform/8xx/Kconfig
304image-$(CONFIG_MPC86XADS)		+= cuImage.mpc866ads
305image-$(CONFIG_MPC885ADS)		+= cuImage.mpc885ads
306image-$(CONFIG_PPC_EP88XC)		+= dtbImage.ep88xc
307image-$(CONFIG_PPC_ADDER875)		+= cuImage.adder875-uboot \
308					   dtbImage.adder875-redboot
309
310# Board ports in arch/powerpc/platform/52xx/Kconfig
311image-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200
312image-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200b
313image-$(CONFIG_PPC_MEDIA5200)		+= cuImage.media5200
314
315# Board ports in arch/powerpc/platform/82xx/Kconfig
316image-$(CONFIG_MPC8272_ADS)		+= cuImage.mpc8272ads
317image-$(CONFIG_PQ2FADS)			+= cuImage.pq2fads
318image-$(CONFIG_EP8248E)			+= dtbImage.ep8248e
319
320# Board ports in arch/powerpc/platform/83xx/Kconfig
321image-$(CONFIG_MPC832x_MDS)		+= cuImage.mpc832x_mds
322image-$(CONFIG_MPC832x_RDB)		+= cuImage.mpc832x_rdb
323image-$(CONFIG_MPC834x_ITX)		+= cuImage.mpc8349emitx \
324					   cuImage.mpc8349emitxgp
325image-$(CONFIG_MPC834x_MDS)		+= cuImage.mpc834x_mds
326image-$(CONFIG_MPC836x_MDS)		+= cuImage.mpc836x_mds
327image-$(CONFIG_ASP834x)			+= dtbImage.asp834x-redboot
328
329# Board ports in arch/powerpc/platform/85xx/Kconfig
330image-$(CONFIG_MPC8540_ADS)		+= cuImage.mpc8540ads
331image-$(CONFIG_MPC8560_ADS)		+= cuImage.mpc8560ads
332image-$(CONFIG_MPC85xx_CDS)		+= cuImage.mpc8541cds \
333					   cuImage.mpc8548cds_32b \
334					   cuImage.mpc8555cds
335image-$(CONFIG_MPC85xx_MDS)		+= cuImage.mpc8568mds
336image-$(CONFIG_MPC85xx_DS)		+= cuImage.mpc8544ds \
337					   cuImage.mpc8572ds
338image-$(CONFIG_TQM8540)			+= cuImage.tqm8540
339image-$(CONFIG_TQM8541)			+= cuImage.tqm8541
340image-$(CONFIG_TQM8548)			+= cuImage.tqm8548
341image-$(CONFIG_TQM8555)			+= cuImage.tqm8555
342image-$(CONFIG_TQM8560)			+= cuImage.tqm8560
343image-$(CONFIG_SBC8548)			+= cuImage.sbc8548
344image-$(CONFIG_KSI8560)			+= cuImage.ksi8560
345
346# Board ports in arch/powerpc/platform/86xx/Kconfig
347image-$(CONFIG_MVME7100)                += dtbImage.mvme7100
348
349# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
350image-$(CONFIG_STORCENTER)		+= cuImage.storcenter
351image-$(CONFIG_MPC7448HPC2)		+= cuImage.mpc7448hpc2
352image-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
353image-$(CONFIG_WII)			+= dtbImage.wii
354image-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
355
356# Board port in arch/powerpc/platform/amigaone/Kconfig
357image-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
358
359# For 32-bit powermacs, build the COFF and miboot images
360# as well as the ELF images.
361ifdef CONFIG_PPC32
362image-$(CONFIG_PPC_PMAC)	+= zImage.coff zImage.miboot
363endif
364
365# Allow extra targets to be added to the defconfig
366image-y	+= $(subst ",,$(CONFIG_EXTRA_TARGETS))
367
368initrd-  := $(patsubst zImage%, zImage.initrd%, $(image-))
369initrd-y := $(patsubst zImage%, zImage.initrd%, \
370		$(patsubst dtbImage%, dtbImage.initrd%, \
371		$(patsubst simpleImage%, simpleImage.initrd%, \
372		$(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
373initrd-y := $(filter-out $(image-y), $(initrd-y))
374targets	+= $(image-y) $(initrd-y)
375
376$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
377
378# Don't put the ramdisk on the pattern rule; when its missing make will try
379# the pattern rule with less dependencies that also matches (even with the
380# hard dependency listed).
381$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) FORCE
382	$(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
383
384$(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperbits) FORCE
385	$(call if_changed,wrap,$(subst $(obj)/zImage.,,$@))
386
387# dtbImage% - a dtbImage is a zImage with an embedded device tree blob
388$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
389	$(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
390
391$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
392	$(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb)
393
394# This cannot be in the root of $(src) as the zImage rule always adds a $(obj)
395# prefix
396$(obj)/vmlinux.strip: vmlinux
397	$(STRIP) -s -R .comment $< -o $@
398
399$(obj)/uImage: vmlinux $(wrapperbits) FORCE
400	$(call if_changed,wrap,uboot)
401
402$(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
403	$(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
404
405$(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
406	$(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb)
407
408$(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
409	$(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
410
411$(obj)/cuImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
412	$(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb)
413
414$(obj)/simpleImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
415	$(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
416
417$(obj)/simpleImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
418	$(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb)
419
420$(obj)/treeImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
421	$(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
422
423$(obj)/treeImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
424	$(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb)
425
426# Needed for the above targets to work with dts/fsl/ files
427$(obj)/dts/%.dtb: $(obj)/dts/fsl/%.dtb
428	@cp $< $@
429
430# If there isn't a platform selected then just strip the vmlinux.
431ifeq (,$(image-y))
432image-y := vmlinux.strip
433endif
434
435$(obj)/zImage:		$(addprefix $(obj)/, $(image-y))
436	$(Q)rm -f $@; ln $< $@
437$(obj)/zImage.initrd:	$(addprefix $(obj)/, $(initrd-y))
438	$(Q)rm -f $@; ln $< $@
439
440# Only install the vmlinux
441install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
442	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
443
444# Install the vmlinux and other built boot targets.
445zInstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
446	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
447
448PHONY += install zInstall
449
450# anything not in $(targets)
451clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \
452	zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \
453	zImage.miboot zImage.pmac zImage.pseries \
454	zImage.maple simpleImage.* otheros.bld
455
456# clean up files cached by wrapper
457clean-kernel-base := vmlinux.strip vmlinux.bin
458clean-kernel := $(addsuffix .gz,$(clean-kernel-base))
459clean-kernel += $(addsuffix .xz,$(clean-kernel-base))
460# If not absolute clean-files are relative to $(obj).
461clean-files += $(addprefix $(objtree)/, $(clean-kernel))
462
463WRAPPER_OBJDIR := /usr/lib/kernel-wrapper
464WRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts
465WRAPPER_BINDIR := /usr/sbin
466INSTALL := install
467
468extra-installed		:= $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y))
469hostprogs-installed	:= $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs))
470wrapper-installed	:= $(DESTDIR)$(WRAPPER_BINDIR)/wrapper
471dts-installed		:= $(patsubst $(dtstree)/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(dtstree)/*.dts))
472
473all-installed		:= $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed)
474
475quiet_cmd_mkdir           = MKDIR   $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
476      cmd_mkdir           = mkdir -p $@
477
478quiet_cmd_install	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@)
479      cmd_install	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@
480
481quiet_cmd_install_dts	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@)
482      cmd_install_dts	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@
483
484quiet_cmd_install_exe	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
485      cmd_install_exe	  = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@
486
487quiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
488      cmd_install_wrapper = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\
489				sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \
490					  -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \
491
492
493$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR):
494	$(call cmd,mkdir)
495
496$(extra-installed)	: $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR)
497	$(call cmd,install)
498
499$(hostprogs-installed)  : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR)
500	$(call cmd,install_exe)
501
502$(dts-installed)	: $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR)
503	$(call cmd,install_dts)
504
505$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR)
506	$(call cmd,install_wrapper)
507
508$(obj)/bootwrapper_install: $(all-installed)
509