blob: bca5c23767df7327dae75ed6d2baaf573a3351b2 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002# 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
David Gibsonb610b972007-05-29 15:37:12 +100015# 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070017# 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
Paul Mackerras2bf11812006-09-27 22:47:03 +100021all: $(obj)/zImage
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Oliver O'Halloran22750d92016-09-22 16:54:30 +100023compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
Oliver O'Halloranc762c692016-09-22 16:54:34 +100024compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ
Oliver O'Halloran22750d92016-09-22 16:54:30 +100025
Nicholas Pigginaf3901c2018-05-30 22:19:20 +100026ifdef CROSS32_COMPILE
27 BOOTCC := $(CROSS32_COMPILE)gcc
28 BOOTAR := $(CROSS32_COMPILE)ar
29else
30 BOOTCC := $(CC)
31 BOOTAR := $(AR)
32endif
33
David Gibsonb610b972007-05-29 15:37:12 +100034BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
Benjamin Herrenschmidt6846ee52010-01-13 16:19:34 +110035 -fno-strict-aliasing -Os -msoft-float -pipe \
David Gibsonb610b972007-05-29 15:37:12 +100036 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
Oliver O'Halloran22750d92016-09-22 16:54:30 +100037 -D$(compress-y)
38
Cédric Le Goater147c0512014-04-24 09:23:39 +020039ifdef CONFIG_PPC64_BOOT_WRAPPER
40BOOTCFLAGS += -m64
Michael Ellerman65c5ec12017-07-26 23:19:04 +100041else
42BOOTCFLAGS += -m32
Michael Ellerman65c5ec12017-07-26 23:19:04 +100043endif
44
45BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include)
46
Cédric Le Goater147c0512014-04-24 09:23:39 +020047ifdef CONFIG_CPU_BIG_ENDIAN
48BOOTCFLAGS += -mbig-endian
Benjamin Herrenschmidt655471f2015-09-15 11:24:17 +100049else
50BOOTCFLAGS += -mlittle-endian
51BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
Cédric Le Goater147c0512014-04-24 09:23:39 +020052endif
53
Olaf Heringdecd3002005-08-08 13:24:38 +100054BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Nicholas Pigginaf3901c2018-05-30 22:19:20 +100056BOOTARFLAGS := -cr$(KBUILD_ARFLAGS)
57
Grant Likely105c13d2007-10-04 14:05:01 +100058ifdef CONFIG_DEBUG_INFO
59BOOTCFLAGS += -g
60endif
61
Niels Kristian Bech Jensenfda7ffd2006-07-02 13:02:27 +020062ifeq ($(call cc-option-yn, -fstack-protector),y)
63BOOTCFLAGS += -fno-stack-protector
64endif
65
Arnd Bergmann58ab5e02016-06-15 17:45:46 +020066BOOTCFLAGS += -I$(objtree)/$(obj) -I$(srctree)/$(obj)
Olaf Hering70540362005-10-28 17:46:38 -070067
Dirk Brandewie63849342010-12-22 11:57:28 -080068DTC_FLAGS ?= -p 1024
Kumar Gala9d4ae9f2008-06-26 18:58:11 +100069
Josh Boyerbf2e70a2008-02-19 13:52:48 +110070$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
71$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
Solomon Peachy0cdf50a2009-08-20 10:19:47 +000072$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
Josh Boyerbf2e70a2008-02-19 13:52:48 +110073$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
74$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
Josh Boyer9f3eefc2008-11-25 06:33:35 +000075$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
Josh Boyer2e71cc02007-09-24 07:32:15 -050076$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
Torez Smithb4e8c8d2010-03-05 10:45:54 +000077$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
Tony Breeds228d5502011-11-30 21:39:24 +000078$(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
Alistair Popple2a2c74b2014-03-06 14:52:27 +110079$(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
Grant Likelyb9e4f172008-04-25 03:33:44 +100080$(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
Josh Boyer60e41752007-05-17 04:51:37 +100081
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +100082# 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
Oliver O'Halloran22750d92016-09-22 16:54:30 +100091zlib-$(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
Hugh Blemings6bbc5472007-12-21 15:39:28 +110094
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +100095$(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)): \
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000104 $(addprefix $(obj)/,$(zliblinuxheader-y)) \
105 $(addprefix $(obj)/,$(zlibheader-y))
Paul Mackerras2bf11812006-09-27 22:47:03 +1000106
David Gibson9fffb552009-04-30 15:25:53 +1000107libfdt := 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
Guenter Roeck64c3f642018-02-23 12:55:59 -0800110$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \
111 treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \
David Gibson9fffb552009-04-30 15:25:53 +1000112 $(addprefix $(obj)/,$(libfdtheader))
113
Nicholas Piggin7c868b62017-05-12 01:56:50 +1000114src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
David Gibson9fffb552009-04-30 15:25:53 +1000115 $(libfdt) libfdt-wrapper.c \
David Gibsonad9d2712007-03-05 14:24:52 +1100116 ns16550.c serial.c simple_alloc.c div64.S util.S \
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000117 elf_util.c $(zlib-y) devtree.c stdlib.c \
Michael Ellermanc3bb6902017-11-08 22:05:29 +1100118 oflib.c ofconsole.c cuboot.c
Michael Ellermanf8e8e692017-11-08 22:05:28 +1100119
Hannes Reinecke866bfc72017-06-27 16:29:51 +0200120src-wlib-$(CONFIG_PPC_MPC52XX) += mpc52xx-psc.c
Michael Ellermanf8e8e692017-11-08 22:05:28 +1100121src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S opal.c
Nicholas Piggin7c868b62017-05-12 01:56:50 +1000122ifndef CONFIG_PPC64_BOOT_WRAPPER
123src-wlib-y += crtsavres.S
124endif
Tony Breedsb81f18e2012-04-03 15:00:39 +0000125src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
126src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
Christophe Leroy968159c2017-08-08 13:58:54 +0200127src-wlib-$(CONFIG_PPC_8xx) += mpc8xx.c planetcore.c fsl-soc.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000128src-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c
Mark Greer297f8312018-04-05 18:17:19 -0700129src-wlib-$(CONFIG_EMBEDDED6xx) += ugecon.c fsl-soc.c
Michael Ellerman3d6bf692017-11-08 22:05:27 +1100130src-wlib-$(CONFIG_XILINX_VIRTEX) += uartlite.c
Michael Ellermanc3bb6902017-11-08 22:05:29 +1100131src-wlib-$(CONFIG_CPM) += cpm-serial.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000132
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000133src-plat-y := of.c epapr.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000134src-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 \
Alistair Popple2a2c74b2014-03-06 14:52:27 +1100144 treeboot-akebono.c \
Tony Breedsb81f18e2012-04-03 15:00:39 +0000145 simpleboot.c fixed-head.S virtex.c
Christophe Leroy968159c2017-08-08 13:58:54 +0200146src-plat-$(CONFIG_PPC_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000147src-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 \
Mark Greer92c8c162018-04-05 18:17:16 -0700152 gamecube-head.S gamecube.c \
153 wii-head.S wii.c holly.c \
Paul Gortmaker3c8464a2014-02-05 20:35:13 -0500154 fixed-head.S mvme5100.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000155src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
156src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000157src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
Cédric Le Goater2d9afb32014-04-24 09:23:38 +0200158src-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
Alessio Igor Bogani97493e2e2016-05-30 11:47:16 +0200161src-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000162
163src-wlib := $(sort $(src-wlib-y))
164src-plat := $(sort $(src-plat-y))
David Gibsoncd197ff2007-03-05 14:24:52 +1100165src-boot := $(src-wlib) $(src-plat) empty.c
Paul Mackerras2bf11812006-09-27 22:47:03 +1000166
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))))
Matthew McClintock0090e022012-09-06 08:48:54 +0000171obj-plat: $(libfdt)
Paul Mackerras2bf11812006-09-27 22:47:03 +1000172
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000173quiet_cmd_copy_kern_src = COPY $@
174 cmd_copy_kern_src = sed -f $(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
Olaf Hering70540362005-10-28 17:46:38 -0700175
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000176$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000177 $(call cmd,copy_kern_src)
Olaf Hering70540362005-10-28 17:46:38 -0700178
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000179$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000180 $(call cmd,copy_kern_src)
Olaf Hering70540362005-10-28 17:46:38 -0700181
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000182$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000183 $(call cmd,copy_kern_src)
Olaf Hering70540362005-10-28 17:46:38 -0700184
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000185$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/%
186 $(call cmd,copy_kern_src)
187
David Gibson9fffb552009-04-30 15:25:53 +1000188quiet_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
Paul Mackerras2bf11812006-09-27 22:47:03 +1000194$(obj)/empty.c:
Michael Ellerman6abe2482016-08-11 16:03:13 +1000195 $(Q)touch $@
Olaf Hering70540362005-10-28 17:46:38 -0700196
Cédric Le Goater147c0512014-04-24 09:23:39 +0200197$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
Michael Ellerman6abe2482016-08-11 16:03:13 +1000198 $(Q)cp $< $@
Paul Mackerras2bf11812006-09-27 22:47:03 +1000199
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000200clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000201 $(zlib-decomp-) $(libfdt) $(libfdtheader) \
Kumar Galab58a4572008-05-18 13:23:03 -0500202 empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
Olaf Hering70540362005-10-28 17:46:38 -0700203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204quiet_cmd_bootcc = BOOTCC $@
Michael Ellerman65c5ec12017-07-26 23:19:04 +1000205 cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207quiet_cmd_bootas = BOOTAS $@
Michael Ellerman65c5ec12017-07-26 23:19:04 +1000208 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Paul Mackerras2bf11812006-09-27 22:47:03 +1000210quiet_cmd_bootar = BOOTAR $@
Nicholas Pigginaf3901c2018-05-30 22:19:20 +1000211 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
Geoff Levanda24c8482005-08-15 13:59:13 -0700212
David Gibson9fffb552009-04-30 15:25:53 +1000213$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
214 $(call if_changed_dep,bootcc)
Milton Miller235fd832007-03-21 09:02:37 -0600215$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
David Gibson2f0dfea2007-12-10 14:28:39 +1100216 $(Q)mkdir -p $(dir $@)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 $(call if_changed_dep,bootcc)
Milton Miller235fd832007-03-21 09:02:37 -0600218$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
David Gibson2f0dfea2007-12-10 14:28:39 +1100219 $(Q)mkdir -p $(dir $@)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 $(call if_changed_dep,bootas)
221
Milton Miller235fd832007-03-21 09:02:37 -0600222$(obj)/wrapper.a: $(obj-wlib) FORCE
223 $(call if_changed,bootar)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Paul Mackerras97bb63e2010-06-07 14:27:10 +0000225hostprogs-y := addnote hack-coff mktree
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Milton Miller235fd832007-03-21 09:02:37 -0600227targets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
David Gibsoncd197ff2007-03-05 14:24:52 +1100228extra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
Geoff Levandbafdb642007-07-04 09:07:18 +1000229 $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
Paul Mackerras66a45dd2006-01-14 15:04:06 +1100230
Grant Likely25431332008-02-07 05:18:34 +1100231dtstree := $(srctree)/$(src)/dts
232
Paul Mackerras2bf11812006-09-27 22:47:03 +1000233wrapper :=$(srctree)/$(src)/wrapper
David Gibson9fffb552009-04-30 15:25:53 +1000234wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
Milton Miller235fd832007-03-21 09:02:37 -0600235 $(wrapper) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
Paul Mackerras2bf11812006-09-27 22:47:03 +1000237#############
238# Bits for building various flavours of zImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Paul Mackerras2bf11812006-09-27 22:47:03 +1000240ifneq ($(CROSS32_COMPILE),)
Michael Ellermandcf90652006-09-30 11:54:09 +1000241CROSSWRAP := -C "$(CROSS32_COMPILE)"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000242else
243ifneq ($(CROSS_COMPILE),)
Michael Ellermandcf90652006-09-30 11:54:09 +1000244CROSSWRAP := -C "$(CROSS_COMPILE)"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000245endif
246endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000248compressor-$(CONFIG_KERNEL_GZIP) := gz
Oliver O'Halloranc762c692016-09-22 16:54:34 +1000249compressor-$(CONFIG_KERNEL_XZ) := xz
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000250
Milton Miller9da82a62007-03-21 09:03:23 -0600251# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
Paul Mackerras2bf11812006-09-27 22:47:03 +1000252quiet_cmd_wrap = WRAP $@
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000253 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
Paul Mackerras2bf11812006-09-27 22:47:03 +1000256
Geoff Levand020533e2006-10-07 15:33:53 -0700257image-$(CONFIG_PPC_PSERIES) += zImage.pseries
Benjamin Herrenschmidt55190f82011-09-19 17:44:52 +0000258image-$(CONFIG_PPC_POWERNV) += zImage.pseries
Corey Minyard58706ef2010-01-29 14:18:20 +0000259image-$(CONFIG_PPC_MAPLE) += zImage.maple
Geoff Levand020533e2006-10-07 15:33:53 -0700260image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
Grant Likely595be942008-02-22 05:57:07 +1100261image-$(CONFIG_PPC_PS3) += dtbImage.ps3
Geoff Levand020533e2006-10-07 15:33:53 -0700262image-$(CONFIG_PPC_CHRP) += zImage.chrp
Nicolas DET7839af32006-11-17 17:08:37 +0100263image-$(CONFIG_PPC_EFIKA) += zImage.chrp
Geoff Levand020533e2006-10-07 15:33:53 -0700264image-$(CONFIG_PPC_PMAC) += zImage.pmac
Josh Boyer32dde0f2008-09-09 04:00:28 +0000265image-$(CONFIG_PPC_HOLLY) += dtbImage.holly
Scott Woodac18c672007-05-03 04:00:00 +1000266image-$(CONFIG_DEFAULT_UIMAGE) += uImage
David Gibson6c5b59b2011-04-14 18:29:16 +0000267image-$(CONFIG_EPAPR_BOOT) += zImage.epapr
Scott Woodac18c672007-05-03 04:00:00 +1000268
Grant Likely25431332008-02-07 05:18:34 +1100269#
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.
Nick Andrew2a947392009-01-03 18:59:37 +1100274# Boards with newish u-boot firmware can use the uImage target above
Grant Likely25431332008-02-07 05:18:34 +1100275#
276
277# Board ports in arch/powerpc/platform/40x/Kconfig
Grant Likely595be942008-02-22 05:57:07 +1100278image-$(CONFIG_EP405) += dtbImage.ep405
Solomon Peachy0cdf50a2009-08-20 10:19:47 +0000279image-$(CONFIG_HOTFOOT) += cuImage.hotfoot
Grant Likely25431332008-02-07 05:18:34 +1100280image-$(CONFIG_WALNUT) += treeImage.walnut
Josh Boyer94c73a82008-09-03 21:01:39 -0400281image-$(CONFIG_ACADIA) += cuImage.acadia
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000282image-$(CONFIG_OBS600) += uImage.obs600
Grant Likely25431332008-02-07 05:18:34 +1100283
284# Board ports in arch/powerpc/platform/44x/Kconfig
David Gibsonf6dfc802007-05-08 14:10:01 +1000285image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
Josh Boyer658e8172007-09-15 04:54:11 +1000286image-$(CONFIG_BAMBOO) += treeImage.bamboo cuImage.bamboo
Giuseppe Coviellob6014e12008-05-20 01:20:47 +1000287image-$(CONFIG_SAM440EP) += cuImage.sam440ep
Valentine Barshak606d08b2007-08-29 17:38:30 +0400288image-$(CONFIG_SEQUOIA) += cuImage.sequoia
Valentine Barshak295e7422007-10-31 03:56:06 +1100289image-$(CONFIG_RAINIER) += cuImage.rainier
Hugh Blemings6bbc5472007-12-21 15:39:28 +1100290image-$(CONFIG_TAISHAN) += cuImage.taishan
Benjamin Herrenschmidt3de9c9c2007-12-21 15:39:34 +1100291image-$(CONFIG_KATMAI) += cuImage.katmai
Sean MacLennan1e12f3c2008-01-11 17:17:51 +1100292image-$(CONFIG_WARP) += cuImage.warp
Josh Boyerd0a48c92008-03-06 21:15:52 -0600293image-$(CONFIG_YOSEMITE) += cuImage.yosemite
Torez Smithb4e8c8d2010-03-05 10:45:54 +0000294image-$(CONFIG_ISS4xx) += treeImage.iss4xx \
295 treeImage.iss4xx-mpic
Tony Breeds228d5502011-11-30 21:39:24 +0000296image-$(CONFIG_CURRITUCK) += treeImage.currituck
Alistair Popple2a2c74b2014-03-06 14:52:27 +1100297image-$(CONFIG_AKEBONO) += treeImage.akebono
Geoff Levanda24c8482005-08-15 13:59:13 -0700298
Grant Likely25431332008-02-07 05:18:34 +1100299# Board ports in arch/powerpc/platform/8xx/Kconfig
Adrian Bunkefa58fb2008-05-22 03:38:28 +1000300image-$(CONFIG_MPC86XADS) += cuImage.mpc866ads
301image-$(CONFIG_MPC885ADS) += cuImage.mpc885ads
Grant Likely595be942008-02-22 05:57:07 +1100302image-$(CONFIG_PPC_EP88XC) += dtbImage.ep88xc
Grant Likely25431332008-02-07 05:18:34 +1100303image-$(CONFIG_PPC_ADDER875) += cuImage.adder875-uboot \
Grant Likely595be942008-02-22 05:57:07 +1100304 dtbImage.adder875-redboot
Grant Likely25431332008-02-07 05:18:34 +1100305
306# Board ports in arch/powerpc/platform/52xx/Kconfig
Rob Herring1acf1cf2015-10-13 13:24:16 -0500307image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200
308image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b
309image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200
Grant Likely25431332008-02-07 05:18:34 +1100310
311# Board ports in arch/powerpc/platform/82xx/Kconfig
312image-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads
313image-$(CONFIG_PQ2FADS) += cuImage.pq2fads
Grant Likely595be942008-02-22 05:57:07 +1100314image-$(CONFIG_EP8248E) += dtbImage.ep8248e
Grant Likely25431332008-02-07 05:18:34 +1100315
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
Bryan O'Donoghue59d13f92008-05-08 13:47:00 +0100323image-$(CONFIG_ASP834x) += dtbImage.asp834x-redboot
Grant Likely25431332008-02-07 05:18:34 +1100324
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 \
Zhao Chenhui0d4fdd322012-03-06 17:06:44 +0800329 cuImage.mpc8548cds_32b \
Grant Likely25431332008-02-07 05:18:34 +1100330 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
Wolfgang Grandegger6dd1b642008-06-06 13:50:04 +0200336image-$(CONFIG_TQM8548) += cuImage.tqm8548
Grant Likely25431332008-02-07 05:18:34 +1100337image-$(CONFIG_TQM8555) += cuImage.tqm8555
338image-$(CONFIG_TQM8560) += cuImage.tqm8560
Paul Gortmakera72a6f52008-03-18 16:13:10 +1100339image-$(CONFIG_SBC8548) += cuImage.sbc8548
Alexandr Smirnovff880112008-03-04 19:34:26 +0300340image-$(CONFIG_KSI8560) += cuImage.ksi8560
Grant Likely25431332008-02-07 05:18:34 +1100341
Alessio Igor Bogani97493e2e2016-05-30 11:47:16 +0200342# Board ports in arch/powerpc/platform/86xx/Kconfig
343image-$(CONFIG_MVME7100) += dtbImage.mvme7100
344
Grant Likely25431332008-02-07 05:18:34 +1100345# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
346image-$(CONFIG_STORCENTER) += cuImage.storcenter
347image-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2
Albert Herranzb68a24b2009-12-12 06:31:36 +0000348image-$(CONFIG_GAMECUBE) += dtbImage.gamecube
Albert Herranz6cdd24172009-12-12 06:31:45 +0000349image-$(CONFIG_WII) += dtbImage.wii
Stephen Chiversbe201982014-01-09 13:01:22 +1100350image-$(CONFIG_MVME5100) += dtbImage.mvme5100
Scott Woodb09c1642008-01-17 16:31:40 -0600351
Gerhard Pircher8f237352009-02-10 12:26:11 +0000352# Board port in arch/powerpc/platform/amigaone/Kconfig
353image-$(CONFIG_AMIGAONE) += cuImage.amigaone
354
Paul Mackerras9216ad82006-01-15 13:00:08 +1100355# For 32-bit powermacs, build the COFF and miboot images
356# as well as the ELF images.
Rodrigo R. Galvaobadf4362018-08-06 13:42:03 -0300357ifdef CONFIG_PPC32
Paul Mackerras2bf11812006-09-27 22:47:03 +1000358image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot
359endif
Paul Mackerras66a45dd2006-01-14 15:04:06 +1100360
Grant Likelyc356aa42008-07-09 09:41:52 -0600361# Allow extra targets to be added to the defconfig
362image-y += $(subst ",,$(CONFIG_EXTRA_TARGETS))
363
Michal Marek755457f2014-10-02 15:49:15 +0200364initrd- := $(patsubst zImage%, zImage.initrd%, $(image-))
David Gibsonf6dfc802007-05-08 14:10:01 +1000365initrd-y := $(patsubst zImage%, zImage.initrd%, \
Grant Likely595be942008-02-22 05:57:07 +1100366 $(patsubst dtbImage%, dtbImage.initrd%, \
John Linn5d1a0412008-07-01 14:17:18 -0600367 $(patsubst simpleImage%, simpleImage.initrd%, \
368 $(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
Milton Miller9da82a62007-03-21 09:03:23 -0600369initrd-y := $(filter-out $(image-y), $(initrd-y))
Milton Miller235fd832007-03-21 09:02:37 -0600370targets += $(image-y) $(initrd-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
Milton Miller9da82a62007-03-21 09:03:23 -0600372$(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).
Michael Ellerman42d0c932016-11-21 21:14:34 +1100377$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) FORCE
Grant Likely25431332008-02-07 05:18:34 +1100378 $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
Milton Miller9da82a62007-03-21 09:03:23 -0600379
Michael Ellerman42d0c932016-11-21 21:14:34 +1100380$(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperbits) FORCE
Michal Marek699c6592014-06-11 13:53:48 +0200381 $(call if_changed,wrap,$(subst $(obj)/zImage.,,$@))
Grant Likely25431332008-02-07 05:18:34 +1100382
Grant Likely595be942008-02-22 05:57:07 +1100383# dtbImage% - a dtbImage is a zImage with an embedded device tree blob
Rob Herring1acf1cf2015-10-13 13:24:16 -0500384$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
385 $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
Grant Likely25431332008-02-07 05:18:34 +1100386
Rob Herring1acf1cf2015-10-13 13:24:16 -0500387$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
388 $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb)
Milton Miller9da82a62007-03-21 09:03:23 -0600389
Tony Breeds4bb09282007-07-04 14:04:31 +1000390# 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
Michael Ellerman42d0c932016-11-21 21:14:34 +1100395$(obj)/uImage: vmlinux $(wrapperbits) FORCE
Milton Miller9da82a62007-03-21 09:03:23 -0600396 $(call if_changed,wrap,uboot)
397
Rob Herring1acf1cf2015-10-13 13:24:16 -0500398$(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
399 $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000400
Rob Herring1acf1cf2015-10-13 13:24:16 -0500401$(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
402 $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb)
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000403
Rob Herring1acf1cf2015-10-13 13:24:16 -0500404$(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
405 $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
Grant Likelya4292d7a2008-10-17 19:12:07 +0000406
Rob Herring1acf1cf2015-10-13 13:24:16 -0500407$(obj)/cuImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
408 $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb)
Scott Wood0fdd7172007-04-17 09:25:50 +1000409
Rob Herring1acf1cf2015-10-13 13:24:16 -0500410$(obj)/simpleImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
411 $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
Grant Likelyd2477b52008-03-19 04:07:43 +1100412
Rob Herring1acf1cf2015-10-13 13:24:16 -0500413$(obj)/simpleImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
414 $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb)
Grant Likelyd2477b52008-03-19 04:07:43 +1100415
Rob Herring1acf1cf2015-10-13 13:24:16 -0500416$(obj)/treeImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
417 $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz)
David Gibsonf6dfc802007-05-08 14:10:01 +1000418
Rob Herring1acf1cf2015-10-13 13:24:16 -0500419$(obj)/treeImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE
420 $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb)
Grant Likelye04018e2008-03-25 09:52:46 +1100421
Rob Herring1acf1cf2015-10-13 13:24:16 -0500422# Needed for the above targets to work with dts/fsl/ files
423$(obj)/dts/%.dtb: $(obj)/dts/fsl/%.dtb
424 @cp $< $@
Alessio Igor Bogani4680c9d2016-04-18 08:36:19 +0200425
Tony Breeds4bb09282007-07-04 14:04:31 +1000426# If there isn't a platform selected then just strip the vmlinux.
427ifeq (,$(image-y))
428image-y := vmlinux.strip
429endif
430
Paul Mackerras2bf11812006-09-27 22:47:03 +1000431$(obj)/zImage: $(addprefix $(obj)/, $(image-y))
Michael Ellerman6abe2482016-08-11 16:03:13 +1000432 $(Q)rm -f $@; ln $< $@
Paul Mackerras2bf11812006-09-27 22:47:03 +1000433$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))
Michael Ellerman6abe2482016-08-11 16:03:13 +1000434 $(Q)rm -f $@; ln $< $@
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Tony Breedsc913e5f2014-08-14 17:05:04 +1000436# Only install the vmlinux
Akinobu Mita928370c2007-04-10 21:05:31 +1000437install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
Tony Breedsc913e5f2014-08-14 17:05:04 +1000438 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
439
440# Install the vmlinux and other built boot targets.
441zInstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
Grant Likely29f1aff2008-12-19 14:57:20 +0000442 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
Paul Mackerras66a45dd2006-01-14 15:04:06 +1100443
Milton Miller1383a342007-03-28 02:21:04 -0600444# anything not in $(targets)
Kumar Galab58a4572008-05-18 13:23:03 -0500445clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \
446 zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \
Stephen Rothwell1b041882012-03-15 18:20:13 +0000447 zImage.miboot zImage.pmac zImage.pseries \
Masahiro Yamada74ce1892017-11-02 11:51:25 +0900448 zImage.maple simpleImage.* otheros.bld
Milton Miller1383a342007-03-28 02:21:04 -0600449
450# clean up files cached by wrapper
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000451clean-kernel-base := vmlinux.strip vmlinux.bin
452clean-kernel := $(addsuffix .gz,$(clean-kernel-base))
Oliver O'Halloranc762c692016-09-22 16:54:34 +1000453clean-kernel += $(addsuffix .xz,$(clean-kernel-base))
Milton Miller1383a342007-03-28 02:21:04 -0600454# If not absolute clean-files are relative to $(obj).
455clean-files += $(addprefix $(objtree)/, $(clean-kernel))
David Woodhouse773f76b2007-12-03 13:56:58 +1100456
457WRAPPER_OBJDIR := /usr/lib/kernel-wrapper
458WRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts
459WRAPPER_BINDIR := /usr/sbin
460INSTALL := install
461
462extra-installed := $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y))
463hostprogs-installed := $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs-y))
464wrapper-installed := $(DESTDIR)$(WRAPPER_BINDIR)/wrapper
Ben Hutchings4d9ef892011-01-08 14:24:01 +0000465dts-installed := $(patsubst $(dtstree)/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(dtstree)/*.dts))
David Woodhouse773f76b2007-12-03 13:56:58 +1100466
467all-installed := $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed)
468
469quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
470 cmd_mkdir = mkdir -p $@
471
472quiet_cmd_install = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@)
473 cmd_install = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@
474
475quiet_cmd_install_dts = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@)
476 cmd_install_dts = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@
477
478quiet_cmd_install_exe = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
479 cmd_install_exe = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@
480
481quiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
482 cmd_install_wrapper = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\
483 sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \
484 -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \
485
486
487$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR):
488 $(call cmd,mkdir)
489
490$(extra-installed) : $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR)
491 $(call cmd,install)
492
493$(hostprogs-installed) : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR)
494 $(call cmd,install_exe)
495
496$(dts-installed) : $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR)
497 $(call cmd,install_dts)
498
499$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR)
500 $(call cmd,install_wrapper)
501
502$(obj)/bootwrapper_install: $(all-installed)