xref: /linux/arch/powerpc/boot/Makefile (revision 5e9dcb6188a40e604e66dc30fab30c2be89aa1cc)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
294b212c2SPaul Mackerras# Makefile for making ELF bootable images for booting on CHRP
394b212c2SPaul Mackerras# using Open Firmware.
494b212c2SPaul Mackerras#
594b212c2SPaul Mackerras# Geert Uytterhoeven	September 1997
694b212c2SPaul Mackerras#
794b212c2SPaul Mackerras# Based on coffboot by Paul Mackerras
894b212c2SPaul Mackerras# Simplified for ppc64 by Todd Inglett
994b212c2SPaul Mackerras#
1094b212c2SPaul Mackerras# NOTE:	this code is built for 32 bit in ELF32 format even though
1194b212c2SPaul Mackerras#	it packages a 64 bit kernel.  We do this to simplify the
1294b212c2SPaul Mackerras#	bootloader and increase compatibility with OpenFirmware.
1394b212c2SPaul Mackerras#
1494b212c2SPaul Mackerras#	To this end we need to define BOOTCC, etc, as the tools
15b610b978SDavid Gibson#	needed to build the 32 bit image.  That's normally the same
16b610b978SDavid Gibson#	compiler for the rest of the kernel, with the -m32 flag added.
1794b212c2SPaul Mackerras#	To make it easier to setup a cross compiler,
1894b212c2SPaul Mackerras#	CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
1994b212c2SPaul Mackerras#	in the toplevel makefile.
2094b212c2SPaul Mackerras
212bf11819SPaul Mackerrasall: $(obj)/zImage
2294b212c2SPaul Mackerras
2322750d98SOliver O'Hallorancompress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
24c762c69eSOliver O'Hallorancompress-$(CONFIG_KERNEL_XZ)   := CONFIG_KERNEL_XZ
2522750d98SOliver O'Halloran
26af3901cbSNicholas Pigginifdef CROSS32_COMPILE
27af3901cbSNicholas Piggin    BOOTCC := $(CROSS32_COMPILE)gcc
28af3901cbSNicholas Piggin    BOOTAR := $(CROSS32_COMPILE)ar
29af3901cbSNicholas Pigginelse
30af3901cbSNicholas Piggin    BOOTCC := $(CC)
31af3901cbSNicholas Piggin    BOOTAR := $(AR)
32af3901cbSNicholas Pigginendif
33af3901cbSNicholas Piggin
34b610b978SDavid GibsonBOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
356846ee5cSBenjamin Herrenschmidt		 -fno-strict-aliasing -Os -msoft-float -pipe \
36b610b978SDavid Gibson		 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
3722750d98SOliver O'Halloran		 -D$(compress-y)
3822750d98SOliver O'Halloran
39147c0516SCédric Le Goaterifdef CONFIG_PPC64_BOOT_WRAPPER
40147c0516SCédric Le GoaterBOOTCFLAGS	+= -m64
4165c5ec11SMichael Ellermanelse
4265c5ec11SMichael EllermanBOOTCFLAGS	+= -m32
4365c5ec11SMichael Ellermanendif
4465c5ec11SMichael Ellerman
4565c5ec11SMichael EllermanBOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
4665c5ec11SMichael Ellerman
47147c0516SCédric Le Goaterifdef CONFIG_CPU_BIG_ENDIAN
48147c0516SCédric Le GoaterBOOTCFLAGS	+= -mbig-endian
49655471f5SBenjamin Herrenschmidtelse
50655471f5SBenjamin HerrenschmidtBOOTCFLAGS	+= -mlittle-endian
51655471f5SBenjamin HerrenschmidtBOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
52147c0516SCédric Le Goaterendif
53147c0516SCédric Le Goater
5494b212c2SPaul MackerrasBOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
5594b212c2SPaul Mackerras
56af3901cbSNicholas PigginBOOTARFLAGS	:= -cr$(KBUILD_ARFLAGS)
57af3901cbSNicholas Piggin
58105c13ddSGrant Likelyifdef CONFIG_DEBUG_INFO
59105c13ddSGrant LikelyBOOTCFLAGS	+= -g
60105c13ddSGrant Likelyendif
61105c13ddSGrant Likely
62fda7ffd2SNiels Kristian Bech Jensenifeq ($(call cc-option-yn, -fstack-protector),y)
63fda7ffd2SNiels Kristian Bech JensenBOOTCFLAGS	+= -fno-stack-protector
64fda7ffd2SNiels Kristian Bech Jensenendif
65fda7ffd2SNiels Kristian Bech Jensen
6658ab5e0cSArnd BergmannBOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)
6794b212c2SPaul Mackerras
6863849340SDirk BrandewieDTC_FLAGS	?= -p 1024
699d4ae9fcSKumar Gala
70bf2e70acSJosh Boyer$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
71bf2e70acSJosh Boyer$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
720cdf50a7SSolomon Peachy$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
73bf2e70acSJosh Boyer$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
74bf2e70acSJosh Boyer$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
759f3eefc4SJosh Boyer$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
762e71cc0dSJosh Boyer$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
77b4e8c8ddSTorez Smith$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
78228d5505STony Breeds$(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
792a2c74b2SAlistair Popple$(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
80b9e4f176SGrant Likely$(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
8160e41753SJosh Boyer
821b7898eeSOliver O'Halloran# The pre-boot decompressors pull in a lot of kernel headers and other source
831b7898eeSOliver O'Halloran# files. This creates a bit of a dependency headache since we need to copy
841b7898eeSOliver O'Halloran# these files into the build dir, fix up any includes and ensure that dependent
851b7898eeSOliver O'Halloran# files are copied in the right order.
861b7898eeSOliver O'Halloran
871b7898eeSOliver O'Halloran# these need to be seperate variables because they are copied out of different
881b7898eeSOliver O'Halloran# directories in the kernel tree. Sure you COULd merge them, but it's a
891b7898eeSOliver O'Halloran# cure-is-worse-than-disease situation.
901b7898eeSOliver O'Halloranzlib-decomp-$(CONFIG_KERNEL_GZIP) := decompress_inflate.c
9122750d98SOliver O'Halloranzlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c
9222750d98SOliver O'Halloranzlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h infutil.h
9322750d98SOliver O'Halloranzliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h
946bbc5476SHugh Blemings
951b7898eeSOliver O'Halloran$(addprefix $(obj)/, decompress.o): \
961b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zlib-decomp-y))
971b7898eeSOliver O'Halloran
981b7898eeSOliver O'Halloran$(addprefix $(obj)/, $(zlib-decomp-y)): \
991b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zliblinuxheader-y)) \
1001b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zlibheader-y)) \
1011b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zlib-y))
1021b7898eeSOliver O'Halloran
1031b7898eeSOliver O'Halloran$(addprefix $(obj)/,$(zlib-y)): \
10422750d98SOliver O'Halloran	$(addprefix $(obj)/,$(zliblinuxheader-y)) \
10522750d98SOliver O'Halloran	$(addprefix $(obj)/,$(zlibheader-y))
1062bf11819SPaul Mackerras
1079fffb55fSDavid Gibsonlibfdt       := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
1089fffb55fSDavid Gibsonlibfdtheader := fdt.h libfdt.h libfdt_internal.h
1099fffb55fSDavid Gibson
11064c3f648SGuenter Roeck$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \
11164c3f648SGuenter Roeck	treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \
1129fffb55fSDavid Gibson	$(addprefix $(obj)/,$(libfdtheader))
1139fffb55fSDavid Gibson
1147c868b66SNicholas Pigginsrc-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
1159fffb55fSDavid Gibson		$(libfdt) libfdt-wrapper.c \
116ad9d2716SDavid Gibson		ns16550.c serial.c simple_alloc.c div64.S util.S \
1171b7898eeSOliver O'Halloran		elf_util.c $(zlib-y) devtree.c stdlib.c \
118c3bb690dSMichael Ellerman		oflib.c ofconsole.c cuboot.c
119f8e8e69cSMichael Ellerman
120866bfc75SHannes Reineckesrc-wlib-$(CONFIG_PPC_MPC52XX) += mpc52xx-psc.c
121f8e8e69cSMichael Ellermansrc-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S opal.c
1227c868b66SNicholas Pigginifndef CONFIG_PPC64_BOOT_WRAPPER
1237c868b66SNicholas Pigginsrc-wlib-y += crtsavres.S
1247c868b66SNicholas Pigginendif
125b81f18e5STony Breedssrc-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
126b81f18e5STony Breedssrc-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
127968159c0SChristophe Leroysrc-wlib-$(CONFIG_PPC_8xx) += mpc8xx.c planetcore.c fsl-soc.c
128b81f18e5STony Breedssrc-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c
129297f8314SMark Greersrc-wlib-$(CONFIG_EMBEDDED6xx) += ugecon.c fsl-soc.c
1303d6bf693SMichael Ellermansrc-wlib-$(CONFIG_XILINX_VIRTEX) += uartlite.c
131c3bb690dSMichael Ellermansrc-wlib-$(CONFIG_CPM) += cpm-serial.c
132b81f18e5STony Breeds
1330c9fa291SBenjamin Herrenschmidtsrc-plat-y := of.c epapr.c
134b81f18e5STony Breedssrc-plat-$(CONFIG_40x) += fixed-head.S ep405.c cuboot-hotfoot.c \
135b81f18e5STony Breeds				treeboot-walnut.c cuboot-acadia.c \
136b81f18e5STony Breeds				cuboot-kilauea.c simpleboot.c \
137b81f18e5STony Breeds				virtex405-head.S virtex.c
138b81f18e5STony Breedssrc-plat-$(CONFIG_44x) += treeboot-ebony.c cuboot-ebony.c treeboot-bamboo.c \
139b81f18e5STony Breeds				cuboot-bamboo.c cuboot-sam440ep.c \
140b81f18e5STony Breeds				cuboot-sequoia.c cuboot-rainier.c \
141b81f18e5STony Breeds				cuboot-taishan.c cuboot-katmai.c \
142b81f18e5STony Breeds				cuboot-warp.c cuboot-yosemite.c \
143b81f18e5STony Breeds				treeboot-iss4xx.c treeboot-currituck.c \
1442a2c74b2SAlistair Popple				treeboot-akebono.c \
145b81f18e5STony Breeds				simpleboot.c fixed-head.S virtex.c
146968159c0SChristophe Leroysrc-plat-$(CONFIG_PPC_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c
147b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_MPC52xx) += cuboot-52xx.c
148b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_82xx) += cuboot-pq2.c fixed-head.S ep8248e.c cuboot-824x.c
149b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_83xx) += cuboot-83xx.c fixed-head.S redboot-83xx.c
150b81f18e5STony Breedssrc-plat-$(CONFIG_FSL_SOC_BOOKE) += cuboot-85xx.c cuboot-85xx-cpm2.c
151b81f18e5STony Breedssrc-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
15292c8c16fSMark Greer					gamecube-head.S gamecube.c \
15392c8c16fSMark Greer					wii-head.S wii.c holly.c \
1543c8464a9SPaul Gortmaker					fixed-head.S mvme5100.c
155b81f18e5STony Breedssrc-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
156b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
1570c9fa291SBenjamin Herrenschmidtsrc-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
1582d9afb36SCédric Le Goatersrc-plat-$(CONFIG_PPC_PSERIES) += pseries-head.S
1592d9afb36SCédric Le Goatersrc-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S
1602d9afb36SCédric Le Goatersrc-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
16197493e2eSAlessio Igor Boganisrc-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c
162b81f18e5STony Breeds
163b81f18e5STony Breedssrc-wlib := $(sort $(src-wlib-y))
164b81f18e5STony Breedssrc-plat := $(sort $(src-plat-y))
165cd197ffcSDavid Gibsonsrc-boot := $(src-wlib) $(src-plat) empty.c
1662bf11819SPaul Mackerras
1672bf11819SPaul Mackerrassrc-boot := $(addprefix $(obj)/, $(src-boot))
1682bf11819SPaul Mackerrasobj-boot := $(addsuffix .o, $(basename $(src-boot)))
1692bf11819SPaul Mackerrasobj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
1702bf11819SPaul Mackerrasobj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
1710090e02bSMatthew McClintockobj-plat: $(libfdt)
1722bf11819SPaul Mackerras
1731a13de6dSOliver O'Halloranquiet_cmd_copy_kern_src = COPY    $@
1741a13de6dSOliver O'Halloran      cmd_copy_kern_src = sed -f $(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
17594b212c2SPaul Mackerras
17622750d98SOliver O'Halloran$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
1771a13de6dSOliver O'Halloran	$(call cmd,copy_kern_src)
17894b212c2SPaul Mackerras
17922750d98SOliver O'Halloran$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
1801a13de6dSOliver O'Halloran	$(call cmd,copy_kern_src)
18194b212c2SPaul Mackerras
18222750d98SOliver O'Halloran$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
1831a13de6dSOliver O'Halloran	$(call cmd,copy_kern_src)
18494b212c2SPaul Mackerras
1851b7898eeSOliver O'Halloran$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/%
1861b7898eeSOliver O'Halloran	$(call cmd,copy_kern_src)
1871b7898eeSOliver O'Halloran
1889fffb55fSDavid Gibsonquiet_cmd_copy_libfdt = COPY    $@
1899fffb55fSDavid Gibson      cmd_copy_libfdt = cp $< $@
1909fffb55fSDavid Gibson
1919fffb55fSDavid Gibson$(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
1929fffb55fSDavid Gibson	$(call cmd,copy_libfdt)
1939fffb55fSDavid Gibson
1942bf11819SPaul Mackerras$(obj)/empty.c:
1956abe248eSMichael Ellerman	$(Q)touch $@
19694b212c2SPaul Mackerras
197147c0516SCédric Le Goater$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
1986abe248eSMichael Ellerman	$(Q)cp $< $@
1992bf11819SPaul Mackerras
200*5e9dcb61SJoel Stanley$(obj)/serial.c: $(obj)/autoconf.h
201*5e9dcb61SJoel Stanley
202*5e9dcb61SJoel Stanley$(obj)/autoconf.h: $(obj)/%: $(objtree)/include/generated/%
203*5e9dcb61SJoel Stanley	$(Q)cp $< $@
204*5e9dcb61SJoel Stanley
20522750d98SOliver O'Halloranclean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
2061b7898eeSOliver O'Halloran		$(zlib-decomp-) $(libfdt) $(libfdtheader) \
207*5e9dcb61SJoel Stanley		autoconf.h empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
20894b212c2SPaul Mackerras
20994b212c2SPaul Mackerrasquiet_cmd_bootcc = BOOTCC  $@
21065c5ec11SMichael Ellerman      cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
21194b212c2SPaul Mackerras
21294b212c2SPaul Mackerrasquiet_cmd_bootas = BOOTAS  $@
21365c5ec11SMichael Ellerman      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
21494b212c2SPaul Mackerras
2152bf11819SPaul Mackerrasquiet_cmd_bootar = BOOTAR  $@
216af3901cbSNicholas Piggin      cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
21794b212c2SPaul Mackerras
2189fffb55fSDavid Gibson$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
2199fffb55fSDavid Gibson	$(call if_changed_dep,bootcc)
220235fd835SMilton Miller$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
2212f0dfeaaSDavid Gibson	$(Q)mkdir -p $(dir $@)
22294b212c2SPaul Mackerras	$(call if_changed_dep,bootcc)
223235fd835SMilton Miller$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
2242f0dfeaaSDavid Gibson	$(Q)mkdir -p $(dir $@)
22594b212c2SPaul Mackerras	$(call if_changed_dep,bootas)
22694b212c2SPaul Mackerras
227235fd835SMilton Miller$(obj)/wrapper.a: $(obj-wlib) FORCE
228235fd835SMilton Miller	$(call if_changed,bootar)
22994b212c2SPaul Mackerras
23097bb63e4SPaul Mackerrashostprogs-y	:= addnote hack-coff mktree
23166a45dd3SPaul Mackerras
232235fd835SMilton Millertargets		+= $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
233cd197ffcSDavid Gibsonextra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
234bafdb645SGeoff Levand		   $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
23594b212c2SPaul Mackerras
23625431333SGrant Likelydtstree		:= $(srctree)/$(src)/dts
23725431333SGrant Likely
2382bf11819SPaul Mackerraswrapper		:=$(srctree)/$(src)/wrapper
2399fffb55fSDavid Gibsonwrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
240235fd835SMilton Miller			$(wrapper) FORCE
24194b212c2SPaul Mackerras
2422bf11819SPaul Mackerras#############
2432bf11819SPaul Mackerras# Bits for building various flavours of zImage
24494b212c2SPaul Mackerras
2452bf11819SPaul Mackerrasifneq ($(CROSS32_COMPILE),)
246dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS32_COMPILE)"
2472bf11819SPaul Mackerraselse
2482bf11819SPaul Mackerrasifneq ($(CROSS_COMPILE),)
249dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS_COMPILE)"
2502bf11819SPaul Mackerrasendif
2512bf11819SPaul Mackerrasendif
25294b212c2SPaul Mackerras
253f1e510bbSOliver O'Hallorancompressor-$(CONFIG_KERNEL_GZIP) := gz
254c762c69eSOliver O'Hallorancompressor-$(CONFIG_KERNEL_XZ)   := xz
255f1e510bbSOliver O'Halloran
2569da82a6dSMilton Miller# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
2572bf11819SPaul Mackerrasquiet_cmd_wrap	= WRAP    $@
258f1e510bbSOliver O'Halloran      cmd_wrap	=$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
259f1e510bbSOliver O'Halloran		$(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
260f1e510bbSOliver O'Halloran		vmlinux
2612bf11819SPaul Mackerras
2622bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PSERIES)		+= zImage.pseries
26355190f88SBenjamin Herrenschmidtimage-$(CONFIG_PPC_POWERNV)		+= zImage.pseries
26458706ef9SCorey Minyardimage-$(CONFIG_PPC_MAPLE)		+= zImage.maple
265020533efSGeoff Levandimage-$(CONFIG_PPC_IBM_CELL_BLADE)	+= zImage.pseries
266595be948SGrant Likelyimage-$(CONFIG_PPC_PS3)			+= dtbImage.ps3
2672bf11819SPaul Mackerrasimage-$(CONFIG_PPC_CHRP)		+= zImage.chrp
2687839af33SNicolas DETimage-$(CONFIG_PPC_EFIKA)		+= zImage.chrp
2692bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC)		+= zImage.pmac
27032dde0f9SJosh Boyerimage-$(CONFIG_PPC_HOLLY)		+= dtbImage.holly
271ac18c673SScott Woodimage-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
2726c5b59b9SDavid Gibsonimage-$(CONFIG_EPAPR_BOOT)		+= zImage.epapr
273ac18c673SScott Wood
27425431333SGrant Likely#
27525431333SGrant Likely# Targets which embed a device tree blob
27625431333SGrant Likely#
27725431333SGrant Likely# Theses are default targets to build images which embed device tree blobs.
27825431333SGrant Likely# They are only required on boards which do not have FDT support in firmware.
2792a94739cSNick Andrew# Boards with newish u-boot firmware can use the uImage target above
28025431333SGrant Likely#
28125431333SGrant Likely
28225431333SGrant Likely# Board ports in arch/powerpc/platform/40x/Kconfig
283595be948SGrant Likelyimage-$(CONFIG_EP405)			+= dtbImage.ep405
2840cdf50a7SSolomon Peachyimage-$(CONFIG_HOTFOOT)			+= cuImage.hotfoot
28525431333SGrant Likelyimage-$(CONFIG_WALNUT)			+= treeImage.walnut
28694c73a8fSJosh Boyerimage-$(CONFIG_ACADIA)			+= cuImage.acadia
28711eab297SBenjamin Herrenschmidtimage-$(CONFIG_OBS600)			+= uImage.obs600
28825431333SGrant Likely
28925431333SGrant Likely# Board ports in arch/powerpc/platform/44x/Kconfig
290f6dfc805SDavid Gibsonimage-$(CONFIG_EBONY)			+= treeImage.ebony cuImage.ebony
291658e8170SJosh Boyerimage-$(CONFIG_BAMBOO)			+= treeImage.bamboo cuImage.bamboo
292b6014e15SGiuseppe Covielloimage-$(CONFIG_SAM440EP)		+= cuImage.sam440ep
293606d08bcSValentine Barshakimage-$(CONFIG_SEQUOIA)			+= cuImage.sequoia
294295e7427SValentine Barshakimage-$(CONFIG_RAINIER)			+= cuImage.rainier
2956bbc5476SHugh Blemingsimage-$(CONFIG_TAISHAN)			+= cuImage.taishan
2963de9c9cdSBenjamin Herrenschmidtimage-$(CONFIG_KATMAI)			+= cuImage.katmai
2971e12f3c5SSean MacLennanimage-$(CONFIG_WARP)			+= cuImage.warp
298d0a48c9fSJosh Boyerimage-$(CONFIG_YOSEMITE)		+= cuImage.yosemite
299b4e8c8ddSTorez Smithimage-$(CONFIG_ISS4xx)			+= treeImage.iss4xx \
300b4e8c8ddSTorez Smith					   treeImage.iss4xx-mpic
301228d5505STony Breedsimage-$(CONFIG_CURRITUCK)			+= treeImage.currituck
3022a2c74b2SAlistair Poppleimage-$(CONFIG_AKEBONO)			+= treeImage.akebono
30394b212c2SPaul Mackerras
30425431333SGrant Likely# Board ports in arch/powerpc/platform/8xx/Kconfig
305efa58fbfSAdrian Bunkimage-$(CONFIG_MPC86XADS)		+= cuImage.mpc866ads
306efa58fbfSAdrian Bunkimage-$(CONFIG_MPC885ADS)		+= cuImage.mpc885ads
307595be948SGrant Likelyimage-$(CONFIG_PPC_EP88XC)		+= dtbImage.ep88xc
30825431333SGrant Likelyimage-$(CONFIG_PPC_ADDER875)		+= cuImage.adder875-uboot \
309595be948SGrant Likely					   dtbImage.adder875-redboot
31025431333SGrant Likely
31125431333SGrant Likely# Board ports in arch/powerpc/platform/52xx/Kconfig
312bfee95bbSGrant Likelyimage-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200 lite5200.dtb
313bfee95bbSGrant Likelyimage-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200b lite5200b.dtb
314bfee95bbSGrant Likelyimage-$(CONFIG_PPC_MEDIA5200)		+= cuImage.media5200 media5200.dtb
31525431333SGrant Likely
31625431333SGrant Likely# Board ports in arch/powerpc/platform/82xx/Kconfig
31725431333SGrant Likelyimage-$(CONFIG_MPC8272_ADS)		+= cuImage.mpc8272ads
31825431333SGrant Likelyimage-$(CONFIG_PQ2FADS)			+= cuImage.pq2fads
319595be948SGrant Likelyimage-$(CONFIG_EP8248E)			+= dtbImage.ep8248e
32025431333SGrant Likely
32125431333SGrant Likely# Board ports in arch/powerpc/platform/83xx/Kconfig
32225431333SGrant Likelyimage-$(CONFIG_MPC832x_MDS)		+= cuImage.mpc832x_mds
32325431333SGrant Likelyimage-$(CONFIG_MPC832x_RDB)		+= cuImage.mpc832x_rdb
32425431333SGrant Likelyimage-$(CONFIG_MPC834x_ITX)		+= cuImage.mpc8349emitx \
32525431333SGrant Likely					   cuImage.mpc8349emitxgp
32625431333SGrant Likelyimage-$(CONFIG_MPC834x_MDS)		+= cuImage.mpc834x_mds
32725431333SGrant Likelyimage-$(CONFIG_MPC836x_MDS)		+= cuImage.mpc836x_mds
32859d13f9dSBryan O'Donoghueimage-$(CONFIG_ASP834x)			+= dtbImage.asp834x-redboot
32925431333SGrant Likely
33025431333SGrant Likely# Board ports in arch/powerpc/platform/85xx/Kconfig
33125431333SGrant Likelyimage-$(CONFIG_MPC8540_ADS)		+= cuImage.mpc8540ads
33225431333SGrant Likelyimage-$(CONFIG_MPC8560_ADS)		+= cuImage.mpc8560ads
33325431333SGrant Likelyimage-$(CONFIG_MPC85xx_CDS)		+= cuImage.mpc8541cds \
3340d4fdd32SZhao Chenhui					   cuImage.mpc8548cds_32b \
33525431333SGrant Likely					   cuImage.mpc8555cds
33625431333SGrant Likelyimage-$(CONFIG_MPC85xx_MDS)		+= cuImage.mpc8568mds
33725431333SGrant Likelyimage-$(CONFIG_MPC85xx_DS)		+= cuImage.mpc8544ds \
33825431333SGrant Likely					   cuImage.mpc8572ds
33925431333SGrant Likelyimage-$(CONFIG_TQM8540)			+= cuImage.tqm8540
34025431333SGrant Likelyimage-$(CONFIG_TQM8541)			+= cuImage.tqm8541
3416dd1b64aSWolfgang Grandeggerimage-$(CONFIG_TQM8548)			+= cuImage.tqm8548
34225431333SGrant Likelyimage-$(CONFIG_TQM8555)			+= cuImage.tqm8555
34325431333SGrant Likelyimage-$(CONFIG_TQM8560)			+= cuImage.tqm8560
344a72a6f53SPaul Gortmakerimage-$(CONFIG_SBC8548)			+= cuImage.sbc8548
345ff880112SAlexandr Smirnovimage-$(CONFIG_KSI8560)			+= cuImage.ksi8560
34625431333SGrant Likely
34797493e2eSAlessio Igor Bogani# Board ports in arch/powerpc/platform/86xx/Kconfig
34897493e2eSAlessio Igor Boganiimage-$(CONFIG_MVME7100)                += dtbImage.mvme7100
34997493e2eSAlessio Igor Bogani
35025431333SGrant Likely# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
35125431333SGrant Likelyimage-$(CONFIG_STORCENTER)		+= cuImage.storcenter
35225431333SGrant Likelyimage-$(CONFIG_MPC7448HPC2)		+= cuImage.mpc7448hpc2
353b68a24bcSAlbert Herranzimage-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
3546cdd2417SAlbert Herranzimage-$(CONFIG_WII)			+= dtbImage.wii
355be201981SStephen Chiversimage-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
356b09c1644SScott Wood
3578f23735dSGerhard Pircher# Board port in arch/powerpc/platform/amigaone/Kconfig
3588f23735dSGerhard Pircherimage-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
3598f23735dSGerhard Pircher
3609216ad8cSPaul Mackerras# For 32-bit powermacs, build the COFF and miboot images
3619216ad8cSPaul Mackerras# as well as the ELF images.
362badf436fSRodrigo R. Galvaoifdef CONFIG_PPC32
3632bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC)	+= zImage.coff zImage.miboot
3642bf11819SPaul Mackerrasendif
36566a45dd3SPaul Mackerras
366c356aa45SGrant Likely# Allow extra targets to be added to the defconfig
367c356aa45SGrant Likelyimage-y	+= $(subst ",,$(CONFIG_EXTRA_TARGETS))
368c356aa45SGrant Likely
369755457f9SMichal Marekinitrd-  := $(patsubst zImage%, zImage.initrd%, $(image-))
370f6dfc805SDavid Gibsoninitrd-y := $(patsubst zImage%, zImage.initrd%, \
371595be948SGrant Likely		$(patsubst dtbImage%, dtbImage.initrd%, \
3725d1a0411SJohn Linn		$(patsubst simpleImage%, simpleImage.initrd%, \
3735d1a0411SJohn Linn		$(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
3749da82a6dSMilton Millerinitrd-y := $(filter-out $(image-y), $(initrd-y))
375235fd835SMilton Millertargets	+= $(image-y) $(initrd-y)
37694b212c2SPaul Mackerras
3779da82a6dSMilton Miller$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
3789da82a6dSMilton Miller
3799da82a6dSMilton Miller# Don't put the ramdisk on the pattern rule; when its missing make will try
3809da82a6dSMilton Miller# the pattern rule with less dependencies that also matches (even with the
3819da82a6dSMilton Miller# hard dependency listed).
38242d0c932SMichael Ellerman$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) FORCE
38325431333SGrant Likely	$(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
3849da82a6dSMilton Miller
38542d0c932SMichael Ellerman$(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperbits) FORCE
386699c659bSMichal Marek	$(call if_changed,wrap,$(subst $(obj)/zImage.,,$@))
38725431333SGrant Likely
388595be948SGrant Likely# dtbImage% - a dtbImage is a zImage with an embedded device tree blob
38942d0c932SMichael Ellerman$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE
390e04018e8SGrant Likely	$(call if_changed,wrap,$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
39125431333SGrant Likely
39242d0c932SMichael Ellerman$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE
393e04018e8SGrant Likely	$(call if_changed,wrap,$*,,$(obj)/$*.dtb)
3949da82a6dSMilton Miller
3954bb09281STony Breeds# This cannot be in the root of $(src) as the zImage rule always adds a $(obj)
3964bb09281STony Breeds# prefix
3974bb09281STony Breeds$(obj)/vmlinux.strip: vmlinux
3984bb09281STony Breeds	$(STRIP) -s -R .comment $< -o $@
3994bb09281STony Breeds
40042d0c932SMichael Ellerman$(obj)/uImage: vmlinux $(wrapperbits) FORCE
4019da82a6dSMilton Miller	$(call if_changed,wrap,uboot)
4029da82a6dSMilton Miller
40342d0c932SMichael Ellerman$(obj)/uImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
40411eab297SBenjamin Herrenschmidt	$(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
40511eab297SBenjamin Herrenschmidt
40642d0c932SMichael Ellerman$(obj)/uImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
40711eab297SBenjamin Herrenschmidt	$(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb)
40811eab297SBenjamin Herrenschmidt
40942d0c932SMichael Ellerman$(obj)/cuImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
410a4292d7aSGrant Likely	$(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
411a4292d7aSGrant Likely
41242d0c932SMichael Ellerman$(obj)/cuImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
413e04018e8SGrant Likely	$(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb)
4140fdd717eSScott Wood
41542d0c932SMichael Ellerman$(obj)/simpleImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
416d2477b5cSGrant Likely	$(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
417d2477b5cSGrant Likely
41842d0c932SMichael Ellerman$(obj)/simpleImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
419d2477b5cSGrant Likely	$(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb)
420d2477b5cSGrant Likely
42142d0c932SMichael Ellerman$(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
422e04018e8SGrant Likely	$(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
423f6dfc805SDavid Gibson
42442d0c932SMichael Ellerman$(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
425e04018e8SGrant Likely	$(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb)
426e04018e8SGrant Likely
427e04018e8SGrant Likely# Rule to build device tree blobs
4287c431851SStephen Warren$(obj)/%.dtb: $(src)/dts/%.dts FORCE
4297c431851SStephen Warren	$(call if_changed_dep,dtc)
4306a32d085SDavid Gibson
4314680c9d5SAlessio Igor Bogani$(obj)/%.dtb: $(src)/dts/fsl/%.dts FORCE
4324680c9d5SAlessio Igor Bogani	$(call if_changed_dep,dtc)
4334680c9d5SAlessio Igor Bogani
4344bb09281STony Breeds# If there isn't a platform selected then just strip the vmlinux.
4354bb09281STony Breedsifeq (,$(image-y))
4364bb09281STony Breedsimage-y := vmlinux.strip
4374bb09281STony Breedsendif
4384bb09281STony Breeds
4392bf11819SPaul Mackerras$(obj)/zImage:		$(addprefix $(obj)/, $(image-y))
4406abe248eSMichael Ellerman	$(Q)rm -f $@; ln $< $@
4412bf11819SPaul Mackerras$(obj)/zImage.initrd:	$(addprefix $(obj)/, $(initrd-y))
4426abe248eSMichael Ellerman	$(Q)rm -f $@; ln $< $@
44394b212c2SPaul Mackerras
444c913e5f9STony Breeds# Only install the vmlinux
445928370c6SAkinobu Mitainstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
446c913e5f9STony Breeds	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
447c913e5f9STony Breeds
448c913e5f9STony Breeds# Install the vmlinux and other built boot targets.
449c913e5f9STony BreedszInstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
45029f1aff2SGrant Likely	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
45166a45dd3SPaul Mackerras
4521383a34fSMilton Miller# anything not in $(targets)
453b58a4575SKumar Galaclean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \
454b58a4575SKumar Gala	zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \
4551b041885SStephen Rothwell	zImage.miboot zImage.pmac zImage.pseries \
45674ce1896SMasahiro Yamada	zImage.maple simpleImage.* otheros.bld
4571383a34fSMilton Miller
4581383a34fSMilton Miller# clean up files cached by wrapper
4591b7898eeSOliver O'Halloranclean-kernel-base := vmlinux.strip vmlinux.bin
4601b7898eeSOliver O'Halloranclean-kernel := $(addsuffix .gz,$(clean-kernel-base))
461c762c69eSOliver O'Halloranclean-kernel += $(addsuffix .xz,$(clean-kernel-base))
4621383a34fSMilton Miller# If not absolute clean-files are relative to $(obj).
4631383a34fSMilton Millerclean-files += $(addprefix $(objtree)/, $(clean-kernel))
464773f76b1SDavid Woodhouse
465773f76b1SDavid WoodhouseWRAPPER_OBJDIR := /usr/lib/kernel-wrapper
466773f76b1SDavid WoodhouseWRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts
467773f76b1SDavid WoodhouseWRAPPER_BINDIR := /usr/sbin
468773f76b1SDavid WoodhouseINSTALL := install
469773f76b1SDavid Woodhouse
470773f76b1SDavid Woodhouseextra-installed		:= $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y))
471773f76b1SDavid Woodhousehostprogs-installed	:= $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs-y))
472773f76b1SDavid Woodhousewrapper-installed	:= $(DESTDIR)$(WRAPPER_BINDIR)/wrapper
4734d9ef89dSBen Hutchingsdts-installed		:= $(patsubst $(dtstree)/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(dtstree)/*.dts))
474773f76b1SDavid Woodhouse
475773f76b1SDavid Woodhouseall-installed		:= $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed)
476773f76b1SDavid Woodhouse
477773f76b1SDavid Woodhousequiet_cmd_mkdir           = MKDIR   $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
478773f76b1SDavid Woodhouse      cmd_mkdir           = mkdir -p $@
479773f76b1SDavid Woodhouse
480773f76b1SDavid Woodhousequiet_cmd_install	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@)
481773f76b1SDavid Woodhouse      cmd_install	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@
482773f76b1SDavid Woodhouse
483773f76b1SDavid Woodhousequiet_cmd_install_dts	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@)
484773f76b1SDavid Woodhouse      cmd_install_dts	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@
485773f76b1SDavid Woodhouse
486773f76b1SDavid Woodhousequiet_cmd_install_exe	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
487773f76b1SDavid Woodhouse      cmd_install_exe	  = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@
488773f76b1SDavid Woodhouse
489773f76b1SDavid Woodhousequiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
490773f76b1SDavid Woodhouse      cmd_install_wrapper = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\
491773f76b1SDavid Woodhouse				sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \
492773f76b1SDavid Woodhouse					  -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \
493773f76b1SDavid Woodhouse
494773f76b1SDavid Woodhouse
495773f76b1SDavid Woodhouse$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR):
496773f76b1SDavid Woodhouse	$(call cmd,mkdir)
497773f76b1SDavid Woodhouse
498773f76b1SDavid Woodhouse$(extra-installed)	: $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR)
499773f76b1SDavid Woodhouse	$(call cmd,install)
500773f76b1SDavid Woodhouse
501773f76b1SDavid Woodhouse$(hostprogs-installed)  : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR)
502773f76b1SDavid Woodhouse	$(call cmd,install_exe)
503773f76b1SDavid Woodhouse
504773f76b1SDavid Woodhouse$(dts-installed)	: $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR)
505773f76b1SDavid Woodhouse	$(call cmd,install_dts)
506773f76b1SDavid Woodhouse
507773f76b1SDavid Woodhouse$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR)
508773f76b1SDavid Woodhouse	$(call cmd,install_wrapper)
509773f76b1SDavid Woodhouse
510773f76b1SDavid Woodhouse$(obj)/bootwrapper_install: $(all-installed)
511