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