I would like to call flex to build a .l file, then call gcc to build everything.
I tryed:
comp:
lex scanner.l \\
gcc -o a.out main.c hash.c -I.
IIRC the usual Makefle pattern is
a.out: lex.yy.c main.c hash,c
gcc -o a.out main.c hash.c lex.yy.c -I. -ll
lex.yy.c: scanner.l
lex scanner.l
This is wrong, because in the original code, main.c includes lex.yy.c
This assumes the original code is changed so that main.c does not include lex.yy.c
Without that change, this will fail because there will be two definitions of yylex(), one from its #include
in main.c, and one because it is supplied as a source code compilation unit. I encourage folks to not include a .c file into another .c file.
In general, the convention is to use a different file extension (.i) for included source files which generate unique symbols and code.