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