make命令OPTIONS总览表 GNU make

make命令OPTIONS总览表 GNU make

make版本: GNU Make 4.3

注意:按字典顺序

  • -b, -m
    • 忽略和其它版本make的兼容性,也就是说当前版本的make不兼容之前版本的make
  • -B, --always-make
    • 认为所有的目标都需要更新(重编译),无条件执行规则
  • -C dir, --directory=dir
    • 读取makefile前,先切换到指定目录dir,如果多次使用-C参数,每个-C选项的路径都相对于前一个选项
    • make -C /HOME -C src等价于make -C /HOME/src
  • -d
    • 除正常处理外,还打印调试信息。 调试信息表明正在考虑重新制作哪些文件,正在比较哪些文件时间以及什么结果,实际上需要重新制作哪些文件,考虑哪些隐式规则并应用了这些信息等等
  • –debug[=FLAGS]
    • 除正常处理外,还打印调试信息
    • 关于FLAGS参数的说明如下
      • 缺省: 和使用选项-d的功能一样
      • a : all的头字母,所有调试信息都输出(与使用-d相同)
      • b : basic的头字母,只输出简单的调试信息,即输出不需要重编译的目标
      • v : verbose的头字母,更加详细的基本信息。在b选项的级别之上。输出的信息包括哪个makefile被解析,不需要被重编译的依赖文件(或是依赖目标)等等
      • i : implicit的头字母,输出隐式规则的信息
      • j : jobs的头字母,命令调用的详细信息,如命令的PID、返回码等
      • m : makefile的头字母,在重新执行makefile时进行调试,输出make读取makefile,更新makefile,执行makefile等的信息
      • n : No/None,禁用所有先前的调试标志。
  • -e, --environment-overrides
    • 指明环境变量具有更高的优先级,即对于同名的变量,环境变量的值覆盖makefile中定义的变量的值。
  • -E string, --eval string
    • 在解析任何makefile文件之前,使用eval函数解释字符串。这个eval函数有点复杂。
  • -f file, --file=file, --makefile=FILE
    • 将file作为将要执行的makefile
  • -i, --ignore-errors
    • 忽略所有执行时的错误
  • -I dir, --include-dir=dir
    • 指定目录dir以搜索包含的makefile。 如果使用多个-I选项指定多个目录,则将按指定的顺序搜索目录。与make的其他标志的参数不同,用-I标志给定的目录可能紧接在标志之后:-Idir以及-I dir。 为了与C预处理程序的-I标志兼容,允许使用此语法。
  • -j [jobs], --jobs[=jobs]
    • 指定要同时运行的作业(命令)数。 如果有多个-j选项,则最后一个有效。 如果给-j选项不带参数,make将不会限制可以同时运行的作业数量。与多线程编译过程的意思类似。
  • -k, --keep-going
    • 发生错误后,尽可能地继续执行。 虽然无法重建失败的目标以及依赖它的目标,但是可以完全处理这些目标的其他依赖项。
  • -l [load], --load-average[=load]
    • 指定如果还有其他作业正在运行并且平均负载至少为load(浮点数),则不应启动任何新作业(命令)。 不带参数时,删除先前的负载限制。
  • -L, --check-symlink-times
    • 在符号链接和目标之间使用最新的mtime。
  • -n, --just-print, --dry-run, --recon
    • 打印将要执行的命令,但不执行它们(在某些情况下除外,需要触发规则执行时,才打印)。
  • -o file, --old-file=file, --assume-old=file
    • 即使文件file比其依赖项早,也不要重新制作文件,也不要由于文件的更改而重新制作任何文件。 本质上,该文件被视为非常旧,并且其规则被忽略。
  • -O[type], --output-sync[=type]
    • 与-j并行运行多个作业时,确保将每个作业的输出收集在一起,而不是散布在其他作业的输出中。
    • type的取值情况说明如下
      • 缺省: 将每个目标的整个配方(包含连带的规则)的输出分组在一起
      • target: 与缺省一样
      • line: 配方中每个命令行的输出将分组在一起
      • recurse: 整个递归make的输出分组在一起
      • none: 禁用输出同步
  • -p, --print-data-base
    • 打印由于读取makefile而产生的数据库(所有规则和变量值), 然后照常执行或按照其他规定执行,所以会打印出一堆信息。 这还将打印由-v开关给出的版本信息(请参见下文)。
    • 如果你只是想输出信息而不想执行makefile,你可以使用make -qp命令。
    • 如果你想查看执行makefile前的预设变量和规则,你可以使用make –p –f /dev/null。这个参数输出的信息会包含着你的makefile文件的文件名和行号,所以,用这个参数来调试你的makefile会是很有用的,特别是当你的环境变量很复杂的时候。
  • -q, --question
    • “问题模式”。 不要运行任何命令或打印任何内容; 如果指定的目标已经是最新的,则仅返回退出状态为零,否则返回非零。
  • -r, --no-builtin-rules
    • 消除对内置隐式规则的使用。 还要清除后缀规则的默认后缀列表。
  • -R, --no-builtin-variables
    • 不定义任何内置变量。
  • -s, --silent, --quiet
    • 静音操作; 在执行命令时不打印命令。
  • –no-silent
    • 取消-s选项的效果。
  • -S, --no-keep-going, --stop
    • 取消-k选项的效果。
  • -t, --touch
    • 在不进行实际更改的情况下将它们标记为最新,而不是运行它们的命令。 这是为了假装命令已完成,以欺骗make的将来调用。
  • –trace
    • 打印有关每个目标的配置的信息(为什么要重建目标以及运行哪些命令来重建目标)。
  • -v, --version
    • 打印make程序的版本以及版权,作者列表和无保证的声明。
  • -w, --print-directory
    • 在其他处理之前和之后,打印包含工作目录的消息。 这对于跟踪复杂的递归make命令嵌套中的错误可能很有用。
  • –no-print-directory
    • 关闭-w,即使它已隐式打开。
  • -W file, --what-if=file, --new-file=file, --assume-new=file
    • 假定目标file需要更新,如果和“-n”选项使用,那么这个参数会输出该目标更新时的运行动作。如果没有“-n”那么就像运行UNIX的“touch”命令一样,使得file的修改时间为当前时间。
  • –warn-undefined-variables
    • 在引用未定义的变量时发出警告
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The utility simply known as make is one of the most enduring features of both Unix and other operating systems. First invented in the 1970s, make still turns up to this day as the central engine in most programming projects; it even builds the Linux kernel. In the third edition of the classic Managing Projects with GNU make, readers will learn why this utility continues to hold its top position in project build software, despite many younger competitors.The premise behind make is simple: after you change source files and want to rebuild your program or other output files, make checks timestamps to see what has changed and rebuilds just what you need, without wasting time rebuilding other files. But on top of this simple principle, make layers a rich collection of options that lets you manipulate multiple directories, build different versions of programs for different platforms, and customize your builds in other ways.This edition focuses on the GNU version of make, which has deservedly become the industry standard. GNU make contains powerful extensions that are explored in this book. It is also popular because it is free software and provides a version for almost every platform, including a version for Microsoft Windows as part of the free Cygwin project. Managing Projects with GNU make, 3rd Edition provides guidelines on meeting the needs of large, modern projects. Also added are a number of interesting advanced topics such as portability, parallelism, and use with Java.Robert Mecklenburg, author of the third edition, has used make for decades with a variety of platforms and languages. In this book he zealously lays forth how to get your builds to be as efficient as possible, reduce maintenance, avoid errors, and thoroughly understand what make is doing. Chapters on C++ and Java provide makefile entries optimized for projects in those languages. The author even includes a discussion of the makefile used to build the book.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值