uclinux编译心得四:分析make menuconfig \ make 过程的一点小技巧

我想,搞Linux/uclinux的一般都想把整个构建系统搞清楚。网上相关的资料很多,有的介绍的非常好。

在这些资料的基础上,我还是很想把整个执行过程与 Makefile等文件的具体位置,以及执行先后顺序,依赖关系等搞得更清楚些。

于是进行了很多的尝试,包括走读Makefile等文件,修改相关内容增加打印信息。

但是 Linux、uclinux的构建系统太过庞大,这样做既费力,还很难搞清楚之间的关系。

走了很多的弯路,还是想从make工具本身方面想办法。这才仔细去看看make的帮助

dx@ubuntu:~$ make --help
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY    Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides       Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE   Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY  Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.
This program built for x86_64-pc-linux-gnu
Report bugs to <bug-make@gnu.org>

经过尝试,-p 参数和  --trace参数对分析make 过程非常有用

-p  参数,可以将当前执行make的所有内部数据库打印出来。这个数据与当前系统的状态有很大的关系

        以uclinux为例,没有编译前,只能输出很少的一些内部数据。在完成uclinux编译后,就可以输出所有你想知道的,比如变量值、规则定义等内部数据,我输出的文件就有160多M。

 --trace参数, 可以将执行目标对应的规则等信息、以及对应的文件内部位置等信息输出。


结合这两个参数的数据,可以非常容易分析整个make执行过程。

接下来将我编译uclinux的make menuconfig 和make过程的分析文本写出来,供参考











  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值