1# SPDX-License-Identifier: GPL-2.0 2# 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 may be 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 15# 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. 17# 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 21all: $(obj)/zImage 22 23ifdef CROSS32_COMPILE 24ifdef CONFIG_CC_IS_CLANG 25 BOOTCC := $(CROSS32_COMPILE)clang 26else 27 BOOTCC := $(CROSS32_COMPILE)gcc 28endif 29 BOOTAR := $(CROSS32_COMPILE)ar 30else 31 BOOTCC := $(CC) 32 BOOTAR := $(AR) 33endif 34 35BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 36 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \ 37 $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \ 38 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ 39 $(LINUXINCLUDE) 40 41ifdef CONFIG_PPC64_BOOT_WRAPPER 42BOOTCFLAGS += -m64 43else 44BOOTCFLAGS += -m32 45endif 46 47BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) 48 49ifdef CONFIG_CPU_BIG_ENDIAN 50BOOTCFLAGS += -mbig-endian 51else 52BOOTCFLAGS += -mlittle-endian 53BOOTCFLAGS += $(call cc-option,-mabi=elfv2) 54endif 55 56BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc 57 58BOOTARFLAGS := -crD 59 60ifdef CONFIG_CC_IS_CLANG 61BOOTCFLAGS += $(CLANG_FLAGS) 62BOOTAFLAGS += $(CLANG_FLAGS) 63endif 64 65ifdef CONFIG_DEBUG_INFO 66BOOTCFLAGS += -g 67endif 68 69ifeq ($(call cc-option-yn, -fstack-protector),y) 70BOOTCFLAGS += -fno-stack-protector 71endif 72 73BOOTCFLAGS += -include $(srctree)/include/linux/compiler_attributes.h 74BOOTCFLAGS += -I$(objtree)/$(obj) -I$(srctree)/$(obj) 75 76DTC_FLAGS ?= -p 1024 77 78$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405 79$(obj)/ebony.o: BOOTCFLAGS += -mcpu=440 80$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405 81$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440 82$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440 83$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405 84$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405 85$(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405 86$(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405 87 88# The pre-boot decompressors pull in a lot of kernel headers and other source 89# files. This creates a bit of a dependency headache since we need to copy 90# these files into the build dir, fix up any includes and ensure that dependent 91# files are copied in the right order. 92 93# these need to be seperate variables because they are copied out of different 94# directories in the kernel tree. Sure you COULd merge them, but it's a 95# cure-is-worse-than-disease situation. 96zlib-decomp-$(CONFIG_KERNEL_GZIP) := decompress_inflate.c 97zlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c 98zlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h infutil.h 99zliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h 100 101$(addprefix $(obj)/, decompress.o): \ 102 $(addprefix $(obj)/,$(zlib-decomp-y)) 103 104$(addprefix $(obj)/, $(zlib-decomp-y)): \ 105 $(addprefix $(obj)/,$(zliblinuxheader-y)) \ 106 $(addprefix $(obj)/,$(zlibheader-y)) \ 107 $(addprefix $(obj)/,$(zlib-y)) 108 109$(addprefix $(obj)/,$(zlib-y)): \ 110 $(addprefix $(obj)/,$(zliblinuxheader-y)) \ 111 $(addprefix $(obj)/,$(zlibheader-y)) 112 113libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c 114libfdtheader := fdt.h libfdt.h libfdt_internal.h 115 116$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \ 117 treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \ 118 $(addprefix $(obj)/,$(libfdtheader)) 119 120src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \ 121 $(libfdt) libfdt-wrapper.c \ 122 ns16550.c serial.c simple_alloc.c div64.S util.S \ 123 elf_util.c $(zlib-y) devtree.c stdlib.c \ 124 oflib.c ofconsole.c cuboot.c 125 126src-wlib-$(CONFIG_PPC_MPC52xx) += mpc52xx-psc.c 127src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S opal.c 128ifndef CONFIG_PPC64_BOOT_WRAPPER 129src-wlib-y += crtsavres.S 130endif 131src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c 132src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c 133src-wlib-$(CONFIG_PPC_8xx) += mpc8xx.c planetcore.c fsl-soc.c 134src-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c 135src-wlib-$(CONFIG_EMBEDDED6xx) += ugecon.c fsl-soc.c 136src-wlib-$(CONFIG_CPM) += cpm-serial.c 137 138src-plat-y := of.c epapr.c 139src-plat-$(CONFIG_40x) += fixed-head.S cuboot-hotfoot.c \ 140 cuboot-acadia.c \ 141 cuboot-kilauea.c simpleboot.c 142src-plat-$(CONFIG_44x) += treeboot-ebony.c cuboot-ebony.c treeboot-bamboo.c \ 143 cuboot-bamboo.c cuboot-sam440ep.c \ 144 cuboot-sequoia.c cuboot-rainier.c \ 145 cuboot-taishan.c cuboot-katmai.c \ 146 cuboot-warp.c cuboot-yosemite.c \ 147 treeboot-iss4xx.c treeboot-currituck.c \ 148 treeboot-akebono.c \ 149 simpleboot.c fixed-head.S 150src-plat-$(CONFIG_PPC_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c 151src-plat-$(CONFIG_PPC_MPC52xx) += cuboot-52xx.c 152src-plat-$(CONFIG_PPC_82xx) += cuboot-pq2.c fixed-head.S ep8248e.c cuboot-824x.c 153src-plat-$(CONFIG_PPC_83xx) += cuboot-83xx.c fixed-head.S redboot-83xx.c 154src-plat-$(CONFIG_FSL_SOC_BOOKE) += cuboot-85xx.c cuboot-85xx-cpm2.c 155src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \ 156 gamecube-head.S gamecube.c \ 157 wii-head.S wii.c holly.c \ 158 fixed-head.S mvme5100.c 159src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c 160src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c 161src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c 162src-plat-$(CONFIG_PPC_PSERIES) += pseries-head.S 163src-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S 164src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S 165src-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c 166 167src-plat-$(CONFIG_PPC_MICROWATT) += fixed-head.S microwatt.c 168 169src-wlib := $(sort $(src-wlib-y)) 170src-plat := $(sort $(src-plat-y)) 171src-boot := $(src-wlib) $(src-plat) empty.c 172 173src-boot := $(addprefix $(obj)/, $(src-boot)) 174obj-boot := $(addsuffix .o, $(basename $(src-boot))) 175obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) 176obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) 177obj-plat: $(libfdt) 178 179quiet_cmd_copy_kern_src = COPY $@ 180 cmd_copy_kern_src = sed -f $(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@ 181 182$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/% 183 $(call cmd,copy_kern_src) 184 185$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/% 186 $(call cmd,copy_kern_src) 187 188$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/% 189 $(call cmd,copy_kern_src) 190 191$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/% 192 $(call cmd,copy_kern_src) 193 194quiet_cmd_copy_libfdt = COPY $@ 195 cmd_copy_libfdt = cp $< $@ 196 197$(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/% 198 $(call cmd,copy_libfdt) 199 200$(obj)/empty.c: 201 $(Q)touch $@ 202 203$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S 204 $(Q)cp $< $@ 205 206clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \ 207 $(zlib-decomp-) $(libfdt) $(libfdtheader) \ 208 empty.c zImage.coff.lds zImage.ps3.lds zImage.lds 209 210quiet_cmd_bootcc = BOOTCC $@ 211 cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< 212 213quiet_cmd_bootas = BOOTAS $@ 214 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 215 216quiet_cmd_bootar = BOOTAR $@ 217 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@ 218 219$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE 220 $(call if_changed_dep,bootcc) 221$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE 222 $(Q)mkdir -p $(dir $@) 223 $(call if_changed_dep,bootcc) 224$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE 225 $(Q)mkdir -p $(dir $@) 226 $(call if_changed_dep,bootas) 227 228$(obj)/wrapper.a: $(obj-wlib) FORCE 229 $(call if_changed,bootar) 230 231hostprogs := addnote hack-coff mktree 232 233targets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a) zImage.lds 234extra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ 235 $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds 236 237dtstree := $(srctree)/$(src)/dts 238 239wrapper :=$(srctree)/$(src)/wrapper 240wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \ 241 $(wrapper) FORCE 242 243############# 244# Bits for building various flavours of zImage 245 246ifneq ($(CROSS32_COMPILE),) 247CROSSWRAP := -C "$(CROSS32_COMPILE)" 248else 249ifneq ($(CROSS_COMPILE),) 250CROSSWRAP := -C "$(CROSS_COMPILE)" 251endif 252endif 253 254compressor-$(CONFIG_KERNEL_GZIP) := gz 255compressor-$(CONFIG_KERNEL_XZ) := xz 256compressor-$(CONFIG_KERNEL_LZMA) := lzma 257compressor-$(CONFIG_KERNEL_LZO) := lzo 258 259# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd 260quiet_cmd_wrap = WRAP $@ 261 cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \ 262 $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \ 263 vmlinux 264 265image-$(CONFIG_PPC_PSERIES) += zImage.pseries 266image-$(CONFIG_PPC_POWERNV) += zImage.pseries 267image-$(CONFIG_PPC_MAPLE) += zImage.maple 268image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries 269image-$(CONFIG_PPC_PS3) += dtbImage.ps3 270image-$(CONFIG_PPC_CHRP) += zImage.chrp 271image-$(CONFIG_PPC_EFIKA) += zImage.chrp 272image-$(CONFIG_PPC_PMAC) += zImage.pmac 273image-$(CONFIG_PPC_HOLLY) += dtbImage.holly 274image-$(CONFIG_DEFAULT_UIMAGE) += uImage 275image-$(CONFIG_EPAPR_BOOT) += zImage.epapr 276 277# 278# Targets which embed a device tree blob 279# 280# Theses are default targets to build images which embed device tree blobs. 281# They are only required on boards which do not have FDT support in firmware. 282# Boards with newish u-boot firmware can use the uImage target above 283# 284 285# Board ports in arch/powerpc/platform/40x/Kconfig 286image-$(CONFIG_HOTFOOT) += cuImage.hotfoot 287image-$(CONFIG_ACADIA) += cuImage.acadia 288image-$(CONFIG_OBS600) += uImage.obs600 289 290# Board ports in arch/powerpc/platform/44x/Kconfig 291image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony 292image-$(CONFIG_BAMBOO) += treeImage.bamboo cuImage.bamboo 293image-$(CONFIG_SAM440EP) += cuImage.sam440ep 294image-$(CONFIG_SEQUOIA) += cuImage.sequoia 295image-$(CONFIG_RAINIER) += cuImage.rainier 296image-$(CONFIG_TAISHAN) += cuImage.taishan 297image-$(CONFIG_KATMAI) += cuImage.katmai 298image-$(CONFIG_WARP) += cuImage.warp 299image-$(CONFIG_YOSEMITE) += cuImage.yosemite 300image-$(CONFIG_ISS4xx) += treeImage.iss4xx \ 301 treeImage.iss4xx-mpic 302image-$(CONFIG_CURRITUCK) += treeImage.currituck 303image-$(CONFIG_AKEBONO) += treeImage.akebono 304 305# Board ports in arch/powerpc/platform/8xx/Kconfig 306image-$(CONFIG_MPC86XADS) += cuImage.mpc866ads 307image-$(CONFIG_MPC885ADS) += cuImage.mpc885ads 308image-$(CONFIG_PPC_EP88XC) += dtbImage.ep88xc 309image-$(CONFIG_PPC_ADDER875) += cuImage.adder875-uboot \ 310 dtbImage.adder875-redboot 311 312# Board ports in arch/powerpc/platform/52xx/Kconfig 313image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 314image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b 315image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200 316 317# Board ports in arch/powerpc/platform/82xx/Kconfig 318image-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads 319image-$(CONFIG_PQ2FADS) += cuImage.pq2fads 320image-$(CONFIG_EP8248E) += dtbImage.ep8248e 321 322# Board ports in arch/powerpc/platform/83xx/Kconfig 323image-$(CONFIG_MPC832x_MDS) += cuImage.mpc832x_mds 324image-$(CONFIG_MPC832x_RDB) += cuImage.mpc832x_rdb 325image-$(CONFIG_MPC834x_ITX) += cuImage.mpc8349emitx \ 326 cuImage.mpc8349emitxgp 327image-$(CONFIG_MPC834x_MDS) += cuImage.mpc834x_mds 328image-$(CONFIG_MPC836x_MDS) += cuImage.mpc836x_mds 329image-$(CONFIG_ASP834x) += dtbImage.asp834x-redboot 330 331# Board ports in arch/powerpc/platform/85xx/Kconfig 332image-$(CONFIG_MPC8540_ADS) += cuImage.mpc8540ads 333image-$(CONFIG_MPC8560_ADS) += cuImage.mpc8560ads 334image-$(CONFIG_MPC85xx_CDS) += cuImage.mpc8541cds \ 335 cuImage.mpc8548cds_32b \ 336 cuImage.mpc8555cds 337image-$(CONFIG_MPC85xx_MDS) += cuImage.mpc8568mds 338image-$(CONFIG_MPC85xx_DS) += cuImage.mpc8544ds \ 339 cuImage.mpc8572ds 340image-$(CONFIG_TQM8540) += cuImage.tqm8540 341image-$(CONFIG_TQM8541) += cuImage.tqm8541 342image-$(CONFIG_TQM8548) += cuImage.tqm8548 343image-$(CONFIG_TQM8555) += cuImage.tqm8555 344image-$(CONFIG_TQM8560) += cuImage.tqm8560 345image-$(CONFIG_KSI8560) += cuImage.ksi8560 346 347# Board ports in arch/powerpc/platform/86xx/Kconfig 348image-$(CONFIG_MVME7100) += dtbImage.mvme7100 349 350# Board ports in arch/powerpc/platform/embedded6xx/Kconfig 351image-$(CONFIG_STORCENTER) += cuImage.storcenter 352image-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2 353image-$(CONFIG_GAMECUBE) += dtbImage.gamecube 354image-$(CONFIG_WII) += dtbImage.wii 355image-$(CONFIG_MVME5100) += dtbImage.mvme5100 356 357# Board port in arch/powerpc/platform/amigaone/Kconfig 358image-$(CONFIG_AMIGAONE) += cuImage.amigaone 359 360image-$(CONFIG_PPC_MICROWATT) += dtbImage.microwatt 361 362# For 32-bit powermacs, build the COFF and miboot images 363# as well as the ELF images. 364ifdef CONFIG_PPC32 365image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot 366endif 367 368# Allow extra targets to be added to the defconfig 369image-y += $(subst ",,$(CONFIG_EXTRA_TARGETS)) 370 371initrd- := $(patsubst zImage%, zImage.initrd%, $(image-)) 372initrd-y := $(patsubst zImage%, zImage.initrd%, \ 373 $(patsubst dtbImage%, dtbImage.initrd%, \ 374 $(patsubst simpleImage%, simpleImage.initrd%, \ 375 $(patsubst treeImage%, treeImage.initrd%, $(image-y))))) 376initrd-y := $(filter-out $(image-y), $(initrd-y)) 377targets += $(image-y) $(initrd-y) 378targets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \ 379 $(patsubst $(x).%, dts/%.dtb, $(filter $(x).%, $(image-y)))) 380targets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \ 381 $(patsubst $(x).%, dts/fsl/%.dtb, $(filter $(x).%, $(image-y)))) 382 383$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz 384 385# Don't put the ramdisk on the pattern rule; when its missing make will try 386# the pattern rule with less dependencies that also matches (even with the 387# hard dependency listed). 388$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) FORCE 389 $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz) 390 391$(addprefix $(obj)/, $(sort $(filter zImage.%, $(image-y)))): vmlinux $(wrapperbits) FORCE 392 $(call if_changed,wrap,$(subst $(obj)/zImage.,,$@)) 393 394# dtbImage% - a dtbImage is a zImage with an embedded device tree blob 395$(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE 396 $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 397 398$(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE 399 $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb) 400 401# This cannot be in the root of $(src) as the zImage rule always adds a $(obj) 402# prefix 403$(obj)/vmlinux.strip: vmlinux 404 $(STRIP) -s -R .comment $< -o $@ 405 406$(obj)/uImage: vmlinux $(wrapperbits) FORCE 407 $(call if_changed,wrap,uboot) 408 409$(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 410 $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 411 412$(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 413 $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb) 414 415$(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 416 $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 417 418$(obj)/cuImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 419 $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb) 420 421$(obj)/simpleImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 422 $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 423 424$(obj)/simpleImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 425 $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb) 426 427$(obj)/treeImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 428 $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 429 430$(obj)/treeImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 431 $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb) 432 433# Needed for the above targets to work with dts/fsl/ files 434$(obj)/dts/%.dtb: $(obj)/dts/fsl/%.dtb 435 @cp $< $@ 436 437# If there isn't a platform selected then just strip the vmlinux. 438ifeq (,$(image-y)) 439image-y := vmlinux.strip 440endif 441 442$(obj)/zImage: $(addprefix $(obj)/, $(image-y)) 443 $(Q)rm -f $@; ln $< $@ 444$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y)) 445 $(Q)rm -f $@; ln $< $@ 446 447# anything not in $(targets) 448clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \ 449 zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \ 450 zImage.miboot zImage.pmac zImage.pseries \ 451 zImage.maple simpleImage.* otheros.bld 452 453# clean up files cached by wrapper 454clean-kernel-base := vmlinux.strip vmlinux.bin 455clean-kernel := $(addsuffix .gz,$(clean-kernel-base)) 456clean-kernel += $(addsuffix .xz,$(clean-kernel-base)) 457# If not absolute clean-files are relative to $(obj). 458clean-files += $(addprefix $(objtree)/, $(clean-kernel)) 459 460WRAPPER_OBJDIR := /usr/lib/kernel-wrapper 461WRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts 462WRAPPER_BINDIR := /usr/sbin 463INSTALL := install 464 465extra-installed := $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y)) 466hostprogs-installed := $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs)) 467wrapper-installed := $(DESTDIR)$(WRAPPER_BINDIR)/wrapper 468dts-installed := $(patsubst $(dtstree)/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(dtstree)/*.dts)) 469 470all-installed := $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed) 471 472quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 473 cmd_mkdir = mkdir -p $@ 474 475quiet_cmd_install = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@) 476 cmd_install = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@ 477 478quiet_cmd_install_dts = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@) 479 cmd_install_dts = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@ 480 481quiet_cmd_install_exe = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@) 482 cmd_install_exe = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@ 483 484quiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@) 485 cmd_install_wrapper = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\ 486 sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \ 487 -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \ 488 489 490$(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR): 491 $(call cmd,mkdir) 492 493$(extra-installed) : $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR) 494 $(call cmd,install) 495 496$(hostprogs-installed) : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR) 497 $(call cmd,install_exe) 498 499$(dts-installed) : $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR) 500 $(call cmd,install_dts) 501 502$(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR) 503 $(call cmd,install_wrapper) 504 505$(obj)/bootwrapper_install: $(all-installed) 506