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