How to add the whole rule to this makefile?

I want to just type “make all” and have the following Makefile do everything that it should 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
source share
1 answer

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

If you still want to create a rule all, you can do this as follows. I recommend putting this above all other rules, so you can just type makeinstead make all.

all: calcu
+4
source

Source: https://habr.com/ru/post/1722946/


All Articles