tags:

views:

41

answers:

1

I want to just type 'make all' and have the following Makefile do everything it's supposed to do:

LEX = lex
YACC = yacc
CC = gcc

calcu: y.tab.o lex.yy.o
    $(CC) -o calcu y.tab.o lex.yy.o -ly -lfl

y.tab.c y.tab.h: parser.y
    $(YACC) -d parser.y

y.tab.o: y.tab.c parser.h
    $(CC) -c y.tab.c

lex.yy.o: y.tab.h lex.yy.c 
    $(CC) -c lex.yy.c

lex.yy.c: calclexer.l parser.h
    $(LEX) calclexer.l

clean:
    rm *.o
    rm *.c
    rm calcu
+3  A: 

What all is it supposed to do? If you just want it to build calcu, all you have to do is type make and it will make it along with everything it depends on, because it is the first rule in the file.

If you still want to make an all rule, it can be done like this. I recommend putting this above all other rules, so that you can just type make instead of make all.

all: calcu
yjerem
.PHONY: all This tells make that you don't expect there to actually be a file named "all" after building.
Stephen Newell