make 手册
命令来自于 Linux man make,补充都是直接粘贴的。
-
-B
Unconditionally make all targets.
编译所有项目,不跳过已经编译的。
-
-C dir, --directory=dir
Change to directory dir before reading the makefiles or doing anything else. If multiple -C options are speci‐ fied, each is interpreted relative to the previous one: -C / -C etc is equivalent to -C /etc. This is typi‐ cally used with recursive invocations of make.
在编译之前改变查找
makefile的文件夹,比如make -C /path/to/directory。这将使make在/path/to/directory中读取相应的 makefile 并执行构建操作。这在需要在项目的不同部分执行构建时很有用,尤其是在使用子目录或递归构建时。 -
-d
debug 模式,不做过多描述
-
-e
Give variables taken from the environment precedence over variables from makefiles.
-e或--environment-overrides选项用于使来自环境变量的变量优先于来自 makefile 的变量。这意味着如果环境变量中存在某个变量,它将覆盖在 makefile 中定义的同名变量。这可以用来方便地在构建过程中覆盖一些默认的设置,而不必修改 makefile。请注意,使用这个选项可能会导致一些不可预测的行为,因为它使环境变量对构建行为产生更直接的影响。 -
-f file, --file=file, --makefile=FILE
Use file as a makefile.
指定 Makefile 文件
-
-j [jobs]
Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously. When make invokes a sub-make, all instances of make will coordinate to run the speci‐fied number of jobs at a time; see the section PARALLEL MAKE AND THE JOBSERVER for details.
指定同时运行几个
make任务。对于大型任务有用,但是可能会导致资源竞争和不稳定,最佳值取决于系统资源。通常建议选择与系统核心数相当或稍小于系统核心数的值。 -
-i
Ignore all errors in commands executed to remake files.
这个命令告诉
make在构建过程中忽略错误,继续尝试构建其他目标。这对于在构建大型项目时,想要查看所有可能的错误而不中断整个构建过程的情况很有用。但要注意,由于错误被忽略,可能会导致生成的结果不可靠,因此需要谨慎使用。 -
-k
Continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same.
make -k命令用于继续构建过程,即使某个目标构建失败。它允许make在构建过程中继续尝试构建其他目标,而不会在首次构建失败时立即停止。 -
-l [load]
Specifies that no new jobs (commands) should be started if there are others jobs running and the load average is at least load (a floating-point number). With no argument, removes a previous load limit.
-l选项后的数字(例如2.0)表示系统的负载阈值。这个数字指定了系统负载的上限,当系统负载超过这个阈值时,make将不再启动新的作业。 -
-n
Print the commands that would be executed, but do not execute them (except in certain circumstances).
用于展示构建过程中即将执行的命令,但实际上并不执行这些命令。
-
-O
When running multiple jobs in parallel with -j, ensure the output of each job is collected together rather than interspersed with output from other jobs. If type is not specified or is target the output from the entire recipe for each target is grouped together. If type is line the output from each command line within a recipe is grouped together. If type is recurse output from an entire recursive make is grouped together. If type is none output synchronization is disabled.
选项的语法是
-O[type],其中type是可选的,用于指定输出同步的方式。以下是可能的type值和它们的含义:-
target: 如果
type未指定或指定为target,则整个目标的输出将被集中在一起。即,每个目标的输出会分别显示,而不会与其他目标的输出混合。make -j4 -Otarget -
line: 如果
type指定为line,则每个命令行的输出将被集中在一起。即,在同一个命令行中的输出会显示在一起,而不会与其他命令行的输出混合。make -j4 -Oline -
recurse: 如果
type指定为recurse,则整个递归调用的输出将被集中在一起。这对于处理递归调用的情况很有用。make -j4 -Orecurse -
none: 如果
type指定为none,则禁用输出同步,输出将按照它们生成的顺序显示,可能会与其他作业的输出混合。make -j4 -Onone
这个选项通常用于改善并行构建的输出可读性,确保输出不会交错混合,使得构建日志更易于理解。
-
-
-p
Print the data base (rules and variable values) that results from reading the makefiles; then execute as usual or as otherwise specified. This also prints the version information given by the -v switch (see below). To print the data base without trying to remake any files, use make -p -f/dev/null.
这个选项会输出
make解析 makefile 后的内部数据结构,包括规则、变量值等。这对于调试 makefile 或查看make内部对 makefile 的解释非常有用。 -
-s
Silent operation; do not print the commands as they are executed.
使用这个选项的目的通常是减少输出,使构建过程更加清晰,只显示关键信息。