c - How does Redis Makefile include header file prerequisites -
i teaching myself gnu make , thought @ redis makefile teach me thing or 2 tool.
the rule compiles source file object file here:
%.o: %.c .make-prerequisites $(redis_cc) -c $<
notice suffix rule mentions c source file (with %.c) prerequisite.
but if add echo in middle , run make:
%.o: %.c .make-prerequisites echo $^ $(redis_cc) -c $<
then first few lines of output make below:
cd src && make make[1]: entering directory `/home/cltpadmin/code/redis/src' echo adlist.c .make-prerequisites adlist.h zmalloc.h adlist.c .make-prerequisites adlist.h zmalloc.h cc adlist.o
how did make
know adlist.c
depends on adlist.h
, zmalloc.h
?
the prerequisites in question come line 1 of makefile.dep
included makefile (included on line 134).
the dep
target on line 136 generates file.
this common (though entirely avoidable) step using compiler generate necessary header file includes. static method has issues conditional header includes believe.
to clarify, "avoidable" part of need not separate step , static dependency file @ all. see advanced auto-dependency generation details idea.
Comments
Post a Comment