繁体   English   中英

如何在makefile中创建目标来调用makefile中的另一个目标

[英]How do I make a target in a makefile invoke another target in 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

exprtest放在与all相同的行上。 冒号后面的依赖关系,命令来自以下行,缩进。

target: dependencies
[tab] system command

所以在你的情况下,这一切都变为:

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

你可以总是有make调用一个新的实例make
例如:

all:
    $(MAKE) exprtest

exprtest:  
    do exprtest stuff

键入make all将间接做make exprtest

你想做点什么

all: exprtest

什么,说是“ all取决于exprtest是成功的”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM