c - GNU、autotools 的 makefile - 构建 C 语言源代码的规则和方法

标签 c makefile autotools rules recipe

对于从 C 语言源代码构建程序,如果后者是由自动工具以标准方式生成的,则如何指定 makefile 中的规则和规则配方? 这意味着在 autoconf、automake 和配置时不进行任何修改。 假设没有使用 libtool。 GNU 系统和构建工具。

这两个单独的规则是否一个用于编译另一个用于链接? 自动工具到底应用什么形式的配方?

我在automake手册中没有找到这些规范。 然而,该手册中很好地指定了其他一些编程语言的规则-目标对。

换句话说,在上面指出的假设下,哪里指定了自动工具生成的 makefile 如何从 C 源代码构建程序?

最佳答案

For building a program from C-language source how are the rules and rule's recipes in makefile specified if latter one is generated by autotools in standard way?

Autotools 旨在实现 GNU 编码标准,因为它们适用于构建系统,如链接所述,in the Automake manual 。编码标准有单独的文档,包括 the standard user-facing targets that Makefiles are expected to provide 。 Automake 提供了这些。

此外,Automake 文档 some targets intended for use as extension points由开发商。 Automake 要么提供这些,要么在开发人员提供的情况下使用它们。

此外,Automake 还为您在 Makefile.am 中明确指定的每个目标提供了一条规则。您可以在非递归构建系统中自由使用这些,但如果您的构建系统是递归的,则 YMMV。

当然,Autotools makefile 包含的目标比这些多得多,但它们的名称应该被视为实现细节。所有规则配方也是实现细节,尽管您可以从 the documentation of the various Automake variables and how they work 中预测其中一些规则的很多内容。 。如果您很好奇,那么查看生成的 Makefile.inMakefile 怎么样?

Are these two separate rules one for compiling another one for linkage?

从使用基于 Autotools 的构建系统构建项目不仅会生成最终目标,还会为每个源文件生成一个目标文件这一事实来看,我们可以确定,至少在当前版本的 Autotools 中,确实存在将源代码编译为目标文件的规则以及将对象链接到可执行文件和/或库的规则。同样,您也可以只查看生成的 Makefile[.in]。

Recipes of what form exactly do autotools apply?

具体细节没有记录,原则上,Automake 版本之间可能会有所不同。但同样,您可以从变量中推断出很多信息,并且始终可以生成一个示例来研究。

I haven't found these specifications in automake manual. However rule-target pairs for some other programing languages are pretty well specified in that manual.

AutoMake 手册讨论特定语言的具体规定的主要位置是 in chapter 8, Building Programs and Libraries 。前几节描述了一般情况下以及 Autotools 的标准目标语言 C 的工作原理,然后有几节描述了其他受支持语言的规定。该手册实际上指定了用于 Fortran 77 和 Fortran 95 源代码的构建规则的形式,但不清楚原因。无论如何,这些都是异常(exception)。其他语言没有提供类似的功能。

In other words where is specified how makefiles generated by autotools build programs from C-sources, under assumptions as pointed out above?

C 源代码的构建规则的具体形式没有记录,但从更一般的意义上来说,这是本手册第 2 - 4 章以及第 8 章大部分内容的主题。

关于c - GNU、autotools 的 makefile - 构建 C 语言源代码的规则和方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53048549/

相关文章:

c - 如何在 C 中将整数转换为十六进制字符串?

c++ -/usr/bin/ld : cannot open output file bin/genericMatching: No such file or directory

c++ - 如何在 Linux 的 makefile 中使用 headerfile(.h) 文件中定义的宏定义

makefile - 如何在 include 的子目录中安装 automake 安装头文件

c++ - somelib++ 的 PKG_CHECK_MODULES

c - 使用 doxygen 记录结构定义之外的 c 结构成员

c - 两个 union 的算术,未定义的行为?

c - 通过网络发送数字时是否必须颠倒字节顺序?

visual-studio - 为什么要通过 make 文件而不是 visual studio build 来构建大型项目?

c - 在使用 AM_LDFLAGS 的项目的 makefile 中编写依赖关系规则