最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】Linux下的make命令使用心得

Embedded crifan 12339浏览 0评论

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

 

之前在折腾crosstool-ng:

【记录】crosstool为xscale编译(ct-ng build)过程

时,就偶尔看到别人用

ct-ng build.4

意思是多线程去编译

估计底层就是调用的makefile的支持多线程的这个功能。

后来又在别处看到类似的写法了:

Introduction to Cross Compilation

中的:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j4

此时,才想到,去查查make的参数:

(此处是在cygwin中)

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 <[email protected]>

Administrator@PC-20130611GART /cygdrive/e/Dev_Root
$

果然对应的-j==–jobs,指的是多线程的意思:

-j [N], –jobs[=N] Allow N jobs at once; infinite jobs with no arg.

用法即:

make –j 4

make –jobs=4

 

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

之前折腾:

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

参考的:

Virtual Development Board

中就用到:

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去指定:

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的输出,就是:

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了:

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$ 

 

5.

转载请注明:在路上 » 【整理】Linux下的make命令使用心得

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
81 queries in 0.230 seconds, using 22.10MB memory