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