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