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