blob: c3caa5bdd6e6abacf12df237f0859710fb1d62e3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001# Makefile for making ELF bootable images for booting on CHRP
2# using Open Firmware.
3#
4# Geert Uytterhoeven September 1997
5#
6# Based on coffboot by Paul Mackerras
7# Simplified for ppc64 by Todd Inglett
8#
9# NOTE: this code is built for 32 bit in ELF32 format even though
10# it packages a 64 bit kernel. We do this to simplify the
11# bootloader and increase compatibility with OpenFirmware.
12#
13# To this end we need to define BOOTCC, etc, as the tools
David Gibsonb610b972007-05-29 15:37:12 +100014# needed to build the 32 bit image. That's normally the same
15# compiler for the rest of the kernel, with the -m32 flag added.
Linus Torvalds1da177e2005-04-16 15:20:36 -070016# To make it easier to setup a cross compiler,
17# CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
18# in the toplevel makefile.
19
Paul Mackerras2bf11812006-09-27 22:47:03 +100020all: $(obj)/zImage
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Oliver O'Halloran22750d92016-09-22 16:54:30 +100022compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
Oliver O'Halloranc762c692016-09-22 16:54:34 +100023compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ
Oliver O'Halloran22750d92016-09-22 16:54:30 +100024
David Gibsonb610b972007-05-29 15:37:12 +100025BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
Benjamin Herrenschmidt6846ee52010-01-13 16:19:34 +110026 -fno-strict-aliasing -Os -msoft-float -pipe \
David Gibsonb610b972007-05-29 15:37:12 +100027 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
Oliver O'Halloran22750d92016-09-22 16:54:30 +100028 -D$(compress-y)
29
Michael Ellerman65c5ec12017-07-26 23:19:04 +100030BOOTCC := $(CC)
Cédric Le Goater147c0512014-04-24 09:23:39 +020031ifdef CONFIG_PPC64_BOOT_WRAPPER
32BOOTCFLAGS += -m64
Michael Ellerman65c5ec12017-07-26 23:19:04 +100033else
34BOOTCFLAGS += -m32
35ifdef CROSS32_COMPILE
36 BOOTCC := $(CROSS32_COMPILE)gcc
Cédric Le Goater147c0512014-04-24 09:23:39 +020037endif
Michael Ellerman65c5ec12017-07-26 23:19:04 +100038endif
39
40BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include)
41
Cédric Le Goater147c0512014-04-24 09:23:39 +020042ifdef CONFIG_CPU_BIG_ENDIAN
43BOOTCFLAGS += -mbig-endian
Benjamin Herrenschmidt655471f2015-09-15 11:24:17 +100044else
45BOOTCFLAGS += -mlittle-endian
46BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
Cédric Le Goater147c0512014-04-24 09:23:39 +020047endif
48
Olaf Heringdecd3002005-08-08 13:24:38 +100049BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Grant Likely105c13d2007-10-04 14:05:01 +100051ifdef CONFIG_DEBUG_INFO
52BOOTCFLAGS += -g
53endif
54
Niels Kristian Bech Jensenfda7ffd2006-07-02 13:02:27 +020055ifeq ($(call cc-option-yn, -fstack-protector),y)
56BOOTCFLAGS += -fno-stack-protector
57endif
58
Arnd Bergmann58ab5e02016-06-15 17:45:46 +020059BOOTCFLAGS += -I$(objtree)/$(obj) -I$(srctree)/$(obj)
Olaf Hering70540362005-10-28 17:46:38 -070060
Dirk Brandewie63849342010-12-22 11:57:28 -080061DTC_FLAGS ?= -p 1024
Kumar Gala9d4ae9f2008-06-26 18:58:11 +100062
Josh Boyerbf2e70a2008-02-19 13:52:48 +110063$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
64$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
Solomon Peachy0cdf50a2009-08-20 10:19:47 +000065$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
Josh Boyerbf2e70a2008-02-19 13:52:48 +110066$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
67$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
Josh Boyer9f3eefc2008-11-25 06:33:35 +000068$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
Josh Boyer2e71cc02007-09-24 07:32:15 -050069$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
Torez Smithb4e8c8d2010-03-05 10:45:54 +000070$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
Tony Breeds228d5502011-11-30 21:39:24 +000071$(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
Alistair Popple2a2c74b2014-03-06 14:52:27 +110072$(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
Grant Likelyb9e4f172008-04-25 03:33:44 +100073$(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
Josh Boyer60e41752007-05-17 04:51:37 +100074
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +100075# The pre-boot decompressors pull in a lot of kernel headers and other source
76# files. This creates a bit of a dependency headache since we need to copy
77# these files into the build dir, fix up any includes and ensure that dependent
78# files are copied in the right order.
79
80# these need to be seperate variables because they are copied out of different
81# directories in the kernel tree. Sure you COULd merge them, but it's a
82# cure-is-worse-than-disease situation.
83zlib-decomp-$(CONFIG_KERNEL_GZIP) := decompress_inflate.c
Oliver O'Halloran22750d92016-09-22 16:54:30 +100084zlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c
85zlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h infutil.h
86zliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h
Hugh Blemings6bbc5472007-12-21 15:39:28 +110087
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +100088$(addprefix $(obj)/, decompress.o): \
89 $(addprefix $(obj)/,$(zlib-decomp-y))
90
91$(addprefix $(obj)/, $(zlib-decomp-y)): \
92 $(addprefix $(obj)/,$(zliblinuxheader-y)) \
93 $(addprefix $(obj)/,$(zlibheader-y)) \
94 $(addprefix $(obj)/,$(zlib-y))
95
96$(addprefix $(obj)/,$(zlib-y)): \
Oliver O'Halloran22750d92016-09-22 16:54:30 +100097 $(addprefix $(obj)/,$(zliblinuxheader-y)) \
98 $(addprefix $(obj)/,$(zlibheader-y))
Paul Mackerras2bf11812006-09-27 22:47:03 +100099
David Gibson9fffb552009-04-30 15:25:53 +1000100libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
101libfdtheader := fdt.h libfdt.h libfdt_internal.h
102
Oliver O'Halloran656ad582016-07-01 00:34:37 +1000103$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \
David Gibson9fffb552009-04-30 15:25:53 +1000104 $(addprefix $(obj)/,$(libfdtheader))
105
Nicholas Piggin7c868b62017-05-12 01:56:50 +1000106src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
David Gibson9fffb552009-04-30 15:25:53 +1000107 $(libfdt) libfdt-wrapper.c \
David Gibsonad9d2712007-03-05 14:24:52 +1100108 ns16550.c serial.c simple_alloc.c div64.S util.S \
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000109 elf_util.c $(zlib-y) devtree.c stdlib.c \
Hannes Reinecke866bfc72017-06-27 16:29:51 +0200110 oflib.c ofconsole.c cuboot.c cpm-serial.c \
111 uartlite.c opal.c
112src-wlib-$(CONFIG_PPC_MPC52XX) += mpc52xx-psc.c
Ben Hutchings10c77db2016-11-16 18:27:56 +0000113src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S
Nicholas Piggin7c868b62017-05-12 01:56:50 +1000114ifndef CONFIG_PPC64_BOOT_WRAPPER
115src-wlib-y += crtsavres.S
116endif
Tony Breedsb81f18e2012-04-03 15:00:39 +0000117src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
118src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
Christophe Leroy968159c2017-08-08 13:58:54 +0200119src-wlib-$(CONFIG_PPC_8xx) += mpc8xx.c planetcore.c fsl-soc.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000120src-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c
Hannes Reinecke866bfc72017-06-27 16:29:51 +0200121src-wlib-$(CONFIG_EMBEDDED6xx) += mpsc.c mv64x60.c mv64x60_i2c.c ugecon.c fsl-soc.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000122
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000123src-plat-y := of.c epapr.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000124src-plat-$(CONFIG_40x) += fixed-head.S ep405.c cuboot-hotfoot.c \
125 treeboot-walnut.c cuboot-acadia.c \
126 cuboot-kilauea.c simpleboot.c \
127 virtex405-head.S virtex.c
128src-plat-$(CONFIG_44x) += treeboot-ebony.c cuboot-ebony.c treeboot-bamboo.c \
129 cuboot-bamboo.c cuboot-sam440ep.c \
130 cuboot-sequoia.c cuboot-rainier.c \
131 cuboot-taishan.c cuboot-katmai.c \
132 cuboot-warp.c cuboot-yosemite.c \
133 treeboot-iss4xx.c treeboot-currituck.c \
Alistair Popple2a2c74b2014-03-06 14:52:27 +1100134 treeboot-akebono.c \
Tony Breedsb81f18e2012-04-03 15:00:39 +0000135 simpleboot.c fixed-head.S virtex.c
Christophe Leroy968159c2017-08-08 13:58:54 +0200136src-plat-$(CONFIG_PPC_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000137src-plat-$(CONFIG_PPC_MPC52xx) += cuboot-52xx.c
138src-plat-$(CONFIG_PPC_82xx) += cuboot-pq2.c fixed-head.S ep8248e.c cuboot-824x.c
139src-plat-$(CONFIG_PPC_83xx) += cuboot-83xx.c fixed-head.S redboot-83xx.c
140src-plat-$(CONFIG_FSL_SOC_BOOKE) += cuboot-85xx.c cuboot-85xx-cpm2.c
141src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
142 cuboot-c2k.c gamecube-head.S \
143 gamecube.c wii-head.S wii.c holly.c \
Paul Gortmaker3c8464a2014-02-05 20:35:13 -0500144 fixed-head.S mvme5100.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000145src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
146src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000147src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
Cédric Le Goater2d9afb32014-04-24 09:23:38 +0200148src-plat-$(CONFIG_PPC_PSERIES) += pseries-head.S
149src-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S
150src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
Alessio Igor Bogani97493e2e2016-05-30 11:47:16 +0200151src-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c
Tony Breedsb81f18e2012-04-03 15:00:39 +0000152
153src-wlib := $(sort $(src-wlib-y))
154src-plat := $(sort $(src-plat-y))
David Gibsoncd197ff2007-03-05 14:24:52 +1100155src-boot := $(src-wlib) $(src-plat) empty.c
Paul Mackerras2bf11812006-09-27 22:47:03 +1000156
157src-boot := $(addprefix $(obj)/, $(src-boot))
158obj-boot := $(addsuffix .o, $(basename $(src-boot)))
159obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
160obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
Matthew McClintock0090e022012-09-06 08:48:54 +0000161obj-plat: $(libfdt)
Paul Mackerras2bf11812006-09-27 22:47:03 +1000162
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000163quiet_cmd_copy_kern_src = COPY $@
164 cmd_copy_kern_src = sed -f $(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
Olaf Hering70540362005-10-28 17:46:38 -0700165
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000166$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000167 $(call cmd,copy_kern_src)
Olaf Hering70540362005-10-28 17:46:38 -0700168
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000169$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000170 $(call cmd,copy_kern_src)
Olaf Hering70540362005-10-28 17:46:38 -0700171
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000172$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
Oliver O'Halloran1a13de62016-09-22 16:54:29 +1000173 $(call cmd,copy_kern_src)
Olaf Hering70540362005-10-28 17:46:38 -0700174
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000175$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/%
176 $(call cmd,copy_kern_src)
177
David Gibson9fffb552009-04-30 15:25:53 +1000178quiet_cmd_copy_libfdt = COPY $@
179 cmd_copy_libfdt = cp $< $@
180
181$(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
182 $(call cmd,copy_libfdt)
183
Paul Mackerras2bf11812006-09-27 22:47:03 +1000184$(obj)/empty.c:
Michael Ellerman6abe2482016-08-11 16:03:13 +1000185 $(Q)touch $@
Olaf Hering70540362005-10-28 17:46:38 -0700186
Cédric Le Goater147c0512014-04-24 09:23:39 +0200187$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
Michael Ellerman6abe2482016-08-11 16:03:13 +1000188 $(Q)cp $< $@
Paul Mackerras2bf11812006-09-27 22:47:03 +1000189
Oliver O'Halloran22750d92016-09-22 16:54:30 +1000190clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000191 $(zlib-decomp-) $(libfdt) $(libfdtheader) \
Kumar Galab58a4572008-05-18 13:23:03 -0500192 empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
Olaf Hering70540362005-10-28 17:46:38 -0700193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194quiet_cmd_bootcc = BOOTCC $@
Michael Ellerman65c5ec12017-07-26 23:19:04 +1000195 cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197quiet_cmd_bootas = BOOTAS $@
Michael Ellerman65c5ec12017-07-26 23:19:04 +1000198 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Paul Mackerras2bf11812006-09-27 22:47:03 +1000200quiet_cmd_bootar = BOOTAR $@
Michal Marek31355402011-05-05 05:22:55 +0000201 cmd_bootar = $(CROSS32AR) -cr$(KBUILD_ARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
Geoff Levanda24c8482005-08-15 13:59:13 -0700202
David Gibson9fffb552009-04-30 15:25:53 +1000203$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
204 $(call if_changed_dep,bootcc)
Milton Miller235fd832007-03-21 09:02:37 -0600205$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
David Gibson2f0dfea2007-12-10 14:28:39 +1100206 $(Q)mkdir -p $(dir $@)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 $(call if_changed_dep,bootcc)
Milton Miller235fd832007-03-21 09:02:37 -0600208$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
David Gibson2f0dfea2007-12-10 14:28:39 +1100209 $(Q)mkdir -p $(dir $@)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 $(call if_changed_dep,bootas)
211
Milton Miller235fd832007-03-21 09:02:37 -0600212$(obj)/wrapper.a: $(obj-wlib) FORCE
213 $(call if_changed,bootar)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Paul Mackerras97bb63e2010-06-07 14:27:10 +0000215hostprogs-y := addnote hack-coff mktree
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Milton Miller235fd832007-03-21 09:02:37 -0600217targets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
David Gibsoncd197ff2007-03-05 14:24:52 +1100218extra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
Geoff Levandbafdb642007-07-04 09:07:18 +1000219 $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
Paul Mackerras66a45dd2006-01-14 15:04:06 +1100220
Grant Likely25431332008-02-07 05:18:34 +1100221dtstree := $(srctree)/$(src)/dts
222
Paul Mackerras2bf11812006-09-27 22:47:03 +1000223wrapper :=$(srctree)/$(src)/wrapper
David Gibson9fffb552009-04-30 15:25:53 +1000224wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
Milton Miller235fd832007-03-21 09:02:37 -0600225 $(wrapper) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Paul Mackerras2bf11812006-09-27 22:47:03 +1000227#############
228# Bits for building various flavours of zImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Paul Mackerras2bf11812006-09-27 22:47:03 +1000230ifneq ($(CROSS32_COMPILE),)
Michael Ellermandcf90652006-09-30 11:54:09 +1000231CROSSWRAP := -C "$(CROSS32_COMPILE)"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000232else
233ifneq ($(CROSS_COMPILE),)
Michael Ellermandcf90652006-09-30 11:54:09 +1000234CROSSWRAP := -C "$(CROSS_COMPILE)"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000235endif
236endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000238compressor-$(CONFIG_KERNEL_GZIP) := gz
Oliver O'Halloranc762c692016-09-22 16:54:34 +1000239compressor-$(CONFIG_KERNEL_XZ) := xz
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000240
Milton Miller9da82a62007-03-21 09:03:23 -0600241# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
Paul Mackerras2bf11812006-09-27 22:47:03 +1000242quiet_cmd_wrap = WRAP $@
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000243 cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
244 $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
245 vmlinux
Paul Mackerras2bf11812006-09-27 22:47:03 +1000246
Geoff Levand020533e2006-10-07 15:33:53 -0700247image-$(CONFIG_PPC_PSERIES) += zImage.pseries
Benjamin Herrenschmidt55190f82011-09-19 17:44:52 +0000248image-$(CONFIG_PPC_POWERNV) += zImage.pseries
Corey Minyard58706ef2010-01-29 14:18:20 +0000249image-$(CONFIG_PPC_MAPLE) += zImage.maple
Geoff Levand020533e2006-10-07 15:33:53 -0700250image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
Grant Likely595be942008-02-22 05:57:07 +1100251image-$(CONFIG_PPC_PS3) += dtbImage.ps3
Geoff Levand020533e2006-10-07 15:33:53 -0700252image-$(CONFIG_PPC_CHRP) += zImage.chrp
Nicolas DET7839af32006-11-17 17:08:37 +0100253image-$(CONFIG_PPC_EFIKA) += zImage.chrp
Geoff Levand020533e2006-10-07 15:33:53 -0700254image-$(CONFIG_PPC_PMAC) += zImage.pmac
Josh Boyer32dde0f2008-09-09 04:00:28 +0000255image-$(CONFIG_PPC_HOLLY) += dtbImage.holly
Scott Woodac18c672007-05-03 04:00:00 +1000256image-$(CONFIG_DEFAULT_UIMAGE) += uImage
David Gibson6c5b59b2011-04-14 18:29:16 +0000257image-$(CONFIG_EPAPR_BOOT) += zImage.epapr
Scott Woodac18c672007-05-03 04:00:00 +1000258
Grant Likely25431332008-02-07 05:18:34 +1100259#
260# Targets which embed a device tree blob
261#
262# Theses are default targets to build images which embed device tree blobs.
263# They are only required on boards which do not have FDT support in firmware.
Nick Andrew2a947392009-01-03 18:59:37 +1100264# Boards with newish u-boot firmware can use the uImage target above
Grant Likely25431332008-02-07 05:18:34 +1100265#
266
267# Board ports in arch/powerpc/platform/40x/Kconfig
Grant Likely595be942008-02-22 05:57:07 +1100268image-$(CONFIG_EP405) += dtbImage.ep405
Solomon Peachy0cdf50a2009-08-20 10:19:47 +0000269image-$(CONFIG_HOTFOOT) += cuImage.hotfoot
Grant Likely25431332008-02-07 05:18:34 +1100270image-$(CONFIG_WALNUT) += treeImage.walnut
Josh Boyer94c73a82008-09-03 21:01:39 -0400271image-$(CONFIG_ACADIA) += cuImage.acadia
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000272image-$(CONFIG_OBS600) += uImage.obs600
Grant Likely25431332008-02-07 05:18:34 +1100273
274# Board ports in arch/powerpc/platform/44x/Kconfig
David Gibsonf6dfc802007-05-08 14:10:01 +1000275image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
Josh Boyer658e8172007-09-15 04:54:11 +1000276image-$(CONFIG_BAMBOO) += treeImage.bamboo cuImage.bamboo
Giuseppe Coviellob6014e12008-05-20 01:20:47 +1000277image-$(CONFIG_SAM440EP) += cuImage.sam440ep
Valentine Barshak606d08b2007-08-29 17:38:30 +0400278image-$(CONFIG_SEQUOIA) += cuImage.sequoia
Valentine Barshak295e7422007-10-31 03:56:06 +1100279image-$(CONFIG_RAINIER) += cuImage.rainier
Hugh Blemings6bbc5472007-12-21 15:39:28 +1100280image-$(CONFIG_TAISHAN) += cuImage.taishan
Benjamin Herrenschmidt3de9c9c2007-12-21 15:39:34 +1100281image-$(CONFIG_KATMAI) += cuImage.katmai
Sean MacLennan1e12f3c2008-01-11 17:17:51 +1100282image-$(CONFIG_WARP) += cuImage.warp
Josh Boyerd0a48c92008-03-06 21:15:52 -0600283image-$(CONFIG_YOSEMITE) += cuImage.yosemite
Torez Smithb4e8c8d2010-03-05 10:45:54 +0000284image-$(CONFIG_ISS4xx) += treeImage.iss4xx \
285 treeImage.iss4xx-mpic
Tony Breeds228d5502011-11-30 21:39:24 +0000286image-$(CONFIG_CURRITUCK) += treeImage.currituck
Alistair Popple2a2c74b2014-03-06 14:52:27 +1100287image-$(CONFIG_AKEBONO) += treeImage.akebono
Geoff Levanda24c8482005-08-15 13:59:13 -0700288
Grant Likely25431332008-02-07 05:18:34 +1100289# Board ports in arch/powerpc/platform/8xx/Kconfig
Adrian Bunkefa58fb2008-05-22 03:38:28 +1000290image-$(CONFIG_MPC86XADS) += cuImage.mpc866ads
291image-$(CONFIG_MPC885ADS) += cuImage.mpc885ads
Grant Likely595be942008-02-22 05:57:07 +1100292image-$(CONFIG_PPC_EP88XC) += dtbImage.ep88xc
Grant Likely25431332008-02-07 05:18:34 +1100293image-$(CONFIG_PPC_ADDER875) += cuImage.adder875-uboot \
Grant Likely595be942008-02-22 05:57:07 +1100294 dtbImage.adder875-redboot
Grant Likely25431332008-02-07 05:18:34 +1100295
296# Board ports in arch/powerpc/platform/52xx/Kconfig
Grant Likelybfee95b2009-02-04 13:39:17 -0700297image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 lite5200.dtb
298image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b lite5200b.dtb
299image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200 media5200.dtb
Grant Likely25431332008-02-07 05:18:34 +1100300
301# Board ports in arch/powerpc/platform/82xx/Kconfig
302image-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads
303image-$(CONFIG_PQ2FADS) += cuImage.pq2fads
Grant Likely595be942008-02-22 05:57:07 +1100304image-$(CONFIG_EP8248E) += dtbImage.ep8248e
Grant Likely25431332008-02-07 05:18:34 +1100305
306# Board ports in arch/powerpc/platform/83xx/Kconfig
307image-$(CONFIG_MPC832x_MDS) += cuImage.mpc832x_mds
308image-$(CONFIG_MPC832x_RDB) += cuImage.mpc832x_rdb
309image-$(CONFIG_MPC834x_ITX) += cuImage.mpc8349emitx \
310 cuImage.mpc8349emitxgp
311image-$(CONFIG_MPC834x_MDS) += cuImage.mpc834x_mds
312image-$(CONFIG_MPC836x_MDS) += cuImage.mpc836x_mds
Bryan O'Donoghue59d13f92008-05-08 13:47:00 +0100313image-$(CONFIG_ASP834x) += dtbImage.asp834x-redboot
Grant Likely25431332008-02-07 05:18:34 +1100314
315# Board ports in arch/powerpc/platform/85xx/Kconfig
316image-$(CONFIG_MPC8540_ADS) += cuImage.mpc8540ads
317image-$(CONFIG_MPC8560_ADS) += cuImage.mpc8560ads
318image-$(CONFIG_MPC85xx_CDS) += cuImage.mpc8541cds \
Zhao Chenhui0d4fdd322012-03-06 17:06:44 +0800319 cuImage.mpc8548cds_32b \
Grant Likely25431332008-02-07 05:18:34 +1100320 cuImage.mpc8555cds
321image-$(CONFIG_MPC85xx_MDS) += cuImage.mpc8568mds
322image-$(CONFIG_MPC85xx_DS) += cuImage.mpc8544ds \
323 cuImage.mpc8572ds
324image-$(CONFIG_TQM8540) += cuImage.tqm8540
325image-$(CONFIG_TQM8541) += cuImage.tqm8541
Wolfgang Grandegger6dd1b642008-06-06 13:50:04 +0200326image-$(CONFIG_TQM8548) += cuImage.tqm8548
Grant Likely25431332008-02-07 05:18:34 +1100327image-$(CONFIG_TQM8555) += cuImage.tqm8555
328image-$(CONFIG_TQM8560) += cuImage.tqm8560
Paul Gortmakera72a6f52008-03-18 16:13:10 +1100329image-$(CONFIG_SBC8548) += cuImage.sbc8548
Alexandr Smirnovff880112008-03-04 19:34:26 +0300330image-$(CONFIG_KSI8560) += cuImage.ksi8560
Grant Likely25431332008-02-07 05:18:34 +1100331
Alessio Igor Bogani97493e2e2016-05-30 11:47:16 +0200332# Board ports in arch/powerpc/platform/86xx/Kconfig
333image-$(CONFIG_MVME7100) += dtbImage.mvme7100
334
Grant Likely25431332008-02-07 05:18:34 +1100335# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
336image-$(CONFIG_STORCENTER) += cuImage.storcenter
337image-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2
Remi Machetc6ec08e2008-05-21 06:50:10 +1000338image-$(CONFIG_PPC_C2K) += cuImage.c2k
Albert Herranzb68a24b2009-12-12 06:31:36 +0000339image-$(CONFIG_GAMECUBE) += dtbImage.gamecube
Albert Herranz6cdd24172009-12-12 06:31:45 +0000340image-$(CONFIG_WII) += dtbImage.wii
Stephen Chiversbe201982014-01-09 13:01:22 +1100341image-$(CONFIG_MVME5100) += dtbImage.mvme5100
Scott Woodb09c1642008-01-17 16:31:40 -0600342
Gerhard Pircher8f237352009-02-10 12:26:11 +0000343# Board port in arch/powerpc/platform/amigaone/Kconfig
344image-$(CONFIG_AMIGAONE) += cuImage.amigaone
345
Paul Mackerras9216ad82006-01-15 13:00:08 +1100346# For 32-bit powermacs, build the COFF and miboot images
347# as well as the ELF images.
Paul Mackerras2bf11812006-09-27 22:47:03 +1000348ifeq ($(CONFIG_PPC32),y)
349image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot
350endif
Paul Mackerras66a45dd2006-01-14 15:04:06 +1100351
Grant Likelyc356aa42008-07-09 09:41:52 -0600352# Allow extra targets to be added to the defconfig
353image-y += $(subst ",,$(CONFIG_EXTRA_TARGETS))
354
Michal Marek755457f2014-10-02 15:49:15 +0200355initrd- := $(patsubst zImage%, zImage.initrd%, $(image-))
David Gibsonf6dfc802007-05-08 14:10:01 +1000356initrd-y := $(patsubst zImage%, zImage.initrd%, \
Grant Likely595be942008-02-22 05:57:07 +1100357 $(patsubst dtbImage%, dtbImage.initrd%, \
John Linn5d1a0412008-07-01 14:17:18 -0600358 $(patsubst simpleImage%, simpleImage.initrd%, \
359 $(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
Milton Miller9da82a62007-03-21 09:03:23 -0600360initrd-y := $(filter-out $(image-y), $(initrd-y))
Milton Miller235fd832007-03-21 09:02:37 -0600361targets += $(image-y) $(initrd-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362
Milton Miller9da82a62007-03-21 09:03:23 -0600363$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
364
365# Don't put the ramdisk on the pattern rule; when its missing make will try
366# the pattern rule with less dependencies that also matches (even with the
367# hard dependency listed).
Michael Ellerman42d0c932016-11-21 21:14:34 +1100368$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) FORCE
Grant Likely25431332008-02-07 05:18:34 +1100369 $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
Milton Miller9da82a62007-03-21 09:03:23 -0600370
Michael Ellerman42d0c932016-11-21 21:14:34 +1100371$(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperbits) FORCE
Michal Marek699c6592014-06-11 13:53:48 +0200372 $(call if_changed,wrap,$(subst $(obj)/zImage.,,$@))
Grant Likely25431332008-02-07 05:18:34 +1100373
Grant Likely595be942008-02-22 05:57:07 +1100374# dtbImage% - a dtbImage is a zImage with an embedded device tree blob
Michael Ellerman42d0c932016-11-21 21:14:34 +1100375$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE
Grant Likelye04018e2008-03-25 09:52:46 +1100376 $(call if_changed,wrap,$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
Grant Likely25431332008-02-07 05:18:34 +1100377
Michael Ellerman42d0c932016-11-21 21:14:34 +1100378$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE
Grant Likelye04018e2008-03-25 09:52:46 +1100379 $(call if_changed,wrap,$*,,$(obj)/$*.dtb)
Milton Miller9da82a62007-03-21 09:03:23 -0600380
Tony Breeds4bb09282007-07-04 14:04:31 +1000381# This cannot be in the root of $(src) as the zImage rule always adds a $(obj)
382# prefix
383$(obj)/vmlinux.strip: vmlinux
384 $(STRIP) -s -R .comment $< -o $@
385
Michael Ellerman42d0c932016-11-21 21:14:34 +1100386$(obj)/uImage: vmlinux $(wrapperbits) FORCE
Milton Miller9da82a62007-03-21 09:03:23 -0600387 $(call if_changed,wrap,uboot)
388
Michael Ellerman42d0c932016-11-21 21:14:34 +1100389$(obj)/uImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000390 $(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
391
Michael Ellerman42d0c932016-11-21 21:14:34 +1100392$(obj)/uImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000393 $(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb)
394
Michael Ellerman42d0c932016-11-21 21:14:34 +1100395$(obj)/cuImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Grant Likelya4292d7a2008-10-17 19:12:07 +0000396 $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
397
Michael Ellerman42d0c932016-11-21 21:14:34 +1100398$(obj)/cuImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Grant Likelye04018e2008-03-25 09:52:46 +1100399 $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb)
Scott Wood0fdd7172007-04-17 09:25:50 +1000400
Michael Ellerman42d0c932016-11-21 21:14:34 +1100401$(obj)/simpleImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Grant Likelyd2477b52008-03-19 04:07:43 +1100402 $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
403
Michael Ellerman42d0c932016-11-21 21:14:34 +1100404$(obj)/simpleImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Grant Likelyd2477b52008-03-19 04:07:43 +1100405 $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb)
406
Michael Ellerman42d0c932016-11-21 21:14:34 +1100407$(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Grant Likelye04018e2008-03-25 09:52:46 +1100408 $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
David Gibsonf6dfc802007-05-08 14:10:01 +1000409
Michael Ellerman42d0c932016-11-21 21:14:34 +1100410$(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE
Grant Likelye04018e2008-03-25 09:52:46 +1100411 $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb)
412
413# Rule to build device tree blobs
Stephen Warren7c431852012-01-09 11:38:15 -0700414$(obj)/%.dtb: $(src)/dts/%.dts FORCE
415 $(call if_changed_dep,dtc)
David Gibson6a32d082007-05-15 12:40:23 +1000416
Alessio Igor Bogani4680c9d2016-04-18 08:36:19 +0200417$(obj)/%.dtb: $(src)/dts/fsl/%.dts FORCE
418 $(call if_changed_dep,dtc)
419
Tony Breeds4bb09282007-07-04 14:04:31 +1000420# If there isn't a platform selected then just strip the vmlinux.
421ifeq (,$(image-y))
422image-y := vmlinux.strip
423endif
424
Paul Mackerras2bf11812006-09-27 22:47:03 +1000425$(obj)/zImage: $(addprefix $(obj)/, $(image-y))
Michael Ellerman6abe2482016-08-11 16:03:13 +1000426 $(Q)rm -f $@; ln $< $@
Paul Mackerras2bf11812006-09-27 22:47:03 +1000427$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))
Michael Ellerman6abe2482016-08-11 16:03:13 +1000428 $(Q)rm -f $@; ln $< $@
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429
Tony Breedsc913e5f2014-08-14 17:05:04 +1000430# Only install the vmlinux
Akinobu Mita928370c2007-04-10 21:05:31 +1000431install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
Tony Breedsc913e5f2014-08-14 17:05:04 +1000432 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
433
434# Install the vmlinux and other built boot targets.
435zInstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
Grant Likely29f1aff2008-12-19 14:57:20 +0000436 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
Paul Mackerras66a45dd2006-01-14 15:04:06 +1100437
Milton Miller1383a342007-03-28 02:21:04 -0600438# anything not in $(targets)
Kumar Galab58a4572008-05-18 13:23:03 -0500439clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \
440 zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \
Stephen Rothwell1b041882012-03-15 18:20:13 +0000441 zImage.miboot zImage.pmac zImage.pseries \
Masahiro Yamada74ce1892017-11-02 11:51:25 +0900442 zImage.maple simpleImage.* otheros.bld
Milton Miller1383a342007-03-28 02:21:04 -0600443
444# clean up files cached by wrapper
Oliver O'Halloran1b7898e2016-09-22 16:54:31 +1000445clean-kernel-base := vmlinux.strip vmlinux.bin
446clean-kernel := $(addsuffix .gz,$(clean-kernel-base))
Oliver O'Halloranc762c692016-09-22 16:54:34 +1000447clean-kernel += $(addsuffix .xz,$(clean-kernel-base))
Milton Miller1383a342007-03-28 02:21:04 -0600448# If not absolute clean-files are relative to $(obj).
449clean-files += $(addprefix $(objtree)/, $(clean-kernel))
David Woodhouse773f76b2007-12-03 13:56:58 +1100450
451WRAPPER_OBJDIR := /usr/lib/kernel-wrapper
452WRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts
453WRAPPER_BINDIR := /usr/sbin
454INSTALL := install
455
456extra-installed := $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y))
457hostprogs-installed := $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs-y))
458wrapper-installed := $(DESTDIR)$(WRAPPER_BINDIR)/wrapper
Ben Hutchings4d9ef892011-01-08 14:24:01 +0000459dts-installed := $(patsubst $(dtstree)/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(dtstree)/*.dts))
David Woodhouse773f76b2007-12-03 13:56:58 +1100460
461all-installed := $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed)
462
463quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
464 cmd_mkdir = mkdir -p $@
465
466quiet_cmd_install = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@)
467 cmd_install = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@
468
469quiet_cmd_install_dts = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@)
470 cmd_install_dts = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@
471
472quiet_cmd_install_exe = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
473 cmd_install_exe = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@
474
475quiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
476 cmd_install_wrapper = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\
477 sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \
478 -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \
479
480
481$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR):
482 $(call cmd,mkdir)
483
484$(extra-installed) : $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR)
485 $(call cmd,install)
486
487$(hostprogs-installed) : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR)
488 $(call cmd,install_exe)
489
490$(dts-installed) : $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR)
491 $(call cmd,install_dts)
492
493$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR)
494 $(call cmd,install_wrapper)
495
496$(obj)/bootwrapper_install: $(all-installed)