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

kbuild: fix "cat: .version: No such file or directory"

Since commit 2df8220cc511 ("kbuild: build init/built-in.a just once"),
the .version file is not touched at all when KBUILD_BUILD_VERSION is
given.

If KBUILD_BUILD_VERSION is specified and the .version file is missing
(for example right after 'make mrproper'), "No such file or director"
is shown. Even if the .version exists, it is irrelevant to the version
of the current build.

$ make -j$(nproc) KBUILD_BUILD_VERSION=100 mrproper defconfig all
[ snip ]
BUILD arch/x86/boot/bzImage
cat: .version: No such file or directory
Kernel: arch/x86/boot/bzImage is ready (#)

Show KBUILD_BUILD_VERSION if it is given.

Fixes: 2df8220cc511 ("kbuild: build init/built-in.a just once")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

+3 -3
+2 -2
arch/microblaze/Makefile
··· 67 67 linux.bin: vmlinux 68 68 linux.bin linux.bin.gz linux.bin.ub: 69 69 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 70 - @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 70 + @echo 'Kernel: $(boot)/$@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')' 71 71 72 72 PHONY += simpleImage.$(DTB) 73 73 simpleImage.$(DTB): vmlinux 74 74 $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip) 75 - @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 75 + @echo 'Kernel: $(boot)/$@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')' 76 76 77 77 define archhelp 78 78 echo '* linux.bin - Create raw binary'
+1 -1
arch/x86/boot/Makefile
··· 83 83 84 84 $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE 85 85 $(call if_changed,image) 86 - @$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')' 86 + @$(kecho) 'Kernel: $@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')' 87 87 88 88 OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S 89 89 $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE