linux 内核版本中自动加入 git 版本信息

来源:互联网 发布:js复合保温图集 编辑:程序博客网 时间:2024/06/05 12:05

在调试驱动时,需要在内核中打印一些信息,但是每次编译后,内核版本总是加上git的版本信息,这样驱动有需要重新编译,如果linux内核版本不变就好了。

在网上找了一些信息,是setlocalversion 在作怪。

make menuconfig 

General Setup --->

     Automatically append version information to the version   将这个去掉

重新编译,发现多了一个 + , 再看 setlocalversion 脚本


                        # If only the short version is requested, don't bother                        # running further git commands                        if $short; then                                echo "+"                                return                        fi                        # If we are past a tagged commit (like                        # "v2.6.30-rc5-302-g72357d5"), we pretty print it.                        if atag="`git describe 2>/dev/null`"; then                                echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'                        # If we don't have a tag at all we print -g{commitish}.                        else                                printf '%s%s' -g $head                        fi

这里的 short 为 1,就是在这里加入的 + 号。

干脆点,不让编译器执行这个文件得了。

在linux 的顶层Makefile中 把这一句:

$(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > $@

改为:

$(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL)   $(srctree))" > $@


直接去掉  $(srctree)/scripts/setlocalversion 就可以了
0 0