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