I have auto.lex
and I want to generate a.out
of this file .
I tried -
a.out: lex.yy.c
gcc -c lex.yy.c
lex.yy.c: auto.lex
flex -c auto.lex
but it not worked .
EDIT:
changed to -
a.out: lex.yy.c
gcc lex.yy.c
lex.yy.c: auto.lex
flex auto.lex
and fixed .
The recommend suffix for lex files is .l
. GNU make has a builtin rule .l.c
that creates C code from a lex source. Thus, if you want to create an executable auto
from auto.l
, you don't need a makefile at all. Just type make auto
:
$ make auto
lex -t auto.l > auto.c
cc -c -o auto.o auto.c
cc auto.o -lfl -o auto
rm auto.o auto.c