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 362f0dfeaaSDavid GibsonBOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) -I$(srctree)/$(src)/libfdt 3794b212c2SPaul Mackerras 38bf2e70acSJosh Boyer$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405 39bf2e70acSJosh Boyer$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405 40bf2e70acSJosh Boyer$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405 41bf2e70acSJosh Boyer$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405 422e71cc0dSJosh Boyer$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405 43b9e4f176SGrant Likely$(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405 4460e41753SJosh Boyer 456bbc5476SHugh Blemings 462bf11819SPaul Mackerraszlib := inffast.c inflate.c inftrees.c 472bf11819SPaul Mackerraszlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h 482bf11819SPaul Mackerraszliblinuxheader := zlib.h zconf.h zutil.h 492bf11819SPaul Mackerras 50d25a9d66SDavid Gibson$(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ 51d25a9d66SDavid Gibson $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) 522bf11819SPaul Mackerras 532f0dfeaaSDavid Gibsonsrc-libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c 54430b01e8SDavid Gibsonsrc-wlib := string.S crt0.S stdio.c main.c \ 552f0dfeaaSDavid Gibson $(addprefix libfdt/,$(src-libfdt)) libfdt-wrapper.c \ 56ad9d2716SDavid Gibson ns16550.c serial.c simple_alloc.c div64.S util.S \ 572e601613SDavid Gibson gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ 58d0f53fafSScott Wood 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ 59bbc6fac3SScott Wood cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \ 60bbc6fac3SScott Wood fsl-soc.c mpc8xx.c pq2.c 613490cba5SJon Loeligersrc-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \ 62bafdb645SGeoff Levand cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ 63606d08bcSValentine Barshak ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ 6425431333SGrant Likely cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \ 6525431333SGrant Likely cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \ 6625431333SGrant Likely fixed-head.S ep88xc.c ep405.c \ 671e12f3c5SSean MacLennan cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \ 68d2477b5cSGrant Likely cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \ 69*59d13f9dSBryan O'Donoghue virtex405-head.S redboot-83xx.c 70cd197ffcSDavid Gibsonsrc-boot := $(src-wlib) $(src-plat) empty.c 712bf11819SPaul Mackerras 722bf11819SPaul Mackerrassrc-boot := $(addprefix $(obj)/, $(src-boot)) 732bf11819SPaul Mackerrasobj-boot := $(addsuffix .o, $(basename $(src-boot))) 742bf11819SPaul Mackerrasobj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) 752bf11819SPaul Mackerrasobj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) 762bf11819SPaul Mackerras 7794b212c2SPaul Mackerrasquiet_cmd_copy_zlib = COPY $@ 783ff6eeccSAdrian Bunk cmd_copy_zlib = sed "s@__used@@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ 7994b212c2SPaul Mackerras 8094b212c2SPaul Mackerrasquiet_cmd_copy_zlibheader = COPY $@ 8167ccd2fcSSegher Boessenkool cmd_copy_zlibheader = sed "s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ 8294b212c2SPaul Mackerras# stddef.h for NULL 8394b212c2SPaul Mackerrasquiet_cmd_copy_zliblinuxheader = COPY $@ 8467ccd2fcSSegher Boessenkool cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ 8594b212c2SPaul Mackerras 8694b212c2SPaul Mackerras$(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/% 8794b212c2SPaul Mackerras $(call cmd,copy_zlib) 8894b212c2SPaul Mackerras 8994b212c2SPaul Mackerras$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/% 9094b212c2SPaul Mackerras $(call cmd,copy_zlibheader) 9194b212c2SPaul Mackerras 9294b212c2SPaul Mackerras$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/% 9394b212c2SPaul Mackerras $(call cmd,copy_zliblinuxheader) 9494b212c2SPaul Mackerras 952bf11819SPaul Mackerras$(obj)/empty.c: 962bf11819SPaul Mackerras @touch $@ 9794b212c2SPaul Mackerras 98bafdb645SGeoff Levand$(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: $(srctree)/$(src)/%.S 992bf11819SPaul Mackerras @cp $< $@ 1002bf11819SPaul Mackerras 1012bf11819SPaul Mackerrasclean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \ 102b58a4575SKumar Gala empty.c zImage.coff.lds zImage.ps3.lds zImage.lds 10394b212c2SPaul Mackerras 10494b212c2SPaul Mackerrasquiet_cmd_bootcc = BOOTCC $@ 10594b212c2SPaul Mackerras cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< 10694b212c2SPaul Mackerras 10794b212c2SPaul Mackerrasquiet_cmd_bootas = BOOTAS $@ 10894b212c2SPaul Mackerras cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 10994b212c2SPaul Mackerras 1102bf11819SPaul Mackerrasquiet_cmd_bootar = BOOTAR $@ 111235fd835SMilton Miller cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ 11294b212c2SPaul Mackerras 113235fd835SMilton Miller$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE 1142f0dfeaaSDavid Gibson $(Q)mkdir -p $(dir $@) 11594b212c2SPaul Mackerras $(call if_changed_dep,bootcc) 116235fd835SMilton Miller$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE 1172f0dfeaaSDavid Gibson $(Q)mkdir -p $(dir $@) 11894b212c2SPaul Mackerras $(call if_changed_dep,bootas) 11994b212c2SPaul Mackerras 120235fd835SMilton Miller$(obj)/wrapper.a: $(obj-wlib) FORCE 121235fd835SMilton Miller $(call if_changed,bootar) 12294b212c2SPaul Mackerras 123e2dc87a1SDavid Gibsonhostprogs-y := addnote addRamDisk hack-coff mktree dtc 12466a45dd3SPaul Mackerras 125235fd835SMilton Millertargets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a) 126cd197ffcSDavid Gibsonextra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ 127bafdb645SGeoff Levand $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds 12894b212c2SPaul Mackerras 12925431333SGrant Likelydtstree := $(srctree)/$(src)/dts 13025431333SGrant Likely 1312bf11819SPaul Mackerraswrapper :=$(srctree)/$(src)/wrapper 132e2dc87a1SDavid Gibsonwrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree dtc) \ 133235fd835SMilton Miller $(wrapper) FORCE 13494b212c2SPaul Mackerras 1352bf11819SPaul Mackerras############# 136e2dc87a1SDavid Gibson# Bits for building dtc 137e2dc87a1SDavid Gibson# DTC_GENPARSER := 1 # Uncomment to rebuild flex/bison output 138e2dc87a1SDavid Gibson 139e2dc87a1SDavid Gibsondtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o srcpos.o checks.o 140e2dc87a1SDavid Gibsondtc-objs += dtc-lexer.lex.o dtc-parser.tab.o 141e2dc87a1SDavid Gibsondtc-objs := $(addprefix dtc-src/, $(dtc-objs)) 142e2dc87a1SDavid Gibson 143e2dc87a1SDavid Gibson# prerequisites on generated files needs to be explicit 144e2dc87a1SDavid Gibson$(obj)/dtc-src/dtc-parser.tab.o: $(obj)/dtc-src/dtc-parser.tab.c $(obj)/dtc-src/dtc-parser.tab.h 145e2dc87a1SDavid Gibson$(obj)/dtc-src/dtc-lexer.lex.o: $(obj)/dtc-src/dtc-lexer.lex.c $(obj)/dtc-src/dtc-parser.tab.h 146e2dc87a1SDavid Gibson 147e2dc87a1SDavid GibsonHOSTCFLAGS += -I$(src)/dtc-src/ -I$(src)/libfdt/ 148e2dc87a1SDavid Gibson 149e2dc87a1SDavid Gibsontargets += dtc-src/dtc-parser.tab.c 150e2dc87a1SDavid Gibsontargets += dtc-src/dtc-lexer.lex.c 151e2dc87a1SDavid Gibson 152e4ccde02SKumar Galaclean-files += dtc-src/dtc-parser.tab.h 153e4ccde02SKumar Gala 154e2dc87a1SDavid Gibsonifdef DTC_GENPARSER 155e2dc87a1SDavid GibsonBISON = bison 156e2dc87a1SDavid GibsonFLEX = flex 157e2dc87a1SDavid Gibson 158e2dc87a1SDavid Gibsonquiet_cmd_bison = BISON $@ 159e2dc87a1SDavid Gibson cmd_bison = $(BISON) -o$@ -d $<; cp $@ $@_shipped 160e2dc87a1SDavid Gibsonquiet_cmd_flex = FLEX $@ 161e2dc87a1SDavid Gibson cmd_flex = $(FLEX) -o$@ $<; cp $@ $@_shipped 162e2dc87a1SDavid Gibson 163e2dc87a1SDavid Gibson$(obj)/dtc-src/dtc-parser.tab.c: $(src)/dtc-src/dtc-parser.y FORCE 164e2dc87a1SDavid Gibson $(call if_changed,bison) 165e2dc87a1SDavid Gibson 166e2dc87a1SDavid Gibson$(obj)/dtc-src/dtc-parser.tab.h: $(obj)/dtc-src/dtc-parser.tab.c 167e2dc87a1SDavid Gibson 168e2dc87a1SDavid Gibson$(obj)/dtc-src/dtc-lexer.lex.c: $(src)/dtc-src/dtc-lexer.l FORCE 169e2dc87a1SDavid Gibson $(call if_changed,flex) 170e2dc87a1SDavid Gibsonendif 171e2dc87a1SDavid Gibson 172e2dc87a1SDavid Gibson############# 1732bf11819SPaul Mackerras# Bits for building various flavours of zImage 17494b212c2SPaul Mackerras 1752bf11819SPaul Mackerrasifneq ($(CROSS32_COMPILE),) 176dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS32_COMPILE)" 1772bf11819SPaul Mackerraselse 1782bf11819SPaul Mackerrasifneq ($(CROSS_COMPILE),) 179dcf90651SMichael EllermanCROSSWRAP := -C "$(CROSS_COMPILE)" 1802bf11819SPaul Mackerrasendif 1812bf11819SPaul Mackerrasendif 18294b212c2SPaul Mackerras 1839da82a6dSMilton Miller# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd 1842bf11819SPaul Mackerrasquiet_cmd_wrap = WRAP $@ 1859da82a6dSMilton Miller cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ 1869da82a6dSMilton Miller $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux 1872bf11819SPaul Mackerras 1882bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PSERIES) += zImage.pseries 1892bf11819SPaul Mackerrasimage-$(CONFIG_PPC_MAPLE) += zImage.pseries 190020533efSGeoff Levandimage-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries 191595be948SGrant Likelyimage-$(CONFIG_PPC_PS3) += dtbImage.ps3 192c347b798SIshizaki Kouimage-$(CONFIG_PPC_CELLEB) += zImage.pseries 1932bf11819SPaul Mackerrasimage-$(CONFIG_PPC_CHRP) += zImage.chrp 1947839af33SNicolas DETimage-$(CONFIG_PPC_EFIKA) += zImage.chrp 1952bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC) += zImage.pmac 196b0e80206SMark A. Greerimage-$(CONFIG_PPC_HOLLY) += zImage.holly 197a7e695f6SDale Farnsworthimage-$(CONFIG_PPC_PRPMC2800) += dtbImage.prpmc2800 1980570d4edSStephen Rothwellimage-$(CONFIG_PPC_ISERIES) += zImage.iseries 199ac18c673SScott Woodimage-$(CONFIG_DEFAULT_UIMAGE) += uImage 200ac18c673SScott Wood 20125431333SGrant Likely# 20225431333SGrant Likely# Targets which embed a device tree blob 20325431333SGrant Likely# 20425431333SGrant Likely# Theses are default targets to build images which embed device tree blobs. 20525431333SGrant Likely# They are only required on boards which do not have FDT support in firmware. 20625431333SGrant Likely# Boards with newish u-boot firmare can use the uImage target above 20725431333SGrant Likely# 20825431333SGrant Likely 20925431333SGrant Likely# Board ports in arch/powerpc/platform/40x/Kconfig 210595be948SGrant Likelyimage-$(CONFIG_EP405) += dtbImage.ep405 21125431333SGrant Likelyimage-$(CONFIG_WALNUT) += treeImage.walnut 21225431333SGrant Likely 21325431333SGrant Likely# Board ports in arch/powerpc/platform/44x/Kconfig 214f6dfc805SDavid Gibsonimage-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony 215658e8170SJosh Boyerimage-$(CONFIG_BAMBOO) += treeImage.bamboo cuImage.bamboo 216606d08bcSValentine Barshakimage-$(CONFIG_SEQUOIA) += cuImage.sequoia 217295e7427SValentine Barshakimage-$(CONFIG_RAINIER) += cuImage.rainier 2186bbc5476SHugh Blemingsimage-$(CONFIG_TAISHAN) += cuImage.taishan 2193de9c9cdSBenjamin Herrenschmidtimage-$(CONFIG_KATMAI) += cuImage.katmai 2201e12f3c5SSean MacLennanimage-$(CONFIG_WARP) += cuImage.warp 221d0a48c9fSJosh Boyerimage-$(CONFIG_YOSEMITE) += cuImage.yosemite 22294b212c2SPaul Mackerras 22325431333SGrant Likely# Board ports in arch/powerpc/platform/8xx/Kconfig 22425431333SGrant Likelyimage-$(CONFIG_PPC_MPC86XADS) += cuImage.mpc866ads 22525431333SGrant Likelyimage-$(CONFIG_PPC_MPC885ADS) += cuImage.mpc885ads 226595be948SGrant Likelyimage-$(CONFIG_PPC_EP88XC) += dtbImage.ep88xc 22725431333SGrant Likelyimage-$(CONFIG_PPC_ADDER875) += cuImage.adder875-uboot \ 228595be948SGrant Likely dtbImage.adder875-redboot 22925431333SGrant Likely 23025431333SGrant Likely# Board ports in arch/powerpc/platform/52xx/Kconfig 23125431333SGrant Likelyimage-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 cuImage.lite5200b 23225431333SGrant Likely 23325431333SGrant Likely# Board ports in arch/powerpc/platform/82xx/Kconfig 23425431333SGrant Likelyimage-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads 23525431333SGrant Likelyimage-$(CONFIG_PQ2FADS) += cuImage.pq2fads 236595be948SGrant Likelyimage-$(CONFIG_EP8248E) += dtbImage.ep8248e 23725431333SGrant Likely 23825431333SGrant Likely# Board ports in arch/powerpc/platform/83xx/Kconfig 23925431333SGrant Likelyimage-$(CONFIG_MPC832x_MDS) += cuImage.mpc832x_mds 24025431333SGrant Likelyimage-$(CONFIG_MPC832x_RDB) += cuImage.mpc832x_rdb 24125431333SGrant Likelyimage-$(CONFIG_MPC834x_ITX) += cuImage.mpc8349emitx \ 24225431333SGrant Likely cuImage.mpc8349emitxgp 24325431333SGrant Likelyimage-$(CONFIG_MPC834x_MDS) += cuImage.mpc834x_mds 24425431333SGrant Likelyimage-$(CONFIG_MPC836x_MDS) += cuImage.mpc836x_mds 245*59d13f9dSBryan O'Donoghueimage-$(CONFIG_ASP834x) += dtbImage.asp834x-redboot 24625431333SGrant Likely 24725431333SGrant Likely# Board ports in arch/powerpc/platform/85xx/Kconfig 24825431333SGrant Likelyimage-$(CONFIG_MPC8540_ADS) += cuImage.mpc8540ads 24925431333SGrant Likelyimage-$(CONFIG_MPC8560_ADS) += cuImage.mpc8560ads 25025431333SGrant Likelyimage-$(CONFIG_MPC85xx_CDS) += cuImage.mpc8541cds \ 25125431333SGrant Likely cuImage.mpc8548cds \ 25225431333SGrant Likely cuImage.mpc8555cds 25325431333SGrant Likelyimage-$(CONFIG_MPC85xx_MDS) += cuImage.mpc8568mds 25425431333SGrant Likelyimage-$(CONFIG_MPC85xx_DS) += cuImage.mpc8544ds \ 25525431333SGrant Likely cuImage.mpc8572ds 25625431333SGrant Likelyimage-$(CONFIG_TQM8540) += cuImage.tqm8540 25725431333SGrant Likelyimage-$(CONFIG_TQM8541) += cuImage.tqm8541 25825431333SGrant Likelyimage-$(CONFIG_TQM8555) += cuImage.tqm8555 25925431333SGrant Likelyimage-$(CONFIG_TQM8560) += cuImage.tqm8560 260a72a6f53SPaul Gortmakerimage-$(CONFIG_SBC8548) += cuImage.sbc8548 261a72a6f53SPaul Gortmakerimage-$(CONFIG_SBC8560) += cuImage.sbc8560 262ff880112SAlexandr Smirnovimage-$(CONFIG_KSI8560) += cuImage.ksi8560 26325431333SGrant Likely 26425431333SGrant Likely# Board ports in arch/powerpc/platform/embedded6xx/Kconfig 26525431333SGrant Likelyimage-$(CONFIG_STORCENTER) += cuImage.storcenter 26625431333SGrant Likelyimage-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2 267b09c1644SScott Wood 2689216ad8cSPaul Mackerras# For 32-bit powermacs, build the COFF and miboot images 2699216ad8cSPaul Mackerras# as well as the ELF images. 2702bf11819SPaul Mackerrasifeq ($(CONFIG_PPC32),y) 2712bf11819SPaul Mackerrasimage-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot 2722bf11819SPaul Mackerrasendif 27366a45dd3SPaul Mackerras 2745d7960ffSMilton Millerinitrd- := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-)) 275f6dfc805SDavid Gibsoninitrd-y := $(patsubst zImage%, zImage.initrd%, \ 276595be948SGrant Likely $(patsubst dtbImage%, dtbImage.initrd%, \ 277595be948SGrant Likely $(patsubst treeImage%, treeImage.initrd%, $(image-y)))) 2789da82a6dSMilton Millerinitrd-y := $(filter-out $(image-y), $(initrd-y)) 279235fd835SMilton Millertargets += $(image-y) $(initrd-y) 28094b212c2SPaul Mackerras 2819da82a6dSMilton Miller$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz 2829da82a6dSMilton Miller 2839da82a6dSMilton Miller# Don't put the ramdisk on the pattern rule; when its missing make will try 2849da82a6dSMilton Miller# the pattern rule with less dependencies that also matches (even with the 2859da82a6dSMilton Miller# hard dependency listed). 28625431333SGrant Likely$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) 28725431333SGrant Likely $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz) 2889da82a6dSMilton Miller 28925431333SGrant Likely$(obj)/zImage.%: vmlinux $(wrapperbits) 29025431333SGrant Likely $(call if_changed,wrap,$*) 29125431333SGrant Likely 292595be948SGrant Likely# dtbImage% - a dtbImage is a zImage with an embedded device tree blob 293e04018e8SGrant Likely$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/%.dtb 294e04018e8SGrant Likely $(call if_changed,wrap,$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 29525431333SGrant Likely 296e04018e8SGrant Likely$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/%.dtb 297e04018e8SGrant Likely $(call if_changed,wrap,$*,,$(obj)/$*.dtb) 2989da82a6dSMilton Miller 2994bb09281STony Breeds# This cannot be in the root of $(src) as the zImage rule always adds a $(obj) 3004bb09281STony Breeds# prefix 3014bb09281STony Breeds$(obj)/vmlinux.strip: vmlinux 3024bb09281STony Breeds $(STRIP) -s -R .comment $< -o $@ 3034bb09281STony Breeds 3040570d4edSStephen Rothwell$(obj)/zImage.iseries: vmlinux 3050570d4edSStephen Rothwell $(STRIP) -s -R .comment $< -o $@ 3060570d4edSStephen Rothwell 3079da82a6dSMilton Miller$(obj)/uImage: vmlinux $(wrapperbits) 3089da82a6dSMilton Miller $(call if_changed,wrap,uboot) 3099da82a6dSMilton Miller 310e04018e8SGrant Likely$(obj)/cuImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) 311e04018e8SGrant Likely $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb) 3120fdd717eSScott Wood 313d2477b5cSGrant Likely$(obj)/simpleImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) 314d2477b5cSGrant Likely $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 315d2477b5cSGrant Likely 316d2477b5cSGrant Likely$(obj)/simpleImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) 317d2477b5cSGrant Likely $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb) 318d2477b5cSGrant Likely 319e04018e8SGrant Likely$(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) 320e04018e8SGrant Likely $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 321f6dfc805SDavid Gibson 322e04018e8SGrant Likely$(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) 323e04018e8SGrant Likely $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb) 324e04018e8SGrant Likely 325e04018e8SGrant Likely# Rule to build device tree blobs 326e04018e8SGrant Likely$(obj)/%.dtb: $(dtstree)/%.dts $(obj)/dtc 327e04018e8SGrant Likely $(obj)/dtc -O dtb -o $(obj)/$*.dtb -b 0 $(DTS_FLAGS) $(dtstree)/$*.dts 3286a32d085SDavid Gibson 3294bb09281STony Breeds# If there isn't a platform selected then just strip the vmlinux. 3304bb09281STony Breedsifeq (,$(image-y)) 3314bb09281STony Breedsimage-y := vmlinux.strip 3324bb09281STony Breedsendif 3334bb09281STony Breeds 3342bf11819SPaul Mackerras$(obj)/zImage: $(addprefix $(obj)/, $(image-y)) 3352bf11819SPaul Mackerras @rm -f $@; ln $< $@ 3362bf11819SPaul Mackerras$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y)) 3372bf11819SPaul Mackerras @rm -f $@; ln $< $@ 33894b212c2SPaul Mackerras 339928370c6SAkinobu Mitainstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y)) 3402bf11819SPaul Mackerras sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $< 34166a45dd3SPaul Mackerras 3421383a34fSMilton Miller# anything not in $(targets) 343b58a4575SKumar Galaclean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \ 344b58a4575SKumar Gala zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \ 345b58a4575SKumar Gala zImage.iseries zImage.miboot zImage.pmac zImage.pseries \ 346e04018e8SGrant Likely otheros.bld *.dtb 3471383a34fSMilton Miller 3481383a34fSMilton Miller# clean up files cached by wrapper 3491383a34fSMilton Millerclean-kernel := vmlinux.strip vmlinux.bin 3501383a34fSMilton Millerclean-kernel += $(addsuffix .gz,$(clean-kernel)) 3511383a34fSMilton Miller# If not absolute clean-files are relative to $(obj). 3521383a34fSMilton Millerclean-files += $(addprefix $(objtree)/, $(clean-kernel)) 353773f76b1SDavid Woodhouse 354773f76b1SDavid WoodhouseWRAPPER_OBJDIR := /usr/lib/kernel-wrapper 355773f76b1SDavid WoodhouseWRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts 356773f76b1SDavid WoodhouseWRAPPER_BINDIR := /usr/sbin 357773f76b1SDavid WoodhouseINSTALL := install 358773f76b1SDavid Woodhouse 359773f76b1SDavid Woodhouseextra-installed := $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y)) 360773f76b1SDavid Woodhousehostprogs-installed := $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs-y)) 361773f76b1SDavid Woodhousewrapper-installed := $(DESTDIR)$(WRAPPER_BINDIR)/wrapper 362773f76b1SDavid Woodhousedts-installed := $(patsubst $(obj)/dts/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(obj)/dts/*.dts)) 363773f76b1SDavid Woodhouse 364773f76b1SDavid Woodhouseall-installed := $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed) 365773f76b1SDavid Woodhouse 366773f76b1SDavid Woodhousequiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 367773f76b1SDavid Woodhouse cmd_mkdir = mkdir -p $@ 368773f76b1SDavid Woodhouse 369773f76b1SDavid Woodhousequiet_cmd_install = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@) 370773f76b1SDavid Woodhouse cmd_install = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@ 371773f76b1SDavid Woodhouse 372773f76b1SDavid Woodhousequiet_cmd_install_dts = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@) 373773f76b1SDavid Woodhouse cmd_install_dts = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@ 374773f76b1SDavid Woodhouse 375773f76b1SDavid Woodhousequiet_cmd_install_exe = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@) 376773f76b1SDavid Woodhouse cmd_install_exe = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@ 377773f76b1SDavid Woodhouse 378773f76b1SDavid Woodhousequiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@) 379773f76b1SDavid Woodhouse cmd_install_wrapper = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\ 380773f76b1SDavid Woodhouse sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \ 381773f76b1SDavid Woodhouse -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \ 382773f76b1SDavid Woodhouse 383773f76b1SDavid Woodhouse 384773f76b1SDavid Woodhouse$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR): 385773f76b1SDavid Woodhouse $(call cmd,mkdir) 386773f76b1SDavid Woodhouse 387773f76b1SDavid Woodhouse$(extra-installed) : $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR) 388773f76b1SDavid Woodhouse $(call cmd,install) 389773f76b1SDavid Woodhouse 390773f76b1SDavid Woodhouse$(hostprogs-installed) : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR) 391773f76b1SDavid Woodhouse $(call cmd,install_exe) 392773f76b1SDavid Woodhouse 393773f76b1SDavid Woodhouse$(dts-installed) : $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR) 394773f76b1SDavid Woodhouse $(call cmd,install_dts) 395773f76b1SDavid Woodhouse 396773f76b1SDavid Woodhouse$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR) 397773f76b1SDavid Woodhouse $(call cmd,install_wrapper) 398773f76b1SDavid Woodhouse 399773f76b1SDavid Woodhouse$(obj)/bootwrapper_install: $(all-installed) 400773f76b1SDavid Woodhouse 401