如何将makefile转换为可读的代码?

发布于 2024-08-16 07:26:04 字数 100 浏览 3 评论 0原文

我在一本书上下载了一套程序的源代码,并得到了一个makefile。 我对Linux很陌生,我想知道是否有什么方法可以看到用C编写的实际源代码?

或者说我到底该拿它做什么?

I downloaded a set of source code for a program in a book and I got a makefile.
I am quite new to Linux, and I want to know whether there is any way I can see the actual source code written in C?

Or what exactly am I to do with it?

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

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

发布评论

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

评论(3

一口甜 2024-08-23 07:26:04

听起来您可能没有从本书网站下载完整源代码。如前所述,Makefile 只是构建源代码的指令,源代码通常位于名称以 .c结尾的其他文件中.h。也许您可以浏览图书网站以获取更多文件下载?

或者,由于该书的网站可能是公开的,请让我们知道它是哪一个,有人会很乐意为您指明正确的方向。

It sounds like you may not have downloaded the complete source code from the book web site. As mentioned previously, a Makefile is only the instructions for building the source code, and the source code is normally found in additional files with names ending in .c and .h. Perhaps you could look around the book web site for more files to download?

Or, since presumably the book web site is public, let us know which one it is and somebody will be happy to point you in the right direction.

陌路终见情 2024-08-23 07:26:04

Makefile 本身不包含任何源代码。它只是一个特殊格式的指令列表,指定应该运行哪些命令以及以什么顺序来构建程序。如果您想查看源代码在哪里,您的 Makefile 可能会包含许多“filename.c”和“filename.h”。您可以使用grep查找文件中所有“.c”和“.h”的实例,它们应该与项目中的C源文件和头文件相对应。以下命令应该可以解决问题:

grep -e '\.[ch]' Makefile

要使用 Makefile 构建项目,只需输入 make 就可以完成一些合理的操作。如果这不能满足您的要求,请查找以冒号结尾的未缩进的行;这些是目标名称,代表您可以在“make”后指定的不同参数,以构建项目的特定部分,或以某种方式构建它。例如,make installmake allmake debug 是常见目标。

您的系统上可能有 GNU Make; 更多有关 Makefile 的信息可以在此处。

A Makefile does not contain any source itself. It is simply a list of instructions in a special format which specifies what commands should be run, and in what order, to build your program. If you want to see where the source is, your Makefile will likely contain many "filename.c"'s and "filename.h"'s. You can use grep to find all the instances of ".c" and ".h" in the file, which should correspond to the C source and header files in the project. The following command should do the trick:

grep -e '\.[ch]' Makefile

To use the Makefile to build your project, simply typing make should do something reasonable. If that doesn't do what you want, look for unindented lines ending in a colon; these are target names, and represent different arguments you can specify after "make" to build a particular part of your project, or build it in a certain way. For instance, make install, make all, and make debug are common targets.

You probably have GNU Make on your system; much more information on Makefiles can be found here.

厌倦 2024-08-23 07:26:04

看来您还需要下载 SB-AllSource.zip 文件。然后使用 make(使用您已经下载的 Makefile)进行构建。

It looks like you also need to download the SB-AllSource.zip file. Then use make (with the Makefile that you've already downloaded) to build.

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