Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Kbuild: centralize MKIMAGE and cmd_uimage definitions

All ARCHs have the same definition of MKIMAGE. Move it to Makefile.lib
to avoid duplication.

All ARCHs have similar definitions of cmd_uimage. Place a sufficiently
parameterized version in Makefile.lib to avoid duplication.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Acked-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Mike Frysinger <vapier@gentoo.org> [Blackfin]
Tested-by: Michal Simek <monstr@monstr.eu> [Microblaze]
Tested-by: Guan Xuetao <gxt@mprc.pku.edu.cn> [unicore32]
Signed-off-by: Michal Marek <mmarek@suse.cz>

authored by

Stephen Warren and committed by
Michal Marek
e3393645 f75a8df3

+54 -60
+9 -14
arch/arm/boot/Makefile
··· 11 11 # Copyright (C) 1995-2002 Russell King 12 12 # 13 13 14 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 15 - 16 14 ifneq ($(MACHINE),) 17 15 include $(srctree)/$(MACHINE)/Makefile.boot 18 16 endif ··· 67 69 68 70 clean-files := *.dtb 69 71 70 - quiet_cmd_uimage = UIMAGE $@ 71 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel \ 72 - -C none -a $(LOADADDR) -e $(STARTADDR) \ 73 - -n 'Linux-$(KERNELRELEASE)' -d $< $@ 74 - 75 - ifeq ($(CONFIG_ZBOOT_ROM),y) 76 - $(obj)/uImage: LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT) 72 + ifneq ($(LOADADDR),) 73 + UIMAGE_LOADADDR=$(LOADADDR) 77 74 else 78 - $(obj)/uImage: LOADADDR=$(ZRELADDR) 75 + ifeq ($(CONFIG_ZBOOT_ROM),y) 76 + UIMAGE_LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT) 77 + else 78 + UIMAGE_LOADADDR=$(ZRELADDR) 79 + endif 79 80 endif 80 81 81 - $(obj)/uImage: STARTADDR=$(LOADADDR) 82 - 83 82 check_for_multiple_loadaddr = \ 84 - if [ $(words $(LOADADDR)) -gt 1 ]; then \ 85 - echo 'multiple load addresses: $(LOADADDR)'; \ 83 + if [ $(words $(UIMAGE_LOADADDR)) -gt 1 ]; then \ 84 + echo 'multiple load addresses: $(UIMAGE_LOADADDR)'; \ 86 85 echo 'This is incompatible with uImages'; \ 87 86 echo 'Specify LOADADDR on the commandline to build an uImage'; \ 88 87 false; \
+3 -6
arch/avr32/boot/images/Makefile
··· 6 6 # for more details. 7 7 # 8 8 9 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 10 - 11 9 extra-y := vmlinux.bin vmlinux.gz 12 10 13 11 OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note.gnu.build-id ··· 15 17 $(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE 16 18 $(call if_changed,gzip) 17 19 18 - quiet_cmd_uimage = UIMAGE $@ 19 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A avr32 -O linux -T kernel \ 20 - -C gzip -a $(CONFIG_LOAD_ADDRESS) -e $(CONFIG_ENTRY_ADDRESS) \ 21 - -n 'Linux-$(KERNELRELEASE)' -d $< $@ 20 + UIMAGE_LOADADDR = $(CONFIG_LOAD_ADDRESS) 21 + UIMAGE_ENTRYADDR = $(CONFIG_ENTRY_ADDRESS) 22 + UIMAGE_COMPRESSION = gzip 22 23 23 24 targets += uImage uImage.srec 24 25 $(obj)/uImage: $(obj)/vmlinux.gz
+8 -11
arch/blackfin/boot/Makefile
··· 6 6 # for more details. 7 7 # 8 8 9 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 10 - 11 9 targets := vmImage vmImage.bin vmImage.bz2 vmImage.gz vmImage.lzma vmImage.lzo vmImage.xip 12 10 extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xip 13 11 14 - UIMAGE_OPTS-y := 15 - UIMAGE_OPTS-$(CONFIG_RAMKERNEL) += -a $(CONFIG_BOOT_LOAD) 16 - UIMAGE_OPTS-$(CONFIG_ROMKERNEL) += -a $(CONFIG_ROM_BASE) -x 17 - 18 - quiet_cmd_uimage = UIMAGE $@ 19 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(ARCH) -O linux -T kernel \ 20 - -C $(2) -n '$(CPU_REV)-$(KERNELRELEASE)' \ 21 - -e $(shell $(NM) vmlinux | awk '$$NF == "__start" {print $$1}') \ 22 - $(UIMAGE_OPTS-y) -d $< $@ 12 + ifeq ($(CONFIG_RAMKERNEL),y) 13 + UIMAGE_LOADADDR = $(CONFIG_BOOT_LOAD) 14 + else # CONFIG_ROMKERNEL must be set 15 + UIMAGE_LOADADDR = $(CONFIG_ROM_BASE) 16 + endif 17 + UIMAGE_ENTRYADDR = $(shell $(NM) vmlinux | awk '$$NF == "__start" {print $$1}') 18 + UIMAGE_NAME = '$(CPU_REV)-$(KERNELRELEASE)' 19 + UIMAGE_OPTS-$(CONFIG_ROMKERNEL) += -x 23 20 24 21 $(obj)/vmlinux.bin: vmlinux FORCE 25 22 $(call if_changed,objcopy)
+3 -7
arch/microblaze/boot/Makefile
··· 2 2 # arch/microblaze/boot/Makefile 3 3 # 4 4 5 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 6 - 7 5 obj-y += linked_dtb.o 8 6 9 7 targets := linux.bin linux.bin.gz simpleImage.% ··· 33 35 cmd_strip = $(STRIP) -K microblaze_start -K _end -K __log_buf \ 34 36 -K _fdt_start vmlinux -o $@ 35 37 36 - quiet_cmd_uimage = UIMAGE $@.ub 37 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A microblaze -O linux -T kernel \ 38 - -C none -n 'Linux-$(KERNELRELEASE)' \ 39 - -a $(CONFIG_KERNEL_BASE_ADDR) -e $(CONFIG_KERNEL_BASE_ADDR) \ 40 - -d $@ $@.ub 38 + UIMAGE_IN = $@ 39 + UIMAGE_OUT = $@.ub 40 + UIMAGE_LOADADDR = $(CONFIG_KERNEL_BASE_ADDR) 41 41 42 42 $(obj)/simpleImage.%: vmlinux FORCE 43 43 $(call if_changed,cp,.unstrip)
+2 -6
arch/sh/boot/Makefile
··· 8 8 # Copyright (C) 1999 Stuart Menefy 9 9 # 10 10 11 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 12 - 13 11 # 14 12 # Assign safe dummy values if these variables are not defined, 15 13 # in order to suppress error message. ··· 59 61 $(KERNEL_MEMORY) + \ 60 62 $(CONFIG_ZERO_PAGE_OFFSET) + $(CONFIG_ENTRY_OFFSET)]') 61 63 62 - quiet_cmd_uimage = UIMAGE $@ 63 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \ 64 - -C $(2) -a $(KERNEL_LOAD) -e $(KERNEL_ENTRY) \ 65 - -n 'Linux-$(KERNELRELEASE)' -d $< $@ 64 + UIMAGE_LOADADDR = $(KERNEL_LOAD) 65 + UIMAGE_ENTRYADDR = $(KERNEL_ENTRY) 66 66 67 67 $(obj)/vmlinux.bin: vmlinux FORCE 68 68 $(call if_changed,objcopy)
+3 -6
arch/sparc/boot/Makefile
··· 5 5 6 6 ROOT_IMG := /usr/src/root.img 7 7 ELFTOAOUT := elftoaout 8 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 9 8 10 9 hostprogs-y := piggyback btfixupprep 11 10 targets := tftpboot.img btfix.o btfix.S image zImage vmlinux.aout ··· 91 92 $(obj)/image.gz: $(obj)/image.bin 92 93 $(call if_changed,gzip) 93 94 94 - quiet_cmd_uimage = UIMAGE $@ 95 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux -T kernel \ 96 - -C gzip -a $(CONFIG_UBOOT_LOAD_ADDR) \ 97 - -e $(CONFIG_UBOOT_ENTRY_ADDR) -n 'Linux-$(KERNELRELEASE)' \ 98 - -d $< $@ 95 + UIMAGE_LOADADDR = $(CONFIG_UBOOT_LOAD_ADDR) 96 + UIMAGE_ENTRYADDR = $(CONFIG_UBOOT_ENTRY_ADDR) 97 + UIMAGE_COMPRESSION = gzip 99 98 100 99 quiet_cmd_uimage.o = UIMAGE.O $@ 101 100 cmd_uimage.o = $(LD) -Tdata $(CONFIG_UBOOT_FLASH_ADDR) \
+2 -10
arch/unicore32/boot/Makefile
··· 11 11 # Copyright (C) 2001~2010 GUAN Xue-tao 12 12 # 13 13 14 - MKIMAGE := $(srctree)/scripts/mkuboot.sh 15 - 16 14 targets := Image zImage uImage 17 15 18 16 $(obj)/Image: vmlinux FORCE ··· 24 26 $(call if_changed,objcopy) 25 27 @echo ' Kernel: $@ is ready' 26 28 27 - quiet_cmd_uimage = UIMAGE $@ 28 - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A unicore -O linux -T kernel \ 29 - -C none -a $(LOADADDR) -e $(STARTADDR) \ 30 - -n 'Linux-$(KERNELRELEASE)' -d $< $@ 31 - 32 - $(obj)/uImage: LOADADDR=0x0 33 - 34 - $(obj)/uImage: STARTADDR=$(LOADADDR) 29 + UIMAGE_ARCH = unicore 30 + UIMAGE_LOADADDR = 0x0 35 31 36 32 $(obj)/uImage: $(obj)/zImage FORCE 37 33 $(call if_changed,uimage)
+24
scripts/Makefile.lib
··· 304 304 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 305 305 (rm -f $@ ; false) 306 306 307 + # U-Boot mkimage 308 + # --------------------------------------------------------------------------- 309 + 310 + MKIMAGE := $(srctree)/scripts/mkuboot.sh 311 + 312 + # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces 313 + # the number of overrides in arch makefiles 314 + UIMAGE_ARCH ?= $(SRCARCH) 315 + UIMAGE_COMPRESSION ?= $(if $(2),$(2),none) 316 + UIMAGE_OPTS-y ?= 317 + UIMAGE_TYPE ?= kernel 318 + UIMAGE_LOADADDR ?= arch_must_set_this 319 + UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) 320 + UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' 321 + UIMAGE_IN ?= $< 322 + UIMAGE_OUT ?= $@ 323 + 324 + quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) 325 + cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ 326 + -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ 327 + -T $(UIMAGE_TYPE) \ 328 + -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ 329 + -n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT) 330 + 307 331 # XZ 308 332 # --------------------------------------------------------------------------- 309 333 # Use xzkern to compress the kernel image and xzmisc to compress other things.