本来这部分是不能单独成篇的,但是想到后面还要很多内核编译相关的内容,就单独拉出来分享了。
首先写博客是一种记录,而这种记录都是问题驱动的。遇到问题,解决问题,记录问题,分享问题。在编译内核的时候,我发现编译生成的文件都适合源码混在一起的,如果改动比较小,自己记得住是没问题的,但是随着改动越来越多,尤其是在本地创建了git库来管理以后,看起来非常混乱,如下图:
配置编译目标生成路径有两种方法,如下:
一、指定编译命令参数make O=dir/to/store/output/files/二、配置环境变量方式
export KBUILD_OUTPUT=dir/to/store/output/files/三、使用案例 四、Kbuild源码中相关说明
/linux-4.19.236/Makefile
# kbuild supports saving output files in a separate directory.
# To locate output files in a separate directory two syntaxes are supported.
# In both cases the working directory must be the root of the kernel src.
# 1) O=
# Use "make O=dir/to/store/output/files/"
#
# 2) Set KBUILD_OUTPUT
# Set the environment variable KBUILD_OUTPUT to point to the directory
# where the output files shall be placed.
# export KBUILD_OUTPUT=dir/to/store/output/files/
# make
#
# The O= assignment takes precedence over the KBUILD_OUTPUT environment
# variable.
# KBUILD_SRC is not intended to be used by the regular user (for now),
# it is set on invocation of make with KBUILD_OUTPUT or O= specified.
ifeq ($(KBUILD_SRC),)
# OK, Make called in directory where kernel src resides
# Do we want to locate output files in a separate directory?
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif



