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?
The trouble is that there is an implicit rule in Make (well, in GNUMake anyway) for linking a single object file to build en executable. Your makefile says nothing about how to build program.lex
, so Make falls back on the implicit rule to build it from program.lex.o
.
Since your your layout seems to depend on having program.lex
to begin with, you can suppress the implicit rule by adding your own rule for program.lex
(which does nothing):
program.lex:;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With