How build kernel version with git commit id automaticly

hi,i want to build kernel,and automatic add git commit id to kernel release version such as Linux version 4.9.140-tegra-commit_id
how to add git commit id to kernel version,when build kernel source.

Hi,

Do you mean you want the result of “uname -r” give your the linux version with commit id?

If so, please use LOCALVERSION variable.
https://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/re137.html

export LOCALVERSION=xxxx before your build the kernel.

yes,use “uname -a” or “cat /proc/version” would give me the linux version with git commit id.
i have export LOCALVERSION=tegra before build kernel source,
i mean i want automatic add git commit id behind linux version ,not manual,when build kernel source

We are not using such method. Maybe you can search it over linux kernel community to see if anyone is using it.

when i check kernel-4.9/arch/arm64/configs/tegra_defconfig, it show CONFIG_LOCALVERSION_AUTO is not set,but when i set tegra_defconfig
$ make ARCH=arm64 O=TEGRA_KERNEL_OUT tegra_defconfig and then set menuconfig as CONFIG_LOCALVERSION_AUTO = y make ARCH=arm64 menuconfig
and then make Image
$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT Image -j8
the result is : kernel/kernel-4.9 is not clean, please run 'make mrproper’
but when i run ‘make mrproper’,the CONFIG_LOCALVERSION_AUTO is back to ‘CONFIG_LOCALVERSION_AUTO = n’
this confused me,how to set ‘CONFIG_LOCALVERSION_AUTO = y’,in menuconfig or tegra_defconfig?
is this MACRO DEFINATION ‘CONFIG_LOCALVERSION_AUTO’ useful in nvidia kernel source?

If you set something in tegra_defconfig, then no need to run menuconfig anymore.