14

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
Amre
  • 1,630
  • 8
  • 29
  • 41

3 Answers3

14

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.

Jonatas Walker
  • 13,583
  • 5
  • 53
  • 82
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
13

Put exprtest on the same line as 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
vladr
  • 65,483
  • 18
  • 129
  • 130
6

You want to do something like

all: exprtest

What that says is "all depends on exprtest to be successful".

Dietmar Kühl
  • 150,225
  • 13
  • 225
  • 380