源码编译
$cat menu_demo/demo_kconfig
menu "menu1"
config MENU_SUBITEM1-1
bool
prompt "entry1.1"
config MENU_SUBITEM1-2
bool
prompt "entry1.2"
config MENU_SUBITEM1-3
bool
prompt "entry1.3"
endmenu
menu "menu2"
config MENU_SUBITEM2-1
bool
prompt "entry2.1"
config MENU_SUBITEM2-2
bool
prompt "entry2.2"
config MENU_SUBITEM2-3
bool
prompt "entry2.3"
endmenu
# for arm
$export ARCH=arm
$export CROSS_COMPILE=arm-linux-gnueabi-
$make vexpress_ca9x4_defconfig
$make -j4
make help
$make help
Cleaning targets:
clean - Remove most generated files but keep the config
mrproper - Remove all generated files + config + various backup files
distclean - mrproper + remove editor backup and patch files
Configuration targets:
config - Update current config utilising a line-oriented program
nconfig - Update current config utilising a ncurses menu based
program
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a Qt based front-end
gconfig - Update current config utilising a GTK+ based front-end
oldconfig - Update current config utilising a provided .config as base
localmodconfig - Update current config disabling modules not loaded
localyesconfig - Update current config converting local mods to core
defconfig - New config with default from ARCH supplied defconfig
savedefconfig - Save current config as ./defconfig (minimal config)
allnoconfig - New config where all options are answered with no
allyesconfig - New config where all options are accepted with yes
allmodconfig - New config selecting modules when possible
alldefconfig - New config with all symbols set to default
randconfig - New config with random answer to all options
listnewconfig - List new options
olddefconfig - Same as oldconfig but sets new symbols to their
default value without prompting
Test targets:
check - Run all automated tests that use sandbox
Other generic targets:
all - Build all necessary images depending on configuration
tests - Build U-Boot for sandbox and run tests
* u-boot - Build the bare u-boot
dir/ - Build all files in dir and below
dir/file.[oisS] - Build specified target only
dir/file.lst - Build specified mixed source/assembly target only
(requires a recent binutils and recent build (System.map))
tags/ctags - Generate ctags file for editors
etags - Generate etags file for editors
cscope - Generate cscope index
ubootrelease - Output the release version string (use with make -s)
ubootversion - Output the version stored in Makefile (use with make -s)
cfg - Don't build, just create the .cfg files
envtools - Build only the target-side environment tools
Static analysers
checkstack - Generate a list of stack hogs
coccicheck - Execute static code analysis with Coccinelle
Documentation targets:
Linux kernel internal documentation in different formats from ReST:
htmldocs - HTML
latexdocs - LaTeX
pdfdocs - PDF
epubdocs - EPUB
xmldocs - XML
linkcheckdocs - check for broken external links (will connect to external hosts)
refcheckdocs - check for references to non-existing files under Documentation
cleandocs - clean all generated files
make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2
valid values for SPHINXDIRS are:
make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build
configuration. This is e.g. useful to build with nit-picking config.
Default location for the generated documents is Documentation/output
make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
make V=2 [targets] 2 => give reason for rebuild of target
make O=dir [targets] Locate all output files in "dir", including .config
make C=1 [targets] Check all c source with $CHECK (sparse by default)
make C=2 [targets] Force check of all c source with $CHECK
make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections
make W=n [targets] Enable extra gcc checks, n=1,2,3 where
1: warnings which may be relevant and do not occur too often
2: warnings which occur quite often but may still be relevant
3: more obscure warnings, can most likely be ignored
Multiple levels can be combined with W=12 or W=123
Execute "make" or "make all" to build all targets marked with [*]
For further info see the ./README file
config targets
make config
- scripts/kconfig/conf --oldaskconfig Kconfig
config - Update current config utilising a line-oriented program - 针对Kconfig文件, 手动设置config项、字符窗口
ospin@ospin-VirtualBox:~/code/u-boot-2018.11$ scripts/kconfig/conf --oldaskconfig menu_demo/demo_kconfig
*
* Linux Kernel Configuration
*
*
* menu1
*
entry1.1 (MENU_SUBITEM1-1) [N/y/?] N
entry1.2 (MENU_SUBITEM1-2) [N/y/?] N
entry1.3 (MENU_SUBITEM1-3) [N/y/?] N
*
* menu2
*
entry2.1 (MENU_SUBITEM2-1) [N/y/?] y
entry2.2 (MENU_SUBITEM2-2) [N/y/?] y
entry2.3 (MENU_SUBITEM2-3) [N/y/?] y
#
# configuration written to .config
#
ospin@ospin-VirtualBox:~/code/u-boot-2018.11$ cat .config
#
# Automatically generated file; DO NOT EDIT.
# Linux Kernel Configuration
#
#
# menu1
#
# CONFIG_MENU_SUBITEM1-1 is not set
# CONFIG_MENU_SUBITEM1-2 is not set
# CONFIG_MENU_SUBITEM1-3 is not set
#
# menu2
#
CONFIG_MENU_SUBITEM2-1=y
CONFIG_MENU_SUBITEM2-2=y
CONFIG_MENU_SUBITEM2-3=y
make oldconfig
- 命令行窗口
- 基于已有的.config,根据Kconfig的增量变化–要求用户手动配置。相比make config更加简便了。
make nconfig/menuconfig/xconfig/gconfig
nconfig/menuconfig/xconfig/gconfig差别在显示窗口不同,举例nconfig:
-
scripts/kconfig/nconf Kconfig
nconfig - Update current config utilising a ncurses menu based -
scripts/kconfig/mconf Kconfig
menuconfig - Update current config utilising a menu based program -
others
xconfig - Update current config utilising a Qt based front-end
gconfig - Update current config utilising a GTK+ based front-end
generic targets
1. 调试技巧
-
Makefile 编译出了什么?
使用git工具将源码配置好 && 编译完毕后 && 使用git status 命令即可看到编译输出的全部文件
-
Makefile 编译对象日志
make --trace vexpress_ca9x4_defconfig | tee trace_config cat trace_config
日志:
Makefile:415: target 'scripts_basic' does not exist make -f ./scripts/Makefile.build obj=scripts/basic scripts/Makefile.host:97: update target 'scripts/basic/fixdep' due to: FORCE scripts/Makefile.build:117: update target '__build' due to: scripts/basic/fixdep : rm -f .tmp_quiet_recordmcount Makefile:496: update target 'vexpress_ca9x4_defconfig' due to: scripts_basic outputmakefile FORCE make -f ./scripts/Makefile.build obj=scripts/kconfig vexpress_ca9x4_defconfig scripts/Makefile.host:114: update target 'scripts/kconfig/conf.o' due to: FORCE scripts/Makefile.lib:228: update target 'scripts/kconfig/zconf.tab.c' due to: FORCE scripts/Makefile.lib:219: update target 'scripts/kconfig/zconf.lex.c' due to: FORCE scripts/Makefile.host:114: update target 'scripts/kconfig/zconf.tab.o' due to: FORCE scripts/Makefile.host:106: update target 'scripts/kconfig/conf' due to: FORCE scripts/kconfig/Makefile:128: update target 'vexpress_ca9x4_defconfig' due to: scripts/kconfig/conf scripts/kconfig/conf --defconfig=arch/../configs/vexpress_ca9x4_defconfig Kconfig # # configuration written to .config #
-
make target 具体使用的规则
$make -p vexpress_ca9x4_defconfig | tee vexpress_ca9x4_defconfig_config $cat vexpress_ca9x4_defconfig_config vexpress_ca9x4_defconfig: scripts/kconfig/conf recipe to execute (from 'scripts/kconfig/Makefile', line 128): $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)