Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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
like image 558
Amre Avatar asked Nov 12 '12 02:11

Amre


1 Answers

And you can always have make call a new instance of make.
For example:

all:
    $(MAKE) exprtest

exprtest:  
    do exprtest stuff

Typing make all will indirectly do make exprtest.

like image 181
Trevor Hickey Avatar answered Sep 21 '22 17:09

Trevor Hickey