Here is my Makefile:
.PHONY: all homework1
CFLAGS= -g -O0 -Wall -Werror -Wno-unused-function
LDFLAGS= -lm
all : homework1
homework1 : program.tab.o program.lex.o
%.o : %.c
gcc -o$@ -c $(CFLAGS) $<
%.lex.c : %.lex %.tab.h
flex -o$@ $<
%.tab.c %.tab.h : %.y
bison --verbose -o$@ -d $<
Whenever I try to compile, I get the warning make: Circular program.lex <- program.lex.o dependency dropped. I don’t see how program.lex is dependent on program.lex.o at all in the makefile. I see how the dependency tree is about 4 layers deep, but it doesn’t look circular.
How can I improve my makefile?
@aaa carp is correct that is an implicit rule, but it’s not one of the
LEXrules, because they buildN.corN.rfromN.l, and this is a rule that’s buildingNfromN.o. That looks to me like the “Linking a single object file” rule, described ininfo (make) Catalogue of Rules. Renaming your.lexfiles to.lfiles will fix this problem.Also: running
flex, I don’t think you really need the.tab.hfile to build the lexer source. Try this instead:This will add the extra dependency to
program.l.o.