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