make menuconfig 是执行makefile里面的menuconfig目标.
如果后面ARCH =arm CROSS_COMPILE=arm-linux-的话表明: 编译出来的目标是针对ARM体系结构的。因为是针对ARM体系结构,所以需要使用交叉编译器。使用CROSS_COMPILE=xxx来指定交叉编译器。
CROSS_COMPILE=arm-linux- 意思是制定交叉编译器为arm-linux-XXX。 如:makefile里面会指定CC为arm-linux-gcc。

本文译至:http://d.hatena.ne.jp/embedded/20140829/p1

为了使make命令执行并行处理,-j 选项可以用来指定作业数。

$ make -j4

作业数是在编译的时候指定主机的CPU个数,所以在脚本中写成一个常量很糟糕。(特别是把编译脚本给其他人的时候。)并行处理的作业数和编译的效率直接相关,所以需要设置合适的作业数量。

昨天的文章中在编译perf时,make的任务数能自动设置成CPU的数量。调查了一下它是怎么做的。

linux/tools/perf/Makefile

#
# Do a parallel build with multiple jobs, based on the number of CPUs online
# in this system: 'make -j8' on a 8-CPU system, etc.
#
# (To override it, run 'make JOBS=1' and similar.)
#
ifeq ($(JOBS),)JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)ifeq ($(JOBS),)JOBS := 1endif
endif

这种计算了/proc/cpuinfo以processor开头的行的数量。

这里不使用wc命令来计算匹配的行数,而是用grep -c来获取。

这里JOBS是CPU的个数,用这个变量在子进程中使用make命令。

$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@


关于make时,通过-j参数指定多线程数目


之前在折腾crosstool-ng:【记录】crosstool为xscale编译(ct-ng build)过程时,就偶尔看到别人用ct-ng build.4意思是多线程去编译估计底层就是调用的makefile的支持多线程的这个功能。后来又在别处看到类似的写法了:Introduction to Cross Compilation中的:
?
1
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j4

此时,才想到,去查查make的参数:(此处是在cygwin中)
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Administrator@PC-20130611GART /cygdrive/e/Dev_Root
$ 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.
  -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 i686-pc-cygwin
Report bugs to <bug-make@gnu.org>
Administrator@PC-20130611GART /cygdrive/e/Dev_Root
$

果然对应的-j==–jobs,指的是多线程的意思:
-j [N], –jobs[=N] Allow N jobs at once; infinite jobs with no arg.

用法即:

?
1
make –j 4

?
1
make –jobs=4

make加上-s,表示silent,不输出详细log信息

之前折腾:

【记录】尝试用QEMU模拟ARM开发板去加载并运行Uboot,kernel,rootfs

参考的:

Virtual Development Board

中就用到:

?
1
2
3
sudo make install -s
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- versatile_defconfig -s
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage -s

其中的-s参数,之前就猜测是silent的意思。

根本上面的–help输出的信息,果然是:

-s, –silent, –quiet Don’t echo recipes.

-f指定makefile文件

之前就知道的,可以通过-f指定特定的makefile文件的。

背景是:

当执行make时,默认会去(当前文件夹下)找名为Makefile的文件

如果此处你需要去运行特定文件名的makefile文件,比如my.mk

那么就可以通过-f去指定:

?
1
make –f my.mk

即可。

make help可以用来查看当前支持哪些目标

一般来说,多数的makefile文件,除了最常见的make all,make clean等最常见的目标之外,往往都会有自己不同的目标供执行,即:

make xxx

make yyy

等等。

而想要去查看,有哪些xxx和yyy供你使用,可以通过make help去查看。

举例:

最近折腾的:

【记录】Ubuntu下为QEMU的arm平台交叉编译BusyBox

中的make help的输出,就是:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
crifan@ubuntu:busybox-1.16.0$ make help
Cleaning:
  clean         - delete temporary files created by build
  distclean     - delete all non-source files (including .config)
  doc-clean     - delete all generated documentation
  
Build:
  all           - Executable and documentation
  busybox       - the swiss-army executable
  doc           - docs/BusyBox.{txt,html,1}
  html          - create html-based cross-reference
  
Configuration:
  allnoconfig       - disable all symbols in .config
  allyesconfig      - enable all symbols in .config (see defconfig)
  config        - text based configurator (of last resort)
  defconfig     - set .config to largest generic configuration
  menuconfig        - interactive curses-based configurator
  oldconfig     - resolve any unresolved symbols in .config
  hosttools         - build sed for the host.
              You can use these commands if the commands on the host
              is unusable. Afterwards use it like:
              make SED="/home/crifan/develop/embedded/qemu/rootfs/busybox/busybox-1.16.0/sed"
  
Installation:
  install       - install busybox into CONFIG_PREFIX
  uninstall
  
Development:
  baseline      - create busybox_old for bloatcheck.
  bloatcheck        - show size difference between old and new versions
  check         - run the test suite for all applets
  checkhelp     - check for missing help-entries in Config.in
  randconfig        - generate a random configuration
  release       - create a distribution tarball
  sizes         - show size of all enabled busybox symbols
  objsizes      - show size of each .o object built
  bigdata       - show data objects, biggest first
  stksizes      - show stack users, biggest first

如此,就知道了:

当前的busybox的makefile中,支持如此多的目标,而想要查看当前busybox的各种stack信息,就可以去试试那个stksizes了:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
crifan@ubuntu:busybox-1.16.0$ make ARCH=arm CROSS_COMPILE=arm-xscale-linux-gnueabi- stksizes
arm-xscale-linux-gnueabi-objdump -d busybox_unstripped | /home/crifan/develop/embedded/qemu/rootfs/busybox/busybox-1.16.0/scripts/checkstack.pl arm | uniq
buffered_vfprintf [busybox_unstripped]:         8384
phys_pages_info [busybox_unstripped]:           8192
__get_nprocs [busybox_unstripped]:          8192
__res_vinit [busybox_unstripped]:           8192
_IO_wfile_seekoff [busybox_unstripped]:         4224
__unix_grantpt [busybox_unstripped]:            4224
_IO_vfwprintf [busybox_unstripped]:         4224
grantpt [busybox_unstripped]:               4160
bb_full_fd_action [busybox_unstripped]:         4096
find_list_entry2 [busybox_unstripped]:          4096
readlink_main [busybox_unstripped]:         4096
pid_is_exec [busybox_unstripped]:           4096
execle [busybox_unstripped]:                4096
execl [busybox_unstripped]:             4096
execlp [busybox_unstripped]:                4096
_dl_get_origin [busybox_unstripped]:            4096
ipaddr_list_or_flush [busybox_unstripped]:      3664
iproute_list_or_flush [busybox_unstripped]:     3648
__c32 [busybox_unstripped]:             3600
buffered_vfprintf [busybox_unstripped]:         3302
__mpatan [busybox_unstripped]:              2976
fallbackSort [busybox_unstripped]:          2928
atan2Mp.constprop.0 [busybox_unstripped]:       2304
__mpsqrt [busybox_unstripped]:              2304
__slowpow [busybox_unstripped]:             2304
cal_main [busybox_unstripped]:              2288
internal_fnmatch [busybox_unstripped]:          2144
doCommands [busybox_unstripped]:            2112
__slowexp [busybox_unstripped]:             1984
__mpexp [busybox_unstripped]:               1984
normalized [busybox_unstripped]:            1968
get_next_block [busybox_unstripped]:            1968
identify_from_stdin [busybox_unstripped]:       1792
__ieee754_log [busybox_unstripped]:         1648
huft_build [busybox_unstripped]:            1488
iproute_modify [busybox_unstripped]:            1376
svc_getreq_common [busybox_unstripped]:         1328
__mpatan2 [busybox_unstripped]:             1312
inflate_block [busybox_unstripped]:         1296
_IO_vfprintf [busybox_unstripped]:          1296
__libc_message [busybox_unstripped]:            1280
getlogin_r [busybox_unstripped]:            1280
mainQSort3.constprop.2 [busybox_unstripped]:        1264
__gettextparse [busybox_unstripped]:            1248
iproute_get [busybox_unstripped]:           1184
rx_main [busybox_unstripped]:               1152
ether_wake_main [busybox_unstripped]:           1152
procps_scan [busybox_unstripped]:           1152
unwind_phase2_forced [busybox_unstripped]:      1152
build_trtable [busybox_unstripped]:         1126
wget_main [busybox_unstripped]:             1120
iprule_modify [busybox_unstripped]:         1120
getopt32 [busybox_unstripped]:              1104
_svcauth_des [busybox_unstripped]:          1088
two_way_long_needle [busybox_unstripped]:       1056
ether_hostton [busybox_unstripped]:         1056
check_existence_through_netlink [busybox_unstripped]:   1040
two_way_long_needle [busybox_unstripped]:       1040
clnt_sperror [busybox_unstripped]:          1040
clnt_spcreateerror [busybox_unstripped]:        1040
_dl_signal_error [busybox_unstripped]:          1040
internal_fnwmatch [busybox_unstripped]:         1030
bad_zone [busybox_unstripped]:              1024
get_dirsize [busybox_unstripped]:           1024
map_block2 [busybox_unstripped]:            1024
map_block [busybox_unstripped]:             1024
addLines [busybox_unstripped]:              1024
getNum [busybox_unstripped]:                1024
perror_internal [busybox_unstripped]:           1024
__getmntent_r [busybox_unstripped]:         1024
__mpsin [busybox_unstripped]:               996
__mpcos [busybox_unstripped]:               996
__mpsin1 [busybox_unstripped]:              992
__mpcos1 [busybox_unstripped]:              992
__sin32 [busybox_unstripped]:               988
__cos32 [busybox_unstripped]:               988
__mpranred [busybox_unstripped]:            988
__mplog [busybox_unstripped]:               984
udhcpc_main [busybox_unstripped]:           884
dhcprelay_main [busybox_unstripped]:            836
udhcpd_main [busybox_unstripped]:           824
sha512_process_block128 [busybox_unstripped]:       812
glob_in_dir [busybox_unstripped]:           804
init_exec [busybox_unstripped]:             788
write_wtmp [busybox_unstripped]:            780
nfsmount [busybox_unstripped]:              732
do_tunnels_list [busybox_unstripped]:           724
print_tunnel [busybox_unstripped]:          712
pututline_file [busybox_unstripped]:            708
if_readlist_proc [busybox_unstripped]:          696
udhcp_send_raw_packet [busybox_unstripped]:     692
arp_show [busybox_unstripped]:              684
__inv [busybox_unstripped]:             664
__gnu_Unwind_Backtrace [busybox_unstripped]:        664
udhcp_recv_raw_packet [busybox_unstripped]:     660
print_login_issue [busybox_unstripped]:         656
send_ACK [busybox_unstripped]:              644
send_release [busybox_unstripped]:          644
send_offer [busybox_unstripped]:            640
send_renew [busybox_unstripped]:            640
send_NAK [busybox_unstripped]:              636
send_discover [busybox_unstripped]:         636
send_inform [busybox_unstripped]:           632
send_decline [busybox_unstripped]:          632
send_select [busybox_unstripped]:           632
ash_main [busybox_unstripped]:              632
dnsd_main [busybox_unstripped]:             604
_dl_start_profile [busybox_unstripped]:         604
sha_crypt [busybox_unstripped]:             596
__gnu_Unwind_RaiseException [busybox_unstripped]:   580
_dl_map_object [busybox_unstripped]:            580
inetd_main [busybox_unstripped]:            576
readtoken1 [busybox_unstripped]:            572
_dl_debug_vdprintf [busybox_unstripped]:        556
process_dev [busybox_unstripped]:           544
get_header_tar [busybox_unstripped]:            540
uname_main [busybox_unstripped]:            540
last_main [busybox_unstripped]:             532
glob_in_dir [busybox_unstripped]:           532
dir_act [busybox_unstripped]:               524
retrieve_file_data [busybox_unstripped]:        524
log_option [busybox_unstripped]:            524
gaih_inet [busybox_unstripped]:             520
readprofile_main [busybox_unstripped]:          516
writeTarHeader [busybox_unstripped]:            516
_IO_vfscanf [busybox_unstripped]:           516
handle_net_output [busybox_unstripped]:         512
writeLongname [busybox_unstripped]:         512
getnameinfo [busybox_unstripped]:           484
print_addrinfo [busybox_unstripped]:            480
_nl_load_locale_from_archive [busybox_unstripped]:  460
read_alias_file [busybox_unstripped]:           460
_dl_discover_osversion [busybox_unstripped]:        460
authunix_create [busybox_unstripped]:           456
login_main [busybox_unstripped]:            452
print_route [busybox_unstripped]:           444
evalfun [busybox_unstripped]:               440
_dl_catch_error [busybox_unstripped]:           440
brctl_main [busybox_unstripped]:            420
evalbltin.isra.1 [busybox_unstripped]:          420
evaltree [busybox_unstripped]:              420
setvarsafe [busybox_unstripped]:            416
redirectsafe [busybox_unstripped]:          416
crond_main [busybox_unstripped]:            412
modprobe_main [busybox_unstripped]:         412
ipaddr_modify [busybox_unstripped]:         412
scan_proc_net [busybox_unstripped]:         412
_Unwind_VRS_Pop [busybox_unstripped]:           412
__sleep [busybox_unstripped]:               408
____strtod_l_internal [busybox_unstripped]:     404
exitshell [busybox_unstripped]:             404
bb_ask [busybox_unstripped]:                404
get_linux_version_code [busybox_unstripped]:        396
safe_gethostname [busybox_unstripped]:          396
safe_getdomainname [busybox_unstripped]:        396
getdomainname [busybox_unstripped]:         396
runsv_main [busybox_unstripped]:            392
__gethostname [busybox_unstripped]:         392
update_utmp [busybox_unstripped]:           384
print_rule [busybox_unstripped]:            384
parse_config_file [busybox_unstripped]:         380
reread_config_file [busybox_unstripped]:        380
set_loop [busybox_unstripped]:              380
fbset_main [busybox_unstripped]:            372
find_block_device [busybox_unstripped]:         372
arping_main [busybox_unstripped]:           364
_IO_vdprintf [busybox_unstripped]:          364
md5_crypt [busybox_unstripped]:             356
passwd_main [busybox_unstripped]:           348
__mbsrtowcs_l [busybox_unstripped]:         348
list_devs_in_proc_partititons [busybox_unstripped]: 344
sha1_process_block64 [busybox_unstripped]:      340
__glob64 [busybox_unstripped]:              340
display_process_list [busybox_unstripped]:      332
__wcsrtombs [busybox_unstripped]:           332
INET6_displayroutes [busybox_unstripped]:       328
__dvd [busybox_unstripped]:             328
mainSort [busybox_unstripped]:              324
__mbsnrtowcs [busybox_unstripped]:          324
__ttyname_r [busybox_unstripped]:           324
glob [busybox_unstripped]:              324
sulogin_main [busybox_unstripped]:          316
makedevs_main [busybox_unstripped]:         316
re_compile_fastmap_iter.isra.40 [busybox_unstripped]:   316
do_lzo_decompress [busybox_unstripped]:         312
do_system [busybox_unstripped]:             312
do_lzo_compress [busybox_unstripped]:           308
updwtmp_file [busybox_unstripped]:          308
getutline_r_file [busybox_unstripped]:          308
correct_password [busybox_unstripped]:          304
__libc_start_main [busybox_unstripped]:         304
telnetd_main [busybox_unstripped]:          300
read_line_input [busybox_unstripped]:           300
re_search_internal [busybox_unstripped]:        300
internal_getut_r [busybox_unstripped]:          300
crifan@ubuntu:busybox-1.16.0$

转自: http://www.crifan.com/summary_usage_about_make_linux_command/
												

Linux下的make命令使用心得相关推荐

  1. linux将文件夹树状列出,Linux下用tree命令列出树形图

    命令用法: tree 参数: -a 显示所有文件和目录. -A 使用ASNI绘图字符显示树状图而非以ASCII字符组合. -C 在文件和目录清单加上色彩,便于区分各种类型. -d 显示目录名称而非内容 ...

  2. Linux下解析域名命令-dig 命令使用详解

    Linux下解析域名除了使用nslookup之外,开可以使用dig命令来解析域名,dig命令可以得到更多的域名信息.dig 命令主要用来从 DNS 域名服务器查询主机地址信息.dig的全称是 (dom ...

  3. Linux下视频截取命令

    比如你有一个视频,然后你对其中某一段感兴趣,你想把他截取下来,并且不希望画面变差,(当然你也不想花钱买视频编辑软件),可以在Linux下使用如下命令: ffmpeg -ss 00:00:05 -t 0 ...

  4. linux命令输入错误怎么弄,Linux下用shopt命令来帮我们自动纠错输入cd 错误

    下面是关于shopt命令的一些参数的用法 选项 含义 cdable_vars 如果给cd内置命令的参数不是一个目录,就假设它是一个变量名,变量的值是将要转换到的目录 cdspell 纠正cd命令中目录 ...

  5. linux查看设备内存代码,Linux下内存查看命令(示例代码)

    在Linux下面,我们常用top命令来查看系统进程,top也能显示系统内存.我们常用的Linux下查看内容的专用工具是free命令. Linux下内存查看命令free详解: 在Linux下查看内存我们 ...

  6. linux下Vi编辑器命令大全

    linux下Vi编辑器命令大全 /根目录下的文件夹 输入"/",回车 里面有很多文件夹,如:etc,home,lib,mnt等等 etc:存放用户名和密码 home:每个用户有个文 ...

  7. [20161229]linux下使用oclumon命令(rac)

    [20161229]linux下使用oclumon命令(rac).txt --11G RAC下grid 存在一个命令oclumon可以了解监测群集健康.简单了解一下. 1.环境: SYS@+ASM1& ...

  8. Linux下使用mail命令发送邮件

    因为需要经常备份网站的数据,所以了解并学习了下linux下如何通过shell来发送邮件,这里以CentOS为例,使用mail命令来进行外部邮件的发送.mail命令的语法如下: Usage: mail ...

  9. 【Linux】5.linux下的export命令和环境变量

    linux下的export命令和环境变量 linux中在 profile 或者 bashrc 或者其他类似的文件中设置环境变量时(比如PATH),如果没有export,那么只能在直接启动的shell中 ...

  10. |9 其他(linux特定的), 用来存放内核例行程序的文档.,Linux下的帮助命令

    Linux下的帮助命令 一.内建命令与外部命令 内建命令实际上是 shell 程序的一部分,其中包含的是一些比较简单的 Linux 系统命令,这些命令是写在bash源码的builtins里面的,并由 ...

最新文章

  1. 处理机调度的性能准则
  2. python中浅拷贝和深拷贝分析
  3. UGUI_不规则按钮的响应区域
  4. TensorFlow2.0(三)--Keras构建神经网络回归模型
  5. 有状态容器实践:k8s集成ceph分布式存储
  6. c# 设为首页和加入收藏代码
  7. Android网络编程之——文件断点下载(暂停/继续/重新下载)
  8. 中职生计算机应用基础心得,关于中职计算机应用基础教学的几点心得
  9. Android手机开启开发者模式
  10. 传教士与野人过河问题
  11. java计算机毕业设计基于安卓/微信小程序的健身房健身管理系统
  12. sed解析url的域名
  13. 7.3 使用“设计视图”创建报表
  14. 简单明了,彻底地理解Binder
  15. 写信中“敬启者”与“敬启”的区别
  16. C语言求斜边程序,用C语言编写勾股定理求斜边
  17. 分布式商城项目-后台开发-SSM工程整合网站模板
  18. 微信小程序 物联网解决方案
  19. android设置字体为微软雅黑,css如何设置字体为微软雅黑
  20. js怎么获取复选框选中的值

热门文章

  1. android studio链接海马玩模拟器
  2. APICloud Studio 在海马玩模拟器上调试程序
  3. iOS10 适配汇总
  4. 吴恩达deeplearning之CNN—人脸识别与风格化转换(2)
  5. [Lisp] [Scheme][MacOS]Scheme语言环境搭建
  6. js事件冒泡与事件捕获、阻止事件冒泡和浏览器默认行为
  7. WORKGROUP无法访问,您可能没有权限使用网络资源,请与这台服务器的管理员联系以.......
  8. ADSL自动更换IP的方法
  9. php addslashes 防注入,PHP基础-addslashes防sql注入-北漂者
  10. 网页调用rm播放器代码 - 详细说明