我对MAKE的理解正确吗?

发布于 2024-11-07 02:29:14 字数 428 浏览 0 评论 0原文

以 GNU make 应用程序为例,当我创建 makefile 时,它​​类似于 Visual Studio 项目文件,因为它包含编译应用程序所需的文件列表和其他项目。 makefile 包含编译器的路径以及编译操作中可能使用的所有文件的路径。 MAKE 应用程序读取 makefile 并将源代码组合成 1 个文件,然后编译器读取该文件并将其转换为相关的汇编/机器代码。

#include 指令是一个指令,它告诉 make 文件: “将此文件的内容包含到您要提供给编译器的较大文件的这一点,然后使用当前文件恢复”。

MAKE 应用程序还告诉编译器在编译完成后在哪里“发出”编译操作的结果。在这方面,Visual Studio .csproj 文件在技术上是一个基于 XML 的 makefile,用于 Microsoft 特定的 MAKE 应用程序。

这种对makefile的理解正确吗?

Taking the GNU make application as an example, when I create a makefile it is likened to a Visual Studio project file in that it contains the list of files and other items needed to compile an application. The makefile contains the path to the compiler as well as the path to all the files that could possibly be used in the compiling operation. The MAKE application reads the makefile and combines the sources into 1 file which the compiler then reads and converts into the relevant assembly/machine code.

The #include directive is a directive that tells the make file to:
"include the contents of this file into this point of the larger file that you're making to feed to the compiler then resume with the current file".

The MAKE application also tells the compiler where to "emit" the result of the compile operation once the compiling is completed. In this regard a Visual Studio .csproj file is technically a XML based makefile for a Microsoft specific MAKE application.

Is this understanding of makefiles correct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

庆幸我还是我 2024-11-14 02:29:14

大约是的。然而,还有许多细节值得挑剔。

以 GNU make 应用程序为例,当我创建 makefile 时,它​​类似于 Visual Studio 项目文件,因为它包含编译应用程序所需的文件列表和其他项目。

这相当接近准确。

makefile 包含编译器的路径以及编译操作中可能使用的所有文件的路径。

makefile 通常不包含编译器的路径,尽管它可以包含。它将包含编译中可能使用的文件列表。

MAKE 应用程序读取 makefile 并将源代码组合成 1 个文件,然后编译器读取该文件并将其转换为相关的汇编/机器代码。

这不是很准确。细节有所不同,但聚合不是由 MAKE 完成的,而是由 MAKE 调用的编译器完成的。除了简单的源代码到机器代码转换之外,MAKE 还可用于其他任务。

#include 指令是一个指令,它告诉 make 文件:“将此文件的内容包含到您要提供给编译器的较大文件的这一点,然后使用当前文件恢复”。< /p>

GNU Make(和 POSIX Make)支持 include 指令来合并 makefile 的其他片段。 C 和 C++ 编译器识别 #include 指令 - 并且 makefile 通常需要了解编译程序所需的标头(由 #include 指令包含) 。然而,#include 是 makefile 中的一个简单注释。

MAKE 应用程序还告诉编译器在编译完成后在哪里“发出”编译操作的结果。

makefile 包含有关生成的代码应放置在何处的信息,并告知编译器是否需要知道。

在这方面,Visual Studio .csproj 文件在技术上是一个基于 XML 的 makefile,用于 Microsoft 特定的 MAKE 应用程序。

这是对描述的合理近似。

Approximately, yes. However there are numerous details to cavil at.

Taking the GNU make application as an example, when I create a makefile it is likened to a Visual Studio project file in that it contains the list of files and other items needed to compile an application.

That is reasonably close to accurate.

The makefile contains the path to the compiler as well as the path to all the files that could possibly be used in the compiling operation.

The makefile typically does not contain the path to the compiler, though it could. It would contain a list of the files that might be used in the compilation.

The MAKE application reads the makefile and combines the sources into 1 file which the compiler then reads and converts into the relevant assembly/machine code.

This is not very accurate. The details vary, but the aggregation is not done by MAKE, but by the compilers that MAKE invokes. MAKE can be used for other tasks than simple source to machine code translation.

The #include directive is a directive that tells the make file to: "include the contents of this file into this point of the larger file that you're making to feed to the compiler then resume with the current file".

GNU Make (and POSIX Make) supports an include directive to incorporate other fragments of a makefile. The C and C++ compilers recognize the #include directive - and the makefile often needs to be briefed on which headers (included by the #include directive) are needed to compile the program. However, #include is a simple comment in a makefile.

The MAKE application also tells the compiler where to "emit" the result of the compile operation once the compiling is completed.

The makefile contains the information about where the generated code should be placed, and the compiler is told if it needs to know.

In this regard a Visual Studio .csproj file is technically a XML based makefile for a Microsoft specific MAKE application.

That is a reasonable approximation to the description.

画骨成沙 2024-11-14 02:29:14

具体来说,您是对的,因为 makefile 可以这样使用并且经常如此。通常,make 实用程序按照以下规则解决依赖性,这些规则说明哪些项(主要是文件)依赖于其他项以及要采取哪些步骤(例如编译操作)来满足依赖性。 makefile 中的变量和规则遵循 make 实用程序的语法。

Specifically you are right in that a makefile can be used this way and often are. Generally the make utility resolves dependencies in following rules stating which items (mostly files) depend on others and what steps (e. g. compile operations) are to be taken to fulfill the dependency. Variables and rules within makefiles adhere to the make utility's syntax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文