[英]How do I make a target in a makefile invoke another target in the makefile
So I have this makefile and I want the target all just to invoke the target expertest, but apparently the way I'm doing it is wrong because i'm getting the error "make: exprtest: Command not found make: * [all] Error 127 " this is the makefile: 所以我有这个makefile,我希望目标只是调用目标expertest,但显然我正在做的方式是错误的,因为我收到错误“make:exprtest:Command not found make: * [all]错误127“这是makefile:
all:
exprtest
exprtest: exptrtest.o driver.o parser.tab.o scanner.o
g++ -Wall -g -o exprtest exptrtest.o driver.o parser.tab.o scanner.o
driver.o: driver.cpp scanner.hpp driver.hpp
g++ -Wall -g -c driver.cpp
parser.tab.o: parser.tab.hpp parser.tab.cpp
bison parser.ypp
g++ -Wall -g -c parser.tab.cpp
scanner.o: scanner.cpp scanner.hpp
flex -t scanner.ll > scanner.cpp
g++ -Wall -g -c scanner.cpp
clean:
rm parser.tab.hpp parser.tab.cpp scanner.cpp
Put exprtest
on the same line as all
. 将
exprtest
放在与all
相同的行上。 Dependencies come after the colon, commands come on the following lines, indented. 冒号后面的依赖关系,命令来自以下行,缩进。
target: dependencies
[tab] system command
So in your case it all becomes: 所以在你的情况下,这一切都变为:
all: exprtest
exprtest: exptrtest.o driver.o parser.tab.o scanner.o
g++ -Wall -g -o exprtest exptrtest.o driver.o parser.tab.o scanner.o
And you can always have make
call a new instance of make
. 你可以总是有
make
调用一个新的实例make
。
For example: 例如:
all:
$(MAKE) exprtest
exprtest:
do exprtest stuff
Typing make all
will indirectly do make exprtest
. 键入
make all
将间接做make exprtest
。
You want to do something like 你想做点什么
all: exprtest
What that says is " all
depends on exprtest
to be successful". 什么,说是“
all
取决于exprtest
是成功的”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.