使用者工具

網站工具


kernel_make_menuconfig_description

Make Menuconfig for Linux Kernel

Kernel 下 scripts 文件夾

scripts 文件夾存放的是跟 make menuconfig 配置介面的圖形繪製相關的文件

make menuconfig
在 Kernel 的目錄下,讀取 Kernel目錄下的 Kconfig
目錄下的 Kconfig 如下

# SPDX-License-Identifier: GPL-2.0
#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.rst.
#
mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
source "scripts/Kconfig.include"
source "init/Kconfig"
source "kernel/Kconfig.freezer"
source "fs/Kconfig.binfmt"
source "mm/Kconfig"
source "net/Kconfig"
source "drivers/Kconfig"
source "fs/Kconfig"
source "security/Kconfig"
source "crypto/Kconfig"
source "lib/Kconfig"
source "lib/Kconfig.debug"
source "Documentation/Kconfig"

再來根據 Linux/$(ARCH) 選擇其架構下對應的 Kconfig 如 ARM64 下的 Kconfig 文件生成整個配置介面選項

# SPDX-License-Identifier: GPL-2.0-only
config ARM64
	def_bool y
	select ACPI_CCA_REQUIRED if ACPI
	select ACPI_GENERIC_GSI if ACPI
	select ACPI_GTDT if ACPI
	select ACPI_IORT if ACPI
	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
	select ACPI_MCFG if (ACPI && PCI)
	select ACPI_SPCR_TABLE if ACPI
	select ACPI_PPTT if ACPI
	…………………

至於 $(ARCH) 可先指定變量或在執行 menuconfig 時指定

 make ARCH=arm64 menuconfig 

每一種架構都有其個別定義的內核默認選項
其資料都會放置在 arch/$ARCH/configs

內核默認會以 Linux 根目錄下 .config 當作默認選項 我們會根據開發版最接近的系列的 defconfig 將其拷貝到 Kernel 根目錄覆蓋 .config 在 Kernel 根目錄執行以下命令

 cp arch/arm64/ configs/defconfig .config 

當我們執行 make menuconfig 之後,會把修改的內容更新到根目錄的 .config
還會將所有選項以巨集定義產生在 kernel 根目錄下成為一個 .h 頭文件

include/generated/autoconf.h

內容如下:

/*
 *
 * Automatically generated file; DO NOT EDIT.
 * Linux/x86 5.10.120 Kernel Configuration
 *
 */
#define CONFIG_IP6_NF_MATCH_AH_MODULE 1
#define CONFIG_NLS_CODEPAGE_861_MODULE 1
#define CONFIG_MTD_SPI_NAND_MODULE 1
#define CONFIG_RING_BUFFER 1
#define CONFIG_SND_SOC_WM8804_MODULE 1
#define CONFIG_NF_CONNTRACK_H323_MODULE 1
#define CONFIG_HAVE_ARCH_SECCOMP_FILTER 1
#define CONFIG_IP6_NF_SECURITY_MODULE 1
#define CONFIG_SND_PROC_FS 1
#define CONFIG_VFIO_PCI_MMAP 1
#define CONFIG_SCSI_DMA 1
#define CONFIG_IQS624_POS_MODULE 1
#define CONFIG_NETFILTER_FAMILY_BRIDGE 1
#define CONFIG_TWL6040_CORE 1
#define CONFIG_NUMA_EMU 1
#define CONFIG_INTEL_IDLE 1
#define CONFIG_TOUCHSCREEN_IQS5XX_MODULE 1
#define CONFIG_TCP_MD5SIG 1
#define CONFIG_HID_GT683R_MODULE 1
#define CONFIG_CC_HAS_SANCOV_TRACE_PC 1
………………………

內核中的源代碼都會包含上述的 .h文件 ,來進行編譯

如何修改 Kconfig

Kconfig 在修改或新增內容時也要修改對應的 Makefile ,這樣才能讓選單對應取得或取消包含的程序

Driver 下的 Makefile 內容如下 :

obj-$(CONFIG_FB_I810)       += video/fbdev/i810/
obj-$(CONFIG_FB_INTEL)      += video/fbdev/intelfb/
obj-$(CONFIG_PARPORT)	    += parport/
obj-$(CONFIG_NVM)	    += lightnvm/
obj-y			    += base/ block/ misc/ mfd/ nfc/
obj-$(CONFIG_LIBNVDIMM)	+= nvdimm/
obj-$(CONFIG_DAX)		+= dax/
obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
obj-$(CONFIG_NUBUS)		+= nubus/
obj-y			        += macintosh/
obj-$(CONFIG_IDE)		+= ide/
obj-y			      	+= scsi/
obj-y			        += nvme/
obj-$(CONFIG_ATA)		+= ata/
obj-$(CONFIG_TARGET_CORE)	+= target/
obj-$(CONFIG_MTD)		+= mtd/
obj-$(CONFIG_SPI)		+= spi/
……………
kernel_make_menuconfig_description.txt · 上一次變更: 2024/07/17 12:00 由 don