close

===介紹

 

有4 個不同的configuration programs 是使用 Config Language︰

 

scripts/Configure make config, make oldconfig
scripts/Menuconfig make menuconfig
scripts/tkparse make xconfig
mconfig ftp.kernel.org/pub/linux/kernel/people/hch/mconfig/

本文主要介紹 Menuconfig

 

=== 說明

 

一個 Config Language script 是一個陳列式的述語. 有 21 個簡單的述語;
一個 'if' 述語; menu 區塊; 跟一個 'source' 述語.

 

'\' 用 來連續每行結尾到下一行
'#' 通常表示後面是解釋

 

每新的一行都是另外一個意義. 你可以用分號來代替換行.

 

下面是基本的文法結構.

 

/prompt/ 顯示給使用這看的文字 主要用一個單引號(') 或一雙引號(")所括含的字串.
EX: 若 kk=tt
' kk=$kk' ==> kk=$kk
" kk=$kk" ==> kk=$tt

 

/word/ 是一個預設值.可以用 $變數 來代替.

 

/symbol/ 表示一個參數設定 以 CONFIG_* 帶頭. scripts/mkdep.c
參數設定會存在 include/linux/autoconf.h.

 

/dep/ 相依性選項 合法值為 "y", "m", "n", or "".

 

/expr/ 是 bash-like 表達式 使用如
'=', '!=', '-a', '-o', and '!'.

 

下面是全部的述語:

 

正文述語:

 

mainmenu_name /prompt/
表示最上層的標題

Configure: ignores this line
Menuconfig: ignores this line
Xconfig: uses /prompt/ for the label window.
mconfig: ignores this line (mconfig does a better job without it).

 

Example:

 

# arch/sparc/config.in
mainmenu_name "Linux/SPARC Kernel Configuration"


comment
/prompt/
表示選單上的標題

Configure: Menuconfig: Xconfig: mconfig: 全部支援

 

Example:

 

# drivers/net/Config.in
comment 'CCP compressors for PPP are only built as modules.'

 



text
/prompt/
後接文字 主要在 mconfig中 做HELP 註解用
Menuconfig: 不支援

Example:

 

# mconfig internal help text
text 'Here are all the mconfig command line options.'

 

詢問述語:

 

bool /prompt/ /symbol/ /symbol/
接受使用者的設定值 合法值為 "n" 跟 "y"

Configure: Menuconfig: Xconfig: mconfig: 全部支援

 

Example:

 

# arch/i386/config.in
bool 'Symmetric multi-processing support' CONFIG_SMP

 



hex /prompt/ /symbol/ /word/
/symbol/=/word/ 是一個16進制的值


Configure: Menuconfig: Xconfig: mconfig: 全部支援

 

Example:

 

# drivers/sound/Config.in
hex 'I/O base for SB Check from manual of the card' CONFIG_SB_BASE 220

 



int
/prompt/ /symbol/ /word/
/symbol/=/word/ 是一個10進制的值

 

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# drivers/char/Config.in
int 'Maximum number of Unix98 PTYs in use (0-2048)' \
CONFIG_UNIX98_PTY_COUNT 256

 



string
/prompt/ /symbol/ /word/
/symbol/=/word/ 是一個字串

 

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# drivers/sound/Config.in
string ' Full pathname of DSPxxx.LD firmware file' \
CONFIG_PSS_BOOT_FILE /etc/sound/dsp001.ld



tristate
/prompt/ /symbol/
/symbol/=使用者輸入的值 "n", "m", "y" ,"m" 表 "module" ,只有在 CONFIG_MODULES = "y" 才有效

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# fs/Config.in
tristate 'NFS filesystem support' CONFIG_NFS_FS

 

定義述語:

 

define_bool /symbol/ /word/
定義 /symbol/=/word/ 通常為 "n" 或 "y" 而為了相容性 若define_tristate 有支援 則"m" 也可使用

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# arch/alpha/config.in
if [ "$CONFIG_ALPHA_GENERIC" = "y" ]
then
define_bool CONFIG_PCI y
define_bool CONFIG_ALPHA_NEED_ROUNDING_EMULATION y
fi

 



define_hex
/symbol/ /word/
定義 /symbol/=/word/ 一個16進制的值

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# Not from the corpus
bool 'Specify custom serial port' CONFIG_SERIAL_PORT_CUSTOM
if [ "$CONFIG_SERIAL_PORT_CUSTOM" = "y" ]; then
hex 'Serial port number' CONFIG_SERIAL_PORT
else
define_hex CONFIG_SERIAL_PORT 0x3F8
fi

 



define_int /symbol/ /word/
定義 /symbol/=/word/ 一個10進制的值

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# drivers/char/ftape/Config.in
define_int CONFIG_FT_ALPHA_CLOCK 0

 



define_string
/symbol/ /word/
定義 /symbol/=/word/ 一個字串

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example

 

# Not from the corpus
define_string CONFIG_VERSION "2.2.0"

 



define_tristate
/symbol/ /word/
定義 /symbol/=/word/ 一個合法的輸入值 為 "n", "m", 跟 "y"

Configure: Menuconfig: Xconfig: mconfig: 全部支援

Example:

 

# drivers/video/Config.in
if [ "$CONFIG_FB_AMIGA" = "y" ]; then
define_tristate CONFIG_FBCON_AFB y
define_tristate CONFIG_FBCON_ILBM y
else
if [ "$CONFIG_FB_AMIGA" = "m" ]; then
define_tristate CONFIG_FBCON_AFB m
define_tristate CONFIG_FBCON_ILBM m
fi
fi

 

依賴述語:

 

dep_bool /prompt/ /symbol/ /dep/ ... 只有 /dep/ 全為"y" 才成立

Configure: Menuconfig: Xconfig: mconfig: 全部支援

EX:
dep_bool ' Set version information on all module symbols' CONFIG_MODVERSIONS $CONFIG_MODULES


dep_mbool /prompt/ /symbol/ /dep/ ... 只有 /dep/ 全為"y" or "m"才成立


Configure: Menuconfig: Xconfig: mconfig: 全部支援

EX:
dep_mbool 'Packet socket: mmapped IO' CONFIG_PACKET_MMAP $CONFIG_PACKET


dep_hex /prompt/ /symbol/ /word/ /dep/ ... 不支援
dep_int
/prompt/ /symbol/ /word/ /dep/ ... 不支援
dep_string
/prompt/ /symbol/ /word/ /dep/ ... 不支援
作者還沒想到在怎做

dep_tristate /prompt/ /symbol/ /dep/ ... 只有 /dep/ 全為"y" 才成立


Configure: Menuconfig: Xconfig: mconfig: 全部支援
EX:
dep_tristate ' Support for SA11x0 USB network link function' CONFIG_SA1100_USB_NETLINK $CONFIG_SA1100_USB

 

未設定述語:

 

unset /symbol/ ...

 

選擇述語:

choice
/prompt/ /word/ /word/ 選單 在 /prompt/文字後接 ""所括住的選單

Configure: Menuconfig: Xconfig: mconfig: 全部支援
EX:
choice 'ARM system type' \
"Anakin CONFIG_ARCH_ANAKIN \
Archimedes/A5000 CONFIG_ARCH_ARCA5K \
Cirrus-CL-PS7500FE CONFIG_ARCH_CLPS7500 \
CLPS711x/EP721x-based CONFIG_ARCH_CLPS711X \
Co-EBSA285 CONFIG_ARCH_CO285 \
EBSA-110 CONFIG_ARCH_EBSA110 \
Excalibur-ARM CONFIG_ARCH_CAMELOT \
FootBridge CONFIG_ARCH_FOOTBRIDGE \
Integrator CONFIG_ARCH_INTEGRATOR \
Omaha CONFIG_ARCH_OMAHA \
LinkUp-L7200 CONFIG_ARCH_L7200 \
Motorola-MX1ADS CONFIG_ARCH_MX1ADS \
RiscPC CONFIG_ARCH_RPC \
RiscStation CONFIG_ARCH_RISCSTATION \
SA1100-based CONFIG_ARCH_SA1100 \
Shark CONFIG_ARCH_SHARK \
AT91RM9200-based CONFIG_ARCH_AT91RM9200 \
FIC81XX-based CONFIG_ARCH_FIC81XX " RiscPC

 

 

 



nchoice /prompt/ /symbol/ /prompt/ /symbol/ ...
Menuconfig: 支援 其他都不支援

 

假設述語:

 

if [ /expr/ ] ; then
/statement/
...
fi


Configure: Menuconfig: Xconfig: mconfig: 全部支援
但 Xconfig 有些bug


if [ "$CONFIG_ARCH_EP7211" = "y" -o \
"$CONFIG_ARCH_EP7212" = "y" ]; then
bool ' EP72xx ROM boot' CONFIG_EP72XX_ROM_BOOT
fi

 

if [ /expr/ ] ; then
/statement/
...
else
/statement/
...
fi


if [ "$CONFIG_ARCH_P720T" = "y" ]; then
define_bool CONFIG_ARCH_EP7212 y
else
define_bool CONFIG_ARCH_EP7212 n
fi

 

選單區塊:

 

mainmenu_option next_comment
comment /prompt/
/statement/
...
endmenu

Configure: Menuconfig: Xconfig: mconfig: 全部支援

 

ex;
mainmenu_option next_comment
comment 'Code maturity level options'
bool 'Prompt for development and/or incomplete code/drivers' CONFIG_EXPERIMENTAL
bool 'Prompt for obsolete code/drivers' CONFIG_OBSOLETE
endmenu

 

 

來源述語:

 

source /word/
讀取其他的cinfig.in設定檔

Configure: implemented (run time)
Menuconfig: implemented (parse time)
Xconfig: implemented (parse time)
mconfig: implemented (parse time)

 

ex;
source drivers/parport/Config.in
讀取 parallel port設定檔
.....
mainmenu_option next_comment
comment 'Parallel port support'
.....

 

 

tristate 'Parallel port support' CONFIG_PARPORT
if [ "$CONFIG_PARPORT" != "n" ]; then
.....

 

 

 

 

相關檔案

 

1.Makefile
make menuconfig 啟動 menuconfig

啟動流程如下
menuconfig: include/linux/version.h symlinks
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in

2.sh

linux.2.4.27/scripts/Menuconfig
這個是Config Language 主要的 shell script 執行檔

linux-2.4.24/scripts/lxdialog/...
這個裡面的檔案 在產生menucofig 選單的程式

3.config.in
linux-2.4.27/arch/arm/config.in
menuconfig 設定檔

4.HELP 檔
linux.2.4.27/Documetation/configure.help
config.in 的相關幫助文件
如下圖

在 Prompt for development and/or incomplete code/drivers 的help
對照 linux.2.4.27/Documetation/configure.help 中相對應的 CONFIG_EXPERIMENRAL 設定

Prompt for development and/or incomplete code/drivers
CONFIG_EXPERIMENTAL
Some of the various things that Linux supports (such as network
drivers, file systems, network protocols, etc.) can be in a state
of development where the functionality, stability, or the level of
testing is not yet high enough for general use. This is usually
known as the "alpha-test" phase among developers. If a feature is
..........................

 

所以若要新增一個註解
也可以在這裡新增

5.CONFIG 檔
經過make menuconfig 設定完後 其結果會存在
/linux-2.4.27/.config

也可以先載入之前的設定檔

 

6.config language readme
linux.2.4.27/Documetation/Kbuild/config-language.txt
config language 說明檔 ,本文主要參考文件

 

7.練習
如下圖 改寫 /arch/arm/config.in 做測試練習
主要將每個語法都測試過一遍

 

 

 

 

2007/05/08 update example

 

2007/03/05 add

arrow
arrow
    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()