xref: /linux/arch/powerpc/boot/Makefile (revision 9fffb55f66127b52c937ede5196ebfa0c0d50bce)
194b212c2SPaul Mackerras# Makefile for making ELF bootable images for booting on CHRP
294b212c2SPaul Mackerras# using Open Firmware.
394b212c2SPaul Mackerras#
494b212c2SPaul Mackerras# Geert Uytterhoeven	September 1997
594b212c2SPaul Mackerras#
694b212c2SPaul Mackerras# Based on coffboot by Paul Mackerras
794b212c2SPaul Mackerras# Simplified for ppc64 by Todd Inglett
894b212c2SPaul Mackerras#
994b212c2SPaul Mackerras# NOTE:	this code is built for 32 bit in ELF32 format even though
1094b212c2SPaul Mackerras#	it packages a 64 bit kernel.  We do this to simplify the
1194b212c2SPaul Mackerras#	bootloader and increase compatibility with OpenFirmware.
1294b212c2SPaul Mackerras#
1394b212c2SPaul Mackerras#	To this end we need to define BOOTCC, etc, as the tools
14b610b978SDavid Gibson#	needed to build the 32 bit image.  That's normally the same
15b610b978SDavid Gibson#	compiler for the rest of the kernel, with the -m32 flag added.
1694b212c2SPaul Mackerras#	To make it easier to setup a cross compiler,
1794b212c2SPaul Mackerras#	CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
1894b212c2SPaul Mackerras#	in the toplevel makefile.
1994b212c2SPaul Mackerras
202bf11819SPaul Mackerrasall: $(obj)/zImage
2194b212c2SPaul Mackerras
22b610b978SDavid GibsonBOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
23b610b978SDavid Gibson		 -fno-strict-aliasing -Os -msoft-float -pipe \
24b610b978SDavid Gibson		 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
25b610b978SDavid Gibson		 -isystem $(shell $(CROSS32CC) -print-file-name=include)
2694b212c2SPaul MackerrasBOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
2794b212c2SPaul Mackerras
28105c13ddSGrant Likelyifdef CONFIG_DEBUG_INFO
29105c13ddSGrant LikelyBOOTCFLAGS	+= -g
30105c13ddSGrant Likelyendif
31105c13ddSGrant Likely
32fda7ffd2SNiels Kristian Bech Jensenifeq ($(call cc-option-yn, -fstack-protector),y)
33fda7ffd2SNiels Kristian Bech JensenBOOTCFLAGS	+= -fno-stack-protector
34fda7ffd2SNiels Kristian Bech Jensenendif
35fda7ffd2SNiels Kristian Bech Jensen
36*9fffb55fSDavid GibsonBOOTCFLAGS	+= -I$(obj) -I$(srctree)/$(obj)
3794b212c2SPaul Mackerras
389d4ae9fcSKumar GalaDTS_FLAGS	?= -p 1024
399d4ae9fcSKumar Gala
40bf2e70acSJosh Boyer$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
41bf2e70acSJosh Boyer$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
42bf2e70acSJosh Boyer$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
43bf2e70acSJosh Boyer$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
449f3eefc4SJosh Boyer$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
452e71cc0dSJosh Boyer$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
46b9e4f176SGrant Likely$(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
4760e41753SJosh Boyer
486bbc5476SHugh Blemings
492bf11819SPaul Mackerraszlib       := inffast.c inflate.c inftrees.c
502bf11819SPaul Mackerraszlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h
512bf11819SPaul Mackerraszliblinuxheader := zlib.h zconf.h zutil.h
522bf11819SPaul Mackerras
534ff23fa9SHugh Dickins$(addprefix $(obj)/,$(zlib) cuboot-c2k.o gunzip_util.o main.o prpmc2800.o): \
54d25a9d66SDavid Gibson	$(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
552bf11819SPaul Mackerras
56*9fffb55fSDavid Gibsonlibfdt       := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
57*9fffb55fSDavid Gibsonlibfdtheader := fdt.h libfdt.h libfdt_internal.h
58*9fffb55fSDavid Gibson
59*9fffb55fSDavid Gibson$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o): \
60*9fffb55fSDavid Gibson	$(addprefix $(obj)/,$(libfdtheader))
61*9fffb55fSDavid Gibson
62143580ecSKumar Galasrc-wlib := string.S crt0.S crtsavres.S stdio.c main.c \
63*9fffb55fSDavid Gibson		$(libfdt) libfdt-wrapper.c \
64ad9d2716SDavid Gibson		ns16550.c serial.c simple_alloc.c div64.S util.S \
652e601613SDavid Gibson		gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
66d0f53fafSScott Wood		4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
67bbc6fac3SScott Wood		cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \
68bbc6fac3SScott Wood		fsl-soc.c mpc8xx.c pq2.c
693490cba5SJon Loeligersrc-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \
70bafdb645SGeoff Levand		cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
71606d08bcSValentine Barshak		ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
7225431333SGrant Likely		cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \
7325431333SGrant Likely		cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \
74c6ec08e0SRemi Machet		fixed-head.S ep88xc.c ep405.c cuboot-c2k.c \
751e12f3c5SSean MacLennan		cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
76d2477b5cSGrant Likely		cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
7794c73a8fSJosh Boyer		virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
788f23735dSGerhard Pircher		cuboot-acadia.c cuboot-amigaone.c
79cd197ffcSDavid Gibsonsrc-boot := $(src-wlib) $(src-plat) empty.c
802bf11819SPaul Mackerras
812bf11819SPaul Mackerrassrc-boot := $(addprefix $(obj)/, $(src-boot))
822bf11819SPaul Mackerrasobj-boot := $(addsuffix .o, $(basename $(src-boot)))
832bf11819SPaul Mackerrasobj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
842bf11819SPaul Mackerrasobj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
852bf11819SPaul Mackerras
8694b212c2SPaul Mackerrasquiet_cmd_copy_zlib = COPY    $@
873ff6eeccSAdrian Bunk      cmd_copy_zlib = sed "s@__used@@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@
8894b212c2SPaul Mackerras
8994b212c2SPaul Mackerrasquiet_cmd_copy_zlibheader = COPY    $@
9067ccd2fcSSegher Boessenkool      cmd_copy_zlibheader = sed "s@<linux/\([^>]*\).*@\"\1\"@" $< > $@
9194b212c2SPaul Mackerras# stddef.h for NULL
9294b212c2SPaul Mackerrasquiet_cmd_copy_zliblinuxheader = COPY    $@
9367ccd2fcSSegher Boessenkool      cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@
9494b212c2SPaul Mackerras
9594b212c2SPaul Mackerras$(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
9694b212c2SPaul Mackerras	$(call cmd,copy_zlib)
9794b212c2SPaul Mackerras
9894b212c2SPaul Mackerras$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
9994b212c2SPaul Mackerras	$(call cmd,copy_zlibheader)
10094b212c2SPaul Mackerras
10194b212c2SPaul Mackerras$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
10294b212c2SPaul Mackerras	$(call cmd,copy_zliblinuxheader)
10394b212c2SPaul Mackerras
104*9fffb55fSDavid Gibsonquiet_cmd_copy_libfdt = COPY    $@
105*9fffb55fSDavid Gibson      cmd_copy_libfdt = cp $< $@
106*9fffb55fSDavid Gibson
107*9fffb55fSDavid Gibson$(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
108*9fffb55fSDavid Gibson	$(call cmd,copy_libfdt)
109*9fffb55fSDavid Gibson
1102bf11819SPaul Mackerras$(obj)/empty.c:
1112bf11819SPaul Mackerras	@touch $@
11294b212c2SPaul Mackerras
113bafdb645SGeoff Levand$(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: $(srctree)/$(src)/%.S
1142bf11819SPaul Mackerras	@cp $< $@
1152bf11819SPaul Mackerras
1162bf11819SPaul Mackerrasclean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
117*9fffb55fSDavid Gibson		$(libfdt) $(libfdtheader) \
118b58a4575SKumar Gala		empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
11994b212c2SPaul Mackerras
12094b212c2SPaul Mackerrasquiet_cmd_bootcc = BOOTCC  $@
12194b212c2SPaul Mackerras      cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
12294b212c2SPaul Mackerras
12394b212c2SPaul Mackerrasquiet_cmd_bootas = BOOTAS  $@
12494b212c2SPaul Mackerras      cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
12594b212c2SPaul Mackerras
1262bf11819SPaul Mackerrasquiet_cmd_bootar = BOOTAR  $@
127235fd835SMilton Miller      cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
12894b212c2SPaul Mackerras
129*9fffb55fSDavid Gibson$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
130*9fffb55fSDavid Gibson	$(call if_changed_dep,bootcc)
131235fd835SMilton Miller$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
1322f0dfeaaSDavid Gibson	$(Q)mkdir -p $(dir $@)
13394b212c2SPaul Mackerras	$(call if_changed_dep,bootcc)
134235fd835SMilton Miller$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
1352f0dfeaaSDavid Gibson	$(Q)mkdir -p $(dir $@)
13694b212c2SPaul Mackerras	$(call if_changed_dep,bootas)
13794b212c2SPaul Mackerras
138235fd835SMilton Miller$(obj)/wrapper.a: $(obj-wlib) FORCE
139235fd835SMilton Miller	$(call if_changed,bootar)
14094b212c2SPaul Mackerras
141*9fffb55fSDavid Gibsonhostprogs-y	:= addnote addRamDisk hack-coff mktree
14266a45dd3SPaul Mackerras
143235fd835SMilton Millertargets		+= $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
144cd197ffcSDavid Gibsonextra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
145bafdb645SGeoff Levand		   $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
14694b212c2SPaul Mackerras
14725431333SGrant Likelydtstree		:= $(srctree)/$(src)/dts
14825431333SGrant Likely
1492bf11819SPaul Mackerraswrapper		:=$(srctree)/$(src)/wrapper
150*9fffb55fSDavid Gibsonwrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
151235fd835SMilton Miller			$(wrapper) FORCE
15294b212c2SPaul Mackerras
1532bf11819SPaul Mackerras#############
1542bf11819SPaul Mackerras# Bits for building various flavours of zImage
15594b212c2SPaul Mackerras
1562bf11819SPaul Mackerrasifneq ($(CROSS32_COMPILE),)
157dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS32_COMPILE)"
1582bf11819SPaul Mackerraselse
1592bf11819SPaul Mackerrasifneq ($(CROSS_COMPILE),)
160dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS_COMPILE)"
1612bf11819SPaul Mackerrasendif
1622bf11819SPaul Mackerrasendif
16394b212c2SPaul Mackerras
1649da82a6dSMilton Miller# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
1652bf11819SPaul Mackerrasquiet_cmd_wrap	= WRAP    $@
1669da82a6dSMilton Miller      cmd_wrap	=$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
1679da82a6dSMilton Miller		$(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
1682bf11819SPaul Mackerras
1692bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PSERIES)		+= zImage.pseries
1702bf11819SPaul Mackerrasimage-$(CONFIG_PPC_MAPLE)		+= zImage.pseries
171020533efSGeoff Levandimage-$(CONFIG_PPC_IBM_CELL_BLADE)	+= zImage.pseries
172595be948SGrant Likelyimage-$(CONFIG_PPC_PS3)			+= dtbImage.ps3
173c347b798SIshizaki Kouimage-$(CONFIG_PPC_CELLEB)		+= zImage.pseries
174def434c2SBenjamin Krillimage-$(CONFIG_PPC_CELL_QPACE)		+= zImage.pseries
1752bf11819SPaul Mackerrasimage-$(CONFIG_PPC_CHRP)		+= zImage.chrp
1767839af33SNicolas DETimage-$(CONFIG_PPC_EFIKA)		+= zImage.chrp
1772bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC)		+= zImage.pmac
17832dde0f9SJosh Boyerimage-$(CONFIG_PPC_HOLLY)		+= dtbImage.holly
179a7e695f6SDale Farnsworthimage-$(CONFIG_PPC_PRPMC2800)		+= dtbImage.prpmc2800
1800570d4edSStephen Rothwellimage-$(CONFIG_PPC_ISERIES)		+= zImage.iseries
181ac18c673SScott Woodimage-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
182ac18c673SScott Wood
18325431333SGrant Likely#
18425431333SGrant Likely# Targets which embed a device tree blob
18525431333SGrant Likely#
18625431333SGrant Likely# Theses are default targets to build images which embed device tree blobs.
18725431333SGrant Likely# They are only required on boards which do not have FDT support in firmware.
1882a94739cSNick Andrew# Boards with newish u-boot firmware can use the uImage target above
18925431333SGrant Likely#
19025431333SGrant Likely
19125431333SGrant Likely# Board ports in arch/powerpc/platform/40x/Kconfig
192595be948SGrant Likelyimage-$(CONFIG_EP405)			+= dtbImage.ep405
19325431333SGrant Likelyimage-$(CONFIG_WALNUT)			+= treeImage.walnut
19494c73a8fSJosh Boyerimage-$(CONFIG_ACADIA)			+= cuImage.acadia
19525431333SGrant Likely
19625431333SGrant Likely# Board ports in arch/powerpc/platform/44x/Kconfig
197f6dfc805SDavid Gibsonimage-$(CONFIG_EBONY)			+= treeImage.ebony cuImage.ebony
198658e8170SJosh Boyerimage-$(CONFIG_BAMBOO)			+= treeImage.bamboo cuImage.bamboo
199b6014e15SGiuseppe Covielloimage-$(CONFIG_SAM440EP)		+= cuImage.sam440ep
200606d08bcSValentine Barshakimage-$(CONFIG_SEQUOIA)			+= cuImage.sequoia
201295e7427SValentine Barshakimage-$(CONFIG_RAINIER)			+= cuImage.rainier
2026bbc5476SHugh Blemingsimage-$(CONFIG_TAISHAN)			+= cuImage.taishan
2033de9c9cdSBenjamin Herrenschmidtimage-$(CONFIG_KATMAI)			+= cuImage.katmai
2041e12f3c5SSean MacLennanimage-$(CONFIG_WARP)			+= cuImage.warp
205d0a48c9fSJosh Boyerimage-$(CONFIG_YOSEMITE)		+= cuImage.yosemite
20694b212c2SPaul Mackerras
20725431333SGrant Likely# Board ports in arch/powerpc/platform/8xx/Kconfig
208efa58fbfSAdrian Bunkimage-$(CONFIG_MPC86XADS)		+= cuImage.mpc866ads
209efa58fbfSAdrian Bunkimage-$(CONFIG_MPC885ADS)		+= cuImage.mpc885ads
210595be948SGrant Likelyimage-$(CONFIG_PPC_EP88XC)		+= dtbImage.ep88xc
21125431333SGrant Likelyimage-$(CONFIG_PPC_ADDER875)		+= cuImage.adder875-uboot \
212595be948SGrant Likely					   dtbImage.adder875-redboot
21325431333SGrant Likely
21425431333SGrant Likely# Board ports in arch/powerpc/platform/52xx/Kconfig
215bfee95bbSGrant Likelyimage-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200 lite5200.dtb
216bfee95bbSGrant Likelyimage-$(CONFIG_PPC_LITE5200)		+= cuImage.lite5200b lite5200b.dtb
217bfee95bbSGrant Likelyimage-$(CONFIG_PPC_MEDIA5200)		+= cuImage.media5200 media5200.dtb
21825431333SGrant Likely
21925431333SGrant Likely# Board ports in arch/powerpc/platform/82xx/Kconfig
22025431333SGrant Likelyimage-$(CONFIG_MPC8272_ADS)		+= cuImage.mpc8272ads
22125431333SGrant Likelyimage-$(CONFIG_PQ2FADS)			+= cuImage.pq2fads
222595be948SGrant Likelyimage-$(CONFIG_EP8248E)			+= dtbImage.ep8248e
22325431333SGrant Likely
22425431333SGrant Likely# Board ports in arch/powerpc/platform/83xx/Kconfig
22525431333SGrant Likelyimage-$(CONFIG_MPC832x_MDS)		+= cuImage.mpc832x_mds
22625431333SGrant Likelyimage-$(CONFIG_MPC832x_RDB)		+= cuImage.mpc832x_rdb
22725431333SGrant Likelyimage-$(CONFIG_MPC834x_ITX)		+= cuImage.mpc8349emitx \
22825431333SGrant Likely					   cuImage.mpc8349emitxgp
22925431333SGrant Likelyimage-$(CONFIG_MPC834x_MDS)		+= cuImage.mpc834x_mds
23025431333SGrant Likelyimage-$(CONFIG_MPC836x_MDS)		+= cuImage.mpc836x_mds
23159d13f9dSBryan O'Donoghueimage-$(CONFIG_ASP834x)			+= dtbImage.asp834x-redboot
23225431333SGrant Likely
23325431333SGrant Likely# Board ports in arch/powerpc/platform/85xx/Kconfig
23425431333SGrant Likelyimage-$(CONFIG_MPC8540_ADS)		+= cuImage.mpc8540ads
23525431333SGrant Likelyimage-$(CONFIG_MPC8560_ADS)		+= cuImage.mpc8560ads
23625431333SGrant Likelyimage-$(CONFIG_MPC85xx_CDS)		+= cuImage.mpc8541cds \
23725431333SGrant Likely					   cuImage.mpc8548cds \
23825431333SGrant Likely					   cuImage.mpc8555cds
23925431333SGrant Likelyimage-$(CONFIG_MPC85xx_MDS)		+= cuImage.mpc8568mds
24025431333SGrant Likelyimage-$(CONFIG_MPC85xx_DS)		+= cuImage.mpc8544ds \
24125431333SGrant Likely					   cuImage.mpc8572ds
24225431333SGrant Likelyimage-$(CONFIG_TQM8540)			+= cuImage.tqm8540
24325431333SGrant Likelyimage-$(CONFIG_TQM8541)			+= cuImage.tqm8541
2446dd1b64aSWolfgang Grandeggerimage-$(CONFIG_TQM8548)			+= cuImage.tqm8548
24525431333SGrant Likelyimage-$(CONFIG_TQM8555)			+= cuImage.tqm8555
24625431333SGrant Likelyimage-$(CONFIG_TQM8560)			+= cuImage.tqm8560
247a72a6f53SPaul Gortmakerimage-$(CONFIG_SBC8548)			+= cuImage.sbc8548
248a72a6f53SPaul Gortmakerimage-$(CONFIG_SBC8560)			+= cuImage.sbc8560
249ff880112SAlexandr Smirnovimage-$(CONFIG_KSI8560)			+= cuImage.ksi8560
25025431333SGrant Likely
25125431333SGrant Likely# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
25225431333SGrant Likelyimage-$(CONFIG_STORCENTER)		+= cuImage.storcenter
25325431333SGrant Likelyimage-$(CONFIG_MPC7448HPC2)		+= cuImage.mpc7448hpc2
254c6ec08e0SRemi Machetimage-$(CONFIG_PPC_C2K)			+= cuImage.c2k
255b09c1644SScott Wood
2568f23735dSGerhard Pircher# Board port in arch/powerpc/platform/amigaone/Kconfig
2578f23735dSGerhard Pircherimage-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
2588f23735dSGerhard Pircher
2599216ad8cSPaul Mackerras# For 32-bit powermacs, build the COFF and miboot images
2609216ad8cSPaul Mackerras# as well as the ELF images.
2612bf11819SPaul Mackerrasifeq ($(CONFIG_PPC32),y)
2622bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC)	+= zImage.coff zImage.miboot
2632bf11819SPaul Mackerrasendif
26466a45dd3SPaul Mackerras
265c356aa45SGrant Likely# Allow extra targets to be added to the defconfig
266c356aa45SGrant Likelyimage-y	+= $(subst ",,$(CONFIG_EXTRA_TARGETS))
267c356aa45SGrant Likely
2685d7960ffSMilton Millerinitrd-  := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-))
269f6dfc805SDavid Gibsoninitrd-y := $(patsubst zImage%, zImage.initrd%, \
270595be948SGrant Likely		$(patsubst dtbImage%, dtbImage.initrd%, \
2715d1a0411SJohn Linn		$(patsubst simpleImage%, simpleImage.initrd%, \
2725d1a0411SJohn Linn		$(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
2739da82a6dSMilton Millerinitrd-y := $(filter-out $(image-y), $(initrd-y))
274235fd835SMilton Millertargets	+= $(image-y) $(initrd-y)
27594b212c2SPaul Mackerras
2769da82a6dSMilton Miller$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
2779da82a6dSMilton Miller
2789da82a6dSMilton Miller# Don't put the ramdisk on the pattern rule; when its missing make will try
2799da82a6dSMilton Miller# the pattern rule with less dependencies that also matches (even with the
2809da82a6dSMilton Miller# hard dependency listed).
28125431333SGrant Likely$(obj)/zImage.initrd.%: vmlinux $(wrapperbits)
28225431333SGrant Likely	$(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
2839da82a6dSMilton Miller
28425431333SGrant Likely$(obj)/zImage.%: vmlinux $(wrapperbits)
28525431333SGrant Likely	$(call if_changed,wrap,$*)
28625431333SGrant Likely
287595be948SGrant Likely# dtbImage% - a dtbImage is a zImage with an embedded device tree blob
288e04018e8SGrant Likely$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/%.dtb
289e04018e8SGrant Likely	$(call if_changed,wrap,$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
29025431333SGrant Likely
291e04018e8SGrant Likely$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/%.dtb
292e04018e8SGrant Likely	$(call if_changed,wrap,$*,,$(obj)/$*.dtb)
2939da82a6dSMilton Miller
2944bb09281STony Breeds# This cannot be in the root of $(src) as the zImage rule always adds a $(obj)
2954bb09281STony Breeds# prefix
2964bb09281STony Breeds$(obj)/vmlinux.strip: vmlinux
2974bb09281STony Breeds	$(STRIP) -s -R .comment $< -o $@
2984bb09281STony Breeds
299549e8152SPaul Mackerras# The iseries hypervisor won't take an ET_DYN executable, so this
300549e8152SPaul Mackerras# changes the type (byte 17) in the file to ET_EXEC (2).
3010570d4edSStephen Rothwell$(obj)/zImage.iseries: vmlinux
3020570d4edSStephen Rothwell	$(STRIP) -s -R .comment $< -o $@
303549e8152SPaul Mackerras	printf "\x02" | dd of=$@ conv=notrunc bs=1 seek=17
3040570d4edSStephen Rothwell
3059da82a6dSMilton Miller$(obj)/uImage: vmlinux $(wrapperbits)
3069da82a6dSMilton Miller	$(call if_changed,wrap,uboot)
3079da82a6dSMilton Miller
308a4292d7aSGrant Likely$(obj)/cuImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits)
309a4292d7aSGrant Likely	$(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
310a4292d7aSGrant Likely
311e04018e8SGrant Likely$(obj)/cuImage.%: vmlinux $(obj)/%.dtb $(wrapperbits)
312e04018e8SGrant Likely	$(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb)
3130fdd717eSScott Wood
314d2477b5cSGrant Likely$(obj)/simpleImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits)
315d2477b5cSGrant Likely	$(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
316d2477b5cSGrant Likely
317d2477b5cSGrant Likely$(obj)/simpleImage.%: vmlinux $(obj)/%.dtb $(wrapperbits)
318d2477b5cSGrant Likely	$(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb)
319d2477b5cSGrant Likely
320e04018e8SGrant Likely$(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits)
321e04018e8SGrant Likely	$(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz)
322f6dfc805SDavid Gibson
323e04018e8SGrant Likely$(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits)
324e04018e8SGrant Likely	$(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb)
325e04018e8SGrant Likely
326e04018e8SGrant Likely# Rule to build device tree blobs
327*9fffb55fSDavid GibsonDTC = $(objtree)/scripts/dtc/dtc
328*9fffb55fSDavid Gibson
329*9fffb55fSDavid Gibson$(obj)/%.dtb: $(dtstree)/%.dts
330*9fffb55fSDavid Gibson	$(DTC) -O dtb -o $(obj)/$*.dtb -b 0 $(DTS_FLAGS) $(dtstree)/$*.dts
3316a32d085SDavid Gibson
3324bb09281STony Breeds# If there isn't a platform selected then just strip the vmlinux.
3334bb09281STony Breedsifeq (,$(image-y))
3344bb09281STony Breedsimage-y := vmlinux.strip
3354bb09281STony Breedsendif
3364bb09281STony Breeds
3372bf11819SPaul Mackerras$(obj)/zImage:		$(addprefix $(obj)/, $(image-y))
3382bf11819SPaul Mackerras	@rm -f $@; ln $< $@
3392bf11819SPaul Mackerras$(obj)/zImage.initrd:	$(addprefix $(obj)/, $(initrd-y))
3402bf11819SPaul Mackerras	@rm -f $@; ln $< $@
34194b212c2SPaul Mackerras
342928370c6SAkinobu Mitainstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
34329f1aff2SGrant Likely	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
34466a45dd3SPaul Mackerras
3451383a34fSMilton Miller# anything not in $(targets)
346b58a4575SKumar Galaclean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \
347b58a4575SKumar Gala	zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \
348b58a4575SKumar Gala	zImage.iseries zImage.miboot zImage.pmac zImage.pseries \
349e04018e8SGrant Likely	otheros.bld *.dtb
3501383a34fSMilton Miller
3511383a34fSMilton Miller# clean up files cached by wrapper
3521383a34fSMilton Millerclean-kernel := vmlinux.strip vmlinux.bin
3531383a34fSMilton Millerclean-kernel += $(addsuffix .gz,$(clean-kernel))
3541383a34fSMilton Miller# If not absolute clean-files are relative to $(obj).
3551383a34fSMilton Millerclean-files += $(addprefix $(objtree)/, $(clean-kernel))
356773f76b1SDavid Woodhouse
357773f76b1SDavid WoodhouseWRAPPER_OBJDIR := /usr/lib/kernel-wrapper
358773f76b1SDavid WoodhouseWRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts
359773f76b1SDavid WoodhouseWRAPPER_BINDIR := /usr/sbin
360773f76b1SDavid WoodhouseINSTALL := install
361773f76b1SDavid Woodhouse
362773f76b1SDavid Woodhouseextra-installed		:= $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y))
363773f76b1SDavid Woodhousehostprogs-installed	:= $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs-y))
364773f76b1SDavid Woodhousewrapper-installed	:= $(DESTDIR)$(WRAPPER_BINDIR)/wrapper
365773f76b1SDavid Woodhousedts-installed		:= $(patsubst $(obj)/dts/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(obj)/dts/*.dts))
366773f76b1SDavid Woodhouse
367773f76b1SDavid Woodhouseall-installed		:= $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed)
368773f76b1SDavid Woodhouse
369773f76b1SDavid Woodhousequiet_cmd_mkdir           = MKDIR   $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
370773f76b1SDavid Woodhouse      cmd_mkdir           = mkdir -p $@
371773f76b1SDavid Woodhouse
372773f76b1SDavid Woodhousequiet_cmd_install	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@)
373773f76b1SDavid Woodhouse      cmd_install	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@
374773f76b1SDavid Woodhouse
375773f76b1SDavid Woodhousequiet_cmd_install_dts	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@)
376773f76b1SDavid Woodhouse      cmd_install_dts	  = $(INSTALL)  -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@
377773f76b1SDavid Woodhouse
378773f76b1SDavid Woodhousequiet_cmd_install_exe	  = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
379773f76b1SDavid Woodhouse      cmd_install_exe	  = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@
380773f76b1SDavid Woodhouse
381773f76b1SDavid Woodhousequiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@)
382773f76b1SDavid Woodhouse      cmd_install_wrapper = $(INSTALL)  -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\
383773f76b1SDavid Woodhouse				sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \
384773f76b1SDavid Woodhouse					  -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \
385773f76b1SDavid Woodhouse
386773f76b1SDavid Woodhouse
387773f76b1SDavid Woodhouse$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR):
388773f76b1SDavid Woodhouse	$(call cmd,mkdir)
389773f76b1SDavid Woodhouse
390773f76b1SDavid Woodhouse$(extra-installed)	: $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR)
391773f76b1SDavid Woodhouse	$(call cmd,install)
392773f76b1SDavid Woodhouse
393773f76b1SDavid Woodhouse$(hostprogs-installed)  : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR)
394773f76b1SDavid Woodhouse	$(call cmd,install_exe)
395773f76b1SDavid Woodhouse
396773f76b1SDavid Woodhouse$(dts-installed)	: $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR)
397773f76b1SDavid Woodhouse	$(call cmd,install_dts)
398773f76b1SDavid Woodhouse
399773f76b1SDavid Woodhouse$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR)
400773f76b1SDavid Woodhouse	$(call cmd,install_wrapper)
401773f76b1SDavid Woodhouse
402773f76b1SDavid Woodhouse$(obj)/bootwrapper_install: $(all-installed)
403773f76b1SDavid Woodhouse
404