xref: /linux/arch/powerpc/boot/Makefile (revision 62f8f307c80e99ab18d38aa1a5bbbc18128ee5f8)
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#
10364b236aSJordan Niethe# NOTE:	this code may be 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
23af3901cbSNicholas Pigginifdef CROSS32_COMPILE
24215fadfeSBill Wendlingifdef CONFIG_CC_IS_CLANG
25215fadfeSBill Wendling    BOOTCC := $(CROSS32_COMPILE)clang
26215fadfeSBill Wendlingelse
27af3901cbSNicholas Piggin    BOOTCC := $(CROSS32_COMPILE)gcc
28215fadfeSBill Wendlingendif
29af3901cbSNicholas Piggin    BOOTAR := $(CROSS32_COMPILE)ar
30af3901cbSNicholas Pigginelse
31af3901cbSNicholas Piggin    BOOTCC := $(CC)
32af3901cbSNicholas Piggin    BOOTAR := $(AR)
33af3901cbSNicholas Pigginendif
34af3901cbSNicholas Piggin
35147c0516SCédric Le Goaterifdef CONFIG_PPC64_BOOT_WRAPPER
36689d592eSNicholas PigginBOOTTARGETFLAGS	+= -m64
37689d592eSNicholas PigginBOOTTARGETFLAGS	+= -mabi=elfv2
38d1c5accaSNathan Chancellorifdef CONFIG_PPC64_ELF_ABI_V2
39689d592eSNicholas PigginBOOTTARGETFLAGS	+= $(call cc-option,-mabi=elfv2)
40d1c5accaSNathan Chancellorendif
4165c5ec11SMichael Ellermanelse
42689d592eSNicholas PigginBOOTTARGETFLAGS	:= -m32
4340a75584SJoel Stanleyendif
44ff7c76f6SPali Rohár
45ff7c76f6SPali Rohárifdef CONFIG_TARGET_CPU_BOOL
46689d592eSNicholas PigginBOOTTARGETFLAGS	+= -mcpu=$(CONFIG_TARGET_CPU)
47ff7c76f6SPali Rohárelse ifdef CONFIG_PPC64_BOOT_WRAPPER
48ff7c76f6SPali Rohárifdef CONFIG_CPU_LITTLE_ENDIAN
49689d592eSNicholas PigginBOOTTARGETFLAGS	+= -mcpu=powerpc64le
5040a75584SJoel Stanleyelse
51689d592eSNicholas PigginBOOTTARGETFLAGS	+= -mcpu=powerpc64
52ff7c76f6SPali Rohárendif
5365c5ec11SMichael Ellermanendif
5465c5ec11SMichael Ellerman
55689d592eSNicholas Piggin$(obj)/4xx.o: BOOTTARGETFLAGS += -mcpu=405
56689d592eSNicholas Piggin$(obj)/ebony.o: BOOTTARGETFLAGS += -mcpu=440
57689d592eSNicholas Piggin$(obj)/cuboot-taishan.o: BOOTTARGETFLAGS += -mcpu=440
58689d592eSNicholas Piggin$(obj)/cuboot-katmai.o: BOOTTARGETFLAGS += -mcpu=440
59689d592eSNicholas Piggin$(obj)/treeboot-iss4xx.o: BOOTTARGETFLAGS += -mcpu=405
60689d592eSNicholas Piggin$(obj)/treeboot-currituck.o: BOOTTARGETFLAGS += -mcpu=405
61689d592eSNicholas Piggin$(obj)/treeboot-akebono.o: BOOTTARGETFLAGS += -mcpu=405
62689d592eSNicholas Piggin
63147c0516SCédric Le Goaterifdef CONFIG_CPU_BIG_ENDIAN
64689d592eSNicholas PigginBOOTTARGETFLAGS	+= -mbig-endian
65655471f5SBenjamin Herrenschmidtelse
66689d592eSNicholas PigginBOOTTARGETFLAGS	+= -mlittle-endian
67661aa880SChristophe Leroyendif
68147c0516SCédric Le Goater
698bce81dbSNicholas PigginBOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
708bce81dbSNicholas PigginBOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
718bce81dbSNicholas Piggin
72f5df87b8SNicholas PigginBOOTCFLAGS	:= $(BOOTTARGETFLAGS) \
738bce81dbSNicholas Piggin		   -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
748bce81dbSNicholas Piggin		   -fno-strict-aliasing -O2 \
758bce81dbSNicholas Piggin		   -msoft-float -mno-altivec -mno-vsx \
768bce81dbSNicholas Piggin		   $(call cc-option,-mno-prefixed) \
778bce81dbSNicholas Piggin		   $(call cc-option,-mno-pcrel) \
788bce81dbSNicholas Piggin		   $(call cc-option,-mno-mma) \
798bce81dbSNicholas Piggin		   $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
808bce81dbSNicholas Piggin		   -fomit-frame-pointer -fno-builtin -fPIC
818bce81dbSNicholas Piggin
82f5df87b8SNicholas PigginBOOTAFLAGS	:= $(BOOTTARGETFLAGS) -D__ASSEMBLY__
8394b212c2SPaul Mackerras
8413dc8c02SMasahiro YamadaBOOTARFLAGS	:= -crD
85af3901cbSNicholas Piggin
86813af51fSJoel Stanleyifdef CONFIG_CC_IS_CLANG
87813af51fSJoel StanleyBOOTCFLAGS += $(CLANG_FLAGS)
88813af51fSJoel StanleyBOOTAFLAGS += $(CLANG_FLAGS)
89813af51fSJoel Stanleyendif
90813af51fSJoel Stanley
91105c13ddSGrant Likelyifdef CONFIG_DEBUG_INFO
92105c13ddSGrant LikelyBOOTCFLAGS	+= -g
93105c13ddSGrant Likelyendif
94105c13ddSGrant Likely
95fda7ffd2SNiels Kristian Bech Jensenifeq ($(call cc-option-yn, -fstack-protector),y)
96fda7ffd2SNiels Kristian Bech JensenBOOTCFLAGS	+= -fno-stack-protector
97fda7ffd2SNiels Kristian Bech Jensenendif
98fda7ffd2SNiels Kristian Bech Jensen
991619b69eSMichael EllermanBOOTCFLAGS	+= -include $(srctree)/include/linux/compiler_attributes.h
10058ab5e0cSArnd BergmannBOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)
10194b212c2SPaul Mackerras
10263849340SDirk BrandewieDTC_FLAGS	?= -p 1024
1039d4ae9fcSKumar Gala
1041b7898eeSOliver O'Halloran# The pre-boot decompressors pull in a lot of kernel headers and other source
1051b7898eeSOliver O'Halloran# files. This creates a bit of a dependency headache since we need to copy
1061b7898eeSOliver O'Halloran# these files into the build dir, fix up any includes and ensure that dependent
1071b7898eeSOliver O'Halloran# files are copied in the right order.
1081b7898eeSOliver O'Halloran
1090ddbbb89SBjorn Helgaas# these need to be separate variables because they are copied out of different
1100ddbbb89SBjorn Helgaas# directories in the kernel tree. Sure you COULD merge them, but it's a
1111b7898eeSOliver O'Halloran# cure-is-worse-than-disease situation.
1121b7898eeSOliver O'Halloranzlib-decomp-$(CONFIG_KERNEL_GZIP) := decompress_inflate.c
11322750d98SOliver O'Halloranzlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c
11422750d98SOliver O'Halloranzlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h infutil.h
11522750d98SOliver O'Halloranzliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h
1166bbc5476SHugh Blemings
1171b7898eeSOliver O'Halloran$(addprefix $(obj)/, decompress.o): \
1181b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zlib-decomp-y))
1191b7898eeSOliver O'Halloran
1201b7898eeSOliver O'Halloran$(addprefix $(obj)/, $(zlib-decomp-y)): \
1211b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zliblinuxheader-y)) \
1221b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zlibheader-y)) \
1231b7898eeSOliver O'Halloran	$(addprefix $(obj)/,$(zlib-y))
1241b7898eeSOliver O'Halloran
1251b7898eeSOliver O'Halloran$(addprefix $(obj)/,$(zlib-y)): \
12622750d98SOliver O'Halloran	$(addprefix $(obj)/,$(zliblinuxheader-y)) \
12722750d98SOliver O'Halloran	$(addprefix $(obj)/,$(zlibheader-y))
1282bf11819SPaul Mackerras
1299fffb55fSDavid Gibsonlibfdt       := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
1309fffb55fSDavid Gibsonlibfdtheader := fdt.h libfdt.h libfdt_internal.h
1319fffb55fSDavid Gibson
13264c3f648SGuenter Roeck$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \
13364c3f648SGuenter Roeck	treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \
1349fffb55fSDavid Gibson	$(addprefix $(obj)/,$(libfdtheader))
1359fffb55fSDavid Gibson
1367c868b66SNicholas Pigginsrc-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
1379fffb55fSDavid Gibson		$(libfdt) libfdt-wrapper.c \
138ad9d2716SDavid Gibson		ns16550.c serial.c simple_alloc.c div64.S util.S \
1391b7898eeSOliver O'Halloran		elf_util.c $(zlib-y) devtree.c stdlib.c \
140c3bb690dSMichael Ellerman		oflib.c ofconsole.c cuboot.c
141f8e8e69cSMichael Ellerman
142e5eff896SMichael Ellermansrc-wlib-$(CONFIG_PPC_MPC52xx) += mpc52xx-psc.c
1436ffeb56eSCédric Le Goatersrc-wlib-$(CONFIG_PPC_POWERNV) += opal-calls.S opal.c
1447c868b66SNicholas Pigginifndef CONFIG_PPC64_BOOT_WRAPPER
1457c868b66SNicholas Pigginsrc-wlib-y += crtsavres.S
1467c868b66SNicholas Pigginendif
147b81f18e5STony Breedssrc-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
148968159c0SChristophe Leroysrc-wlib-$(CONFIG_PPC_8xx) += mpc8xx.c planetcore.c fsl-soc.c
149b81f18e5STony Breedssrc-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c
150297f8314SMark Greersrc-wlib-$(CONFIG_EMBEDDED6xx) += ugecon.c fsl-soc.c
151c3bb690dSMichael Ellermansrc-wlib-$(CONFIG_CPM) += cpm-serial.c
152b81f18e5STony Breeds
1530c9fa291SBenjamin Herrenschmidtsrc-plat-y := of.c epapr.c
154b81f18e5STony Breedssrc-plat-$(CONFIG_44x) += treeboot-ebony.c cuboot-ebony.c treeboot-bamboo.c \
155b81f18e5STony Breeds				cuboot-bamboo.c cuboot-sam440ep.c \
156b81f18e5STony Breeds				cuboot-sequoia.c cuboot-rainier.c \
157b81f18e5STony Breeds				cuboot-taishan.c cuboot-katmai.c \
158b81f18e5STony Breeds				cuboot-warp.c cuboot-yosemite.c \
159b81f18e5STony Breeds				treeboot-iss4xx.c treeboot-currituck.c \
1602a2c74b2SAlistair Popple				treeboot-akebono.c \
1617ade8495SMichal Simek				simpleboot.c fixed-head.S
162968159c0SChristophe Leroysrc-plat-$(CONFIG_PPC_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c
163b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_MPC52xx) += cuboot-52xx.c
164b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_82xx) += cuboot-pq2.c fixed-head.S ep8248e.c cuboot-824x.c
165b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_83xx) += cuboot-83xx.c fixed-head.S redboot-83xx.c
166b81f18e5STony Breedssrc-plat-$(CONFIG_FSL_SOC_BOOKE) += cuboot-85xx.c cuboot-85xx-cpm2.c
167f03425a5SPaul Gortmakersrc-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c \
16892c8c16fSMark Greer					gamecube-head.S gamecube.c \
16992c8c16fSMark Greer					wii-head.S wii.c holly.c \
1703c8464a9SPaul Gortmaker					fixed-head.S mvme5100.c
171b81f18e5STony Breedssrc-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
172b81f18e5STony Breedssrc-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
1730c9fa291SBenjamin Herrenschmidtsrc-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
1742d9afb36SCédric Le Goatersrc-plat-$(CONFIG_PPC_PSERIES) += pseries-head.S
1752d9afb36SCédric Le Goatersrc-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S
1762d9afb36SCédric Le Goatersrc-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
17797493e2eSAlessio Igor Boganisrc-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c
178b81f18e5STony Breeds
1794a21192eSJoel Stanleysrc-plat-$(CONFIG_PPC_MICROWATT) += fixed-head.S microwatt.c
1804a21192eSJoel Stanley
181b81f18e5STony Breedssrc-wlib := $(sort $(src-wlib-y))
182b81f18e5STony Breedssrc-plat := $(sort $(src-plat-y))
183cd197ffcSDavid Gibsonsrc-boot := $(src-wlib) $(src-plat) empty.c
1842bf11819SPaul Mackerras
1852bf11819SPaul Mackerrassrc-boot := $(addprefix $(obj)/, $(src-boot))
1862bf11819SPaul Mackerrasobj-boot := $(addsuffix .o, $(basename $(src-boot)))
1872bf11819SPaul Mackerrasobj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
1882bf11819SPaul Mackerrasobj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
1890090e02bSMatthew McClintockobj-plat: $(libfdt)
1902bf11819SPaul Mackerras
1911a13de6dSOliver O'Halloranquiet_cmd_copy_kern_src = COPY    $@
1921a13de6dSOliver O'Halloran      cmd_copy_kern_src = sed -f $(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
19394b212c2SPaul Mackerras
19422750d98SOliver O'Halloran$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
1951a13de6dSOliver O'Halloran	$(call cmd,copy_kern_src)
19694b212c2SPaul Mackerras
19722750d98SOliver O'Halloran$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
1981a13de6dSOliver O'Halloran	$(call cmd,copy_kern_src)
19994b212c2SPaul Mackerras
20022750d98SOliver O'Halloran$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
2011a13de6dSOliver O'Halloran	$(call cmd,copy_kern_src)
20294b212c2SPaul Mackerras
2031b7898eeSOliver O'Halloran$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/%
2041b7898eeSOliver O'Halloran	$(call cmd,copy_kern_src)
2051b7898eeSOliver O'Halloran
2069fffb55fSDavid Gibsonquiet_cmd_copy_libfdt = COPY    $@
2079fffb55fSDavid Gibson      cmd_copy_libfdt = cp $< $@
2089fffb55fSDavid Gibson
2099fffb55fSDavid Gibson$(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
2109fffb55fSDavid Gibson	$(call cmd,copy_libfdt)
2119fffb55fSDavid Gibson
2122bf11819SPaul Mackerras$(obj)/empty.c:
2136abe248eSMichael Ellerman	$(Q)touch $@
21494b212c2SPaul Mackerras
215b1992c37SMasahiro Yamada$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(src)/%.S
2166abe248eSMichael Ellerman	$(Q)cp $< $@
2172bf11819SPaul Mackerras
21822750d98SOliver O'Halloranclean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
2191b7898eeSOliver O'Halloran		$(zlib-decomp-) $(libfdt) $(libfdtheader) \
2204ba7f80fSMasahiro Yamada		empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
22194b212c2SPaul Mackerras
22294b212c2SPaul Mackerrasquiet_cmd_bootcc = BOOTCC  $@
223d1b7d40dSNicholas Piggin      cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCPPFLAGS) $(BOOTCFLAGS) -c -o $@ $<
22494b212c2SPaul Mackerras
22594b212c2SPaul Mackerrasquiet_cmd_bootas = BOOTAS  $@
226d1b7d40dSNicholas Piggin      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCPPFLAGS) $(BOOTAFLAGS) -c -o $@ $<
22794b212c2SPaul Mackerras
2282bf11819SPaul Mackerrasquiet_cmd_bootar = BOOTAR  $@
229afa974b7SMasahiro Yamada      cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@
23094b212c2SPaul Mackerras
2319fffb55fSDavid Gibson$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
2329fffb55fSDavid Gibson	$(call if_changed_dep,bootcc)
233235fd835SMilton Miller$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
2342f0dfeaaSDavid Gibson	$(Q)mkdir -p $(dir $@)
23594b212c2SPaul Mackerras	$(call if_changed_dep,bootcc)
236235fd835SMilton Miller$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
2372f0dfeaaSDavid Gibson	$(Q)mkdir -p $(dir $@)
23894b212c2SPaul Mackerras	$(call if_changed_dep,bootas)
23994b212c2SPaul Mackerras
240235fd835SMilton Miller$(obj)/wrapper.a: $(obj-wlib) FORCE
241235fd835SMilton Miller	$(call if_changed,bootar)
24294b212c2SPaul Mackerras
2435f2fb52fSMasahiro Yamadahostprogs	:= addnote hack-coff mktree
24466a45dd3SPaul Mackerras
245710e6822SNicholas Piggintargets		+= $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a) zImage.lds
246cd197ffcSDavid Gibsonextra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
247bafdb645SGeoff Levand		   $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
24894b212c2SPaul Mackerras
249b1992c37SMasahiro Yamadadtstree		:= $(src)/dts
25025431333SGrant Likely
251b1992c37SMasahiro Yamadawrapper		:= $(src)/wrapper
2529fffb55fSDavid Gibsonwrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
253235fd835SMilton Miller			$(wrapper) FORCE
25494b212c2SPaul Mackerras
2552bf11819SPaul Mackerras#############
2562bf11819SPaul Mackerras# Bits for building various flavours of zImage
25794b212c2SPaul Mackerras
2582bf11819SPaul Mackerrasifneq ($(CROSS32_COMPILE),)
259dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS32_COMPILE)"
2602bf11819SPaul Mackerraselse
2612bf11819SPaul Mackerrasifneq ($(CROSS_COMPILE),)
262dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS_COMPILE)"
2632bf11819SPaul Mackerrasendif
2642bf11819SPaul Mackerrasendif
26594b212c2SPaul Mackerras
266f1e510bbSOliver O'Hallorancompressor-$(CONFIG_KERNEL_GZIP) := gz
267c762c69eSOliver O'Hallorancompressor-$(CONFIG_KERNEL_XZ)   := xz
2681cc9a21bSChristophe Leroycompressor-$(CONFIG_KERNEL_LZMA)   := lzma
269264bffadSChristophe Leroycompressor-$(CONFIG_KERNEL_LZO) := lzo
270f1e510bbSOliver O'Halloran
2719da82a6dSMilton Miller# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
2722bf11819SPaul Mackerrasquiet_cmd_wrap	= WRAP    $@
273f1e510bbSOliver O'Halloran      cmd_wrap	=$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
274f1e510bbSOliver O'Halloran		$(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
275f1e510bbSOliver O'Halloran		vmlinux
2762bf11819SPaul Mackerras
2772bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PSERIES)		+= zImage.pseries
27855190f88SBenjamin Herrenschmidtimage-$(CONFIG_PPC_POWERNV)		+= zImage.pseries
279020533efSGeoff Levandimage-$(CONFIG_PPC_IBM_CELL_BLADE)	+= zImage.pseries
280595be948SGrant Likelyimage-$(CONFIG_PPC_PS3)			+= dtbImage.ps3
2812bf11819SPaul Mackerrasimage-$(CONFIG_PPC_CHRP)		+= zImage.chrp
2827839af33SNicolas DETimage-$(CONFIG_PPC_EFIKA)		+= zImage.chrp
2832bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC)		+= zImage.pmac
28432dde0f9SJosh Boyerimage-$(CONFIG_PPC_HOLLY)		+= dtbImage.holly
285ac18c673SScott Woodimage-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
2866c5b59b9SDavid Gibsonimage-$(CONFIG_EPAPR_BOOT)		+= zImage.epapr
287ac18c673SScott Wood
28825431333SGrant Likely#
28925431333SGrant Likely# Targets which embed a device tree blob
29025431333SGrant Likely#
29125431333SGrant Likely# Theses are default targets to build images which embed device tree blobs.
29225431333SGrant Likely# They are only required on boards which do not have FDT support in firmware.
2932a94739cSNick Andrew# Boards with newish u-boot firmware can use the uImage target above
29425431333SGrant Likely#
29525431333SGrant Likely
29625431333SGrant Likely# Board ports in arch/powerpc/platform/44x/Kconfig
297f6dfc805SDavid Gibsonimage-$(CONFIG_EBONY)			+= treeImage.ebony cuImage.ebony
298658e8170SJosh Boyerimage-$(CONFIG_BAMBOO)			+= treeImage.bamboo cuImage.bamboo
299b6014e15SGiuseppe Covielloimage-$(CONFIG_SAM440EP)		+= cuImage.sam440ep
300606d08bcSValentine Barshakimage-$(CONFIG_SEQUOIA)			+= cuImage.sequoia
301295e7427SValentine Barshakimage-$(CONFIG_RAINIER)			+= cuImage.rainier
3026bbc5476SHugh Blemingsimage-$(CONFIG_TAISHAN)			+= cuImage.taishan
3033de9c9cdSBenjamin Herrenschmidtimage-$(CONFIG_KATMAI)			+= cuImage.katmai
3041e12f3c5SSean MacLennanimage-$(CONFIG_WARP)			+= cuImage.warp
305d0a48c9fSJosh Boyerimage-$(CONFIG_YOSEMITE)		+= cuImage.yosemite
306b4e8c8ddSTorez Smithimage-$(CONFIG_ISS4xx)			+= treeImage.iss4xx \
307b4e8c8ddSTorez Smith					   treeImage.iss4xx-mpic
308228d5505STony Breedsimage-$(CONFIG_CURRITUCK)			+= treeImage.currituck
3092a2c74b2SAlistair Poppleimage-$(CONFIG_AKEBONO)			+= treeImage.akebono
31094b212c2SPaul Mackerras
31125431333SGrant Likely# Board ports in arch/powerpc/platform/8xx/Kconfig
312efa58fbfSAdrian Bunkimage-$(CONFIG_MPC86XADS)		+= cuImage.mpc866ads
313efa58fbfSAdrian Bunkimage-$(CONFIG_MPC885ADS)		+= cuImage.mpc885ads
314595be948SGrant Likelyimage-$(CONFIG_PPC_EP88XC)		+= dtbImage.ep88xc
31525431333SGrant Likelyimage-$(CONFIG_PPC_ADDER875)		+= cuImage.adder875-uboot \
316595be948SGrant Likely					   dtbImage.adder875-redboot
31725431333SGrant Likely
31825431333SGrant Likely# Board ports in arch/powerpc/platform/52xx/Kconfig
3191acf1cf8SRob Herringimage-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200
3201acf1cf8SRob Herringimage-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200b
3211acf1cf8SRob Herringimage-$(CONFIG_PPC_MEDIA5200)		+= cuImage.media5200
32225431333SGrant Likely
32325431333SGrant Likely# Board ports in arch/powerpc/platform/82xx/Kconfig
324595be948SGrant Likelyimage-$(CONFIG_EP8248E)			+= dtbImage.ep8248e
32525431333SGrant Likely
32625431333SGrant Likely# Board ports in arch/powerpc/platform/83xx/Kconfig
32725431333SGrant Likelyimage-$(CONFIG_MPC832x_RDB)		+= cuImage.mpc832x_rdb
32825431333SGrant Likelyimage-$(CONFIG_MPC834x_ITX)		+= cuImage.mpc8349emitx \
32925431333SGrant Likely					   cuImage.mpc8349emitxgp
33059d13f9dSBryan O'Donoghueimage-$(CONFIG_ASP834x)			+= dtbImage.asp834x-redboot
33125431333SGrant Likely
33225431333SGrant Likely# Board ports in arch/powerpc/platform/85xx/Kconfig
33325431333SGrant Likelyimage-$(CONFIG_MPC85xx_MDS)		+= cuImage.mpc8568mds
33425431333SGrant Likelyimage-$(CONFIG_MPC85xx_DS)		+= cuImage.mpc8544ds \
33525431333SGrant Likely					   cuImage.mpc8572ds
33625431333SGrant Likelyimage-$(CONFIG_TQM8540)			+= cuImage.tqm8540
33725431333SGrant Likelyimage-$(CONFIG_TQM8541)			+= cuImage.tqm8541
3386dd1b64aSWolfgang Grandeggerimage-$(CONFIG_TQM8548)			+= cuImage.tqm8548
33925431333SGrant Likelyimage-$(CONFIG_TQM8555)			+= cuImage.tqm8555
34025431333SGrant Likelyimage-$(CONFIG_TQM8560)			+= cuImage.tqm8560
341ff880112SAlexandr Smirnovimage-$(CONFIG_KSI8560)			+= cuImage.ksi8560
34225431333SGrant Likely
34397493e2eSAlessio Igor Bogani# Board ports in arch/powerpc/platform/86xx/Kconfig
34497493e2eSAlessio Igor Boganiimage-$(CONFIG_MVME7100)                += dtbImage.mvme7100
34597493e2eSAlessio Igor Bogani
34625431333SGrant Likely# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
34725431333SGrant Likelyimage-$(CONFIG_STORCENTER)		+= cuImage.storcenter
348b68a24bcSAlbert Herranzimage-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
3496cdd2417SAlbert Herranzimage-$(CONFIG_WII)			+= dtbImage.wii
350be201981SStephen Chiversimage-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
351b09c1644SScott Wood
3528f23735dSGerhard Pircher# Board port in arch/powerpc/platform/amigaone/Kconfig
3538f23735dSGerhard Pircherimage-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
3548f23735dSGerhard Pircher
3554a21192eSJoel Stanleyimage-$(CONFIG_PPC_MICROWATT)		+= dtbImage.microwatt
3564a21192eSJoel Stanley
3579216ad8cSPaul Mackerras# For 32-bit powermacs, build the COFF and miboot images
3589216ad8cSPaul Mackerras# as well as the ELF images.
359badf436fSRodrigo R. Galvaoifdef CONFIG_PPC32
3602bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC)	+= zImage.coff zImage.miboot
3612bf11819SPaul Mackerrasendif
36266a45dd3SPaul Mackerras
363c356aa45SGrant Likely# Allow extra targets to be added to the defconfig
364129ab0d2SMasahiro Yamadaimage-y	+= $(CONFIG_EXTRA_TARGETS)
365c356aa45SGrant Likely
366755457f9SMichal Marekinitrd-  := $(patsubst zImage%, zImage.initrd%, $(image-))
367f6dfc805SDavid Gibsoninitrd-y := $(patsubst zImage%, zImage.initrd%, \
368595be948SGrant Likely		$(patsubst dtbImage%, dtbImage.initrd%, \
3695d1a0411SJohn Linn		$(patsubst simpleImage%, simpleImage.initrd%, \
3705d1a0411SJohn Linn		$(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
3719da82a6dSMilton Millerinitrd-y := $(filter-out $(image-y), $(initrd-y))
372235fd835SMilton Millertargets	+= $(image-y) $(initrd-y)
3731bca5440SMasahiro Yamadatargets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \
3741bca5440SMasahiro Yamada		$(patsubst $(x).%, dts/%.dtb, $(filter $(x).%, $(image-y))))
375b36f835bSMichael Ellermantargets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \
376b36f835bSMichael Ellerman		$(patsubst $(x).%, dts/fsl/%.dtb, $(filter $(x).%, $(image-y))))
37794b212c2SPaul Mackerras
3789da82a6dSMilton Miller$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
3799da82a6dSMilton Miller
3809da82a6dSMilton Miller# Don't put the ramdisk on the pattern rule; when its missing make will try
3819da82a6dSMilton Miller# the pattern rule with less dependencies that also matches (even with the
3829da82a6dSMilton Miller# hard dependency listed).
38342d0c932SMichael Ellerman$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) FORCE
38425431333SGrant Likely	$(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
3859da82a6dSMilton Miller
38642d0c932SMichael Ellerman$(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperbits) FORCE
387699c659bSMichal Marek	$(call if_changed,wrap,$(subst $(obj)/zImage.,,$@))
38825431333SGrant Likely
389595be948SGrant Likely# dtbImage% - a dtbImage is a zImage with an embedded device tree blob
3901acf1cf8SRob Herring$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
3911acf1cf8SRob Herring	$(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
39225431333SGrant Likely
3931acf1cf8SRob Herring$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
3941acf1cf8SRob Herring	$(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb)
3959da82a6dSMilton Miller
3964bb09281STony Breeds# This cannot be in the root of $(src) as the zImage rule always adds a $(obj)
3974bb09281STony Breeds# prefix
3984bb09281STony Breeds$(obj)/vmlinux.strip: vmlinux
3994bb09281STony Breeds	$(STRIP) -s -R .comment $< -o $@
4004bb09281STony Breeds
40142d0c932SMichael Ellerman$(obj)/uImage: vmlinux $(wrapperbits) FORCE
4029da82a6dSMilton Miller	$(call if_changed,wrap,uboot)
4039da82a6dSMilton Miller
4041acf1cf8SRob Herring$(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4051acf1cf8SRob Herring	$(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
40611eab297SBenjamin Herrenschmidt
4071acf1cf8SRob Herring$(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4081acf1cf8SRob Herring	$(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb)
40911eab297SBenjamin Herrenschmidt
4101acf1cf8SRob Herring$(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4111acf1cf8SRob Herring	$(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
412a4292d7aSGrant Likely
4131acf1cf8SRob Herring$(obj)/cuImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4141acf1cf8SRob Herring	$(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb)
4150fdd717eSScott Wood
4161acf1cf8SRob Herring$(obj)/simpleImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4171acf1cf8SRob Herring	$(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
418d2477b5cSGrant Likely
4191acf1cf8SRob Herring$(obj)/simpleImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4201acf1cf8SRob Herring	$(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb)
421d2477b5cSGrant Likely
4221acf1cf8SRob Herring$(obj)/treeImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4231acf1cf8SRob Herring	$(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
424f6dfc805SDavid Gibson
4251acf1cf8SRob Herring$(obj)/treeImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
4261acf1cf8SRob Herring	$(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb)
427e04018e8SGrant Likely
4281acf1cf8SRob Herring# Needed for the above targets to work with dts/fsl/ files
4291acf1cf8SRob Herring$(obj)/dts/%.dtb: $(obj)/dts/fsl/%.dtb
4301acf1cf8SRob Herring	@cp $< $@
4314680c9d5SAlessio Igor Bogani
4324bb09281STony Breeds# If there isn't a platform selected then just strip the vmlinux.
4334bb09281STony Breedsifeq (,$(image-y))
4344bb09281STony Breedsimage-y := vmlinux.strip
4354bb09281STony Breedsendif
4364bb09281STony Breeds
4372bf11819SPaul Mackerras$(obj)/zImage:		$(addprefix $(obj)/, $(image-y))
4386abe248eSMichael Ellerman	$(Q)rm -f $@; ln $< $@
4392bf11819SPaul Mackerras$(obj)/zImage.initrd:	$(addprefix $(obj)/, $(initrd-y))
4406abe248eSMichael Ellerman	$(Q)rm -f $@; ln $< $@
44194b212c2SPaul Mackerras
4421383a34fSMilton Miller# anything not in $(targets)
443b58a4575SKumar Galaclean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \
444b58a4575SKumar Gala	zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \
4451b041885SStephen Rothwell	zImage.miboot zImage.pmac zImage.pseries \
446*62f8f307SMichael Ellerman	simpleImage.* otheros.bld
4471383a34fSMilton Miller
4481383a34fSMilton Miller# clean up files cached by wrapper
4491b7898eeSOliver O'Halloranclean-kernel-base := vmlinux.strip vmlinux.bin
4501b7898eeSOliver O'Halloranclean-kernel := $(addsuffix .gz,$(clean-kernel-base))
451c762c69eSOliver O'Halloranclean-kernel += $(addsuffix .xz,$(clean-kernel-base))
4528d613a1dSMasahiro Yamada# clean-files are relative to $(obj).
4538d613a1dSMasahiro Yamadaclean-files += $(addprefix ../../../, $(clean-kernel))
454773f76b1SDavid Woodhouse
455773f76b1SDavid WoodhouseWRAPPER_OBJDIR := /usr/lib/kernel-wrapper
456773f76b1SDavid WoodhouseWRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts
457773f76b1SDavid WoodhouseWRAPPER_BINDIR := /usr/sbin
458773f76b1SDavid WoodhouseINSTALL := install
459773f76b1SDavid Woodhouse
460773f76b1SDavid Woodhouseextra-installed		:= $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y))
4615f2fb52fSMasahiro Yamadahostprogs-installed	:= $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs))
462773f76b1SDavid Woodhousewrapper-installed	:= $(DESTDIR)$(WRAPPER_BINDIR)/wrapper
4634d9ef89dSBen Hutchingsdts-installed		:= $(patsubst $(dtstree)/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(dtstree)/*.dts))
464773f76b1SDavid Woodhouse
465773f76b1SDavid Woodhouseall-installed		:= $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed)
466773f76b1SDavid Woodhouse
467773f76b1SDavid Woodhousequiet_cmd_mkdir           = MKDIR   $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
468773f76b1SDavid Woodhouse      cmd_mkdir           = mkdir -p $@
469773f76b1SDavid Woodhouse
470773f76b1SDavid Woodhousequiet_cmd_install	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@)
471773f76b1SDavid Woodhouse      cmd_install	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@
472773f76b1SDavid Woodhouse
473773f76b1SDavid Woodhousequiet_cmd_install_dts	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@)
474773f76b1SDavid Woodhouse      cmd_install_dts	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@
475773f76b1SDavid Woodhouse
476773f76b1SDavid Woodhousequiet_cmd_install_exe	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
477773f76b1SDavid Woodhouse      cmd_install_exe	  = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@
478773f76b1SDavid Woodhouse
479773f76b1SDavid Woodhousequiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
480773f76b1SDavid Woodhouse      cmd_install_wrapper = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\
481773f76b1SDavid Woodhouse				sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \
482773f76b1SDavid Woodhouse					  -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \
483773f76b1SDavid Woodhouse
484773f76b1SDavid Woodhouse
485773f76b1SDavid Woodhouse$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR):
486773f76b1SDavid Woodhouse	$(call cmd,mkdir)
487773f76b1SDavid Woodhouse
488773f76b1SDavid Woodhouse$(extra-installed)	: $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR)
489773f76b1SDavid Woodhouse	$(call cmd,install)
490773f76b1SDavid Woodhouse
491773f76b1SDavid Woodhouse$(hostprogs-installed)  : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR)
492773f76b1SDavid Woodhouse	$(call cmd,install_exe)
493773f76b1SDavid Woodhouse
494773f76b1SDavid Woodhouse$(dts-installed)	: $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR)
495773f76b1SDavid Woodhouse	$(call cmd,install_dts)
496773f76b1SDavid Woodhouse
497773f76b1SDavid Woodhouse$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR)
498773f76b1SDavid Woodhouse	$(call cmd,install_wrapper)
499773f76b1SDavid Woodhouse
500773f76b1SDavid Woodhouse$(obj)/bootwrapper_install: $(all-installed)
501