问题描述
在哪里我们把所有的Makefile文件?
Where do we put the all in a Makefiles?
我有一个类似的问题,发现,但我需要一点点位的更多细节。我又看了看,但在山上迷路了的文档。我尝试了谷歌,但没有找到一个很好的例子。于是,我做了什么,是我最后的手段,试图通过在自己的Makefile黑客弄明白。我有:
I had a similar question found earlier, but I needed a little bit more details. I also looked at the GNU make manual, but got lost in the mountain of documentation. I tried the googles, but didn't find a good example. So, I did what was my last resort and tried to figure it out by hacking at a Makefile myself. I have:
CC=gcc
CFLAGS=-Wall -g
clean:
rm -f all: ex1
这没有编译我的EX1在C.另外,如果我想更添加到此make文件。像EX1,EX2,锻炼什么的。我只想把所有的顶部和重复
This didn't compile my ex1 in C. Also, if I wanted to add more to this make file. Like ex1, ex2, to exercise whatever. Would I just put the all at the top and repeat the
rm - f whatever
下面的清洁线?
line below clean?
鸭preciate您的帮助和援助。耐心AP preciated了。
Appreciate your help and assistance. Patience appreciated too.
推荐答案
所有
其实没什么特别的,只是一个目标名称常用。使它工作最好,它应该是在该文件中的第一个目标。这使得默认目标,而使用gmake
的工作方式相同使用gmake均
。
all
is actually nothing special, just a target name commonly used. To make it work best, it should be the first target in the file. This makes it the default target, and gmake
works the same as gmake all
.
通常情况下,所有
目标具有相关性,这是它需要建立的事情。例如。
Normally, the all
target has dependencies, which are the things which need to be built. E.g.
all: myexe
RM
是关系到清洁
目标(这也是没什么特别的,只是一个名字常用)。你定义它是这样的:
rm
is related to the clean
target (which is also nothing special, just a name commonly used). You define it this way:
clean:
rm -f myexe
这使得它删除 myexe
在使用gmake干净
运行。如果Makefile将其他文件,他们也应该被列出。
This makes it delete myexe
when gmake clean
is run. If you makefile builds other files, they should also be listed there.
有很多更了解makefile文件。通常你会使用变量和模板规则,这有助于你避免重复自己。但是,这远远超过了简单的答案可以形容。
There's a lot more to know about makefiles. Normally you would use variables and template rules, which help you avoid repeating yourself. But this is far more than a simple answer can describe.
这篇关于哪里“全部”属于在一个Makefile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!