标签:字符 命令 comm bre cin order input blank tar
转自:http://blog.sina.com.cn/s/blog_87c063060101l25y.html
在编译构建性目标时(如 make vmlinux),顶层 Makefile 的 $(dot-config) 变量值为 1 。
在顶层 Makefile 的 497-504 行看到:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
ifeq ($(dot-config),1)# Read in config-include include/config/auto.confifeq ($(KBUILD_EXTMOD),)# Read in dependencies to all Kconfig* files,
make sure to run# oldconfig if changes are
detected.-include include/config/auto.conf.cmd# To avoid any implicit rule to kick in, define
an empty command$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;# If .config is newer than
include/config/auto.conf, someone tinkered# with it and forgot to run make
oldconfig.# if auto.conf.cmd is missing then we are
probably in a cleaned tree so# we execute the config step to be sure to
catch updated Kconfig filesinclude/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd $(Q)$(MAKE)
-f $(srctree)/Makefile silentoldconfig |
其中,
引用-include include/config/auto.conf
-include include/config/auto.conf.cmd
这两行尝试包含 auto.conf 和 auto.conf.cmd 这两个文件。由于使用 -include
进行声明,所以即使这两个文件不存在也不会报错退出,比如在第 1 次编译内核,且已经配置好 .config
文件时,这两个文件还未生成。
假如我们已经编译好了 vmlinux 这个目标,那么我们会在 include/config 这个目录下看到 auto.conf 和
auto.conf.cmd 这两个文件。
从 include/config/%.conf:
$(KCONFIG_CONFIG) include/config/auto.conf.cmd
这条语句可以知道,auto.conf 文件依赖于 $(KCONFIG_CONFIG) 和
include/config/auto.conf.cmd 。其中 $(KCONFIG_CONFIG) 变量的值就是 .config
这个配置文件。那么
|
1
2
3
|
%config: scripts_basic outputmakefile
FORCE $(Q)mkdir
-p include/linux include/config $(Q)$(MAKE)
$(build)=scripts/kconfig $@ |
|
1
2
3
|
silentoldconfig: $(obj)/conf $(Q)mkdir
-p include/generated $<
-s $(Kconfig) |
|
1
2
3
4
5
6
7
8
9
10
|
while ((opt =
getopt(ac, av, "osdD:nmyrh")) != -1)
{ switch
(opt) { case
‘o‘: input_mode
= ask_silent; break; case
‘s‘: input_mode
= ask_silent; sync_kconfig
= 1; break;...
... |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
if
(sync_kconfig) { name
= conf_get_configname(); if
(stat(name, &tmpstat)) { fprintf(stderr,
_("***\n" "***
You have not yet configured your kernel!\n" "***
(missing kernel config file \"%s\")\n" "***\n" "***
Please run some configurator (e.g. \"make oldconfig\"
or\n" "***
\"make menuconfig\" or \"make xconfig\").\n" "***\n"),
name); exit(1); } } |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
switch
(input_mode) { case
set_default: if
(!defconfig_file) defconfig_file
= conf_get_default_confname(); if
(conf_read(defconfig_file)) { printf(_("***\n" "***
Can‘t find default configuration \"%s\"!\n" "***\n"),
defconfig_file); exit(1); } break; case
ask_silent: case
ask_all: case
ask_new: conf_read(NULL); break;...
... |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
if
(sync_kconfig) { if
(conf_get_changed() &&
conf_write(NULL)) { fprintf(stderr,
_("\n*** Error during writing of
the kernel configuration.\n\n")); exit(1); } if
(conf_write_autoconf()) { fprintf(stderr,
_("\n*** Error during update of the
kernel configuration.\n\n")); return
1; } }
else { if
(conf_write(NULL)) { fprintf(stderr,
_("\n*** Error during writing of
the kernel configuration.\n\n")); exit(1); } } |
|
1
2
|
include/config/auto.conf: \ $(deps_config) |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
out
= fopen(".tmpconfig",
"w"); if
(!out) return
1; tristate
= fopen(".tmpconfig_tristate", "w"); if
(!tristate) { fclose(out); return
1; } out_h
= fopen(".tmpconfig.h",
"w"); if
(!out_h) { fclose(out); fclose(tristate); return
1; } |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
sym
= sym_lookup("KERNELVERSION",
0); sym_calc_value(sym); time(&now); fprintf(out,
"#\n" "#
Automatically generated make config: don‘t edit\n" "#
Linux kernel version: %s\n" "#
%s" "#\n", sym_get_string_value(sym),
ctime(&now)); fprintf(tristate,
"#\n" "#
Automatically generated - do not edit\n" "\n"); fprintf(out_h,
"\n" "#define
AUTOCONF_INCLUDED\n", sym_get_string_value(sym),
ctime(&now)); |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
name
= getenv("KCONFIG_AUTOHEADER"); if
(!name) name
= "include/generated/autoconf.h"; if
(rename(".tmpconfig.h",
name)) return
1; name
= getenv("KCONFIG_TRISTATE"); if
(!name) name
= "include/config/tristate.conf"; if
(rename(".tmpconfig_tristate",
name)) return
1; name
= conf_get_autoconfig_name(); if
(rename(".tmpconfig",
name)) return
1; |
|
1
2
3
4
5
6
|
const char *conf_get_autoconfig_name(void){ char
*name = getenv("KCONFIG_AUTOCONFIG"); return
name ? name : "include/config/auto.conf";} |
引用include/generated/autoconf.h
include/config/tristate.conf
include/config/auto.conf
《Linux内核Makefile分析》之 auto.conf, auto.conf.cmd, autoconf.h【转】
标签:字符 命令 comm bre cin order input blank tar
原文地址:http://www.cnblogs.com/sky-heaven/p/6745496.html