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 := 1
endif
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
中的:
1make
ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j4
此时,才想到,去查查make的参数:
(此处是在cygwin中)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849Administrator@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
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
|
之前折腾:
【记录】尝试用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文件的。
背景是:
当执行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/