c++ - Why does this incredibly simple Makefile produce so much debug logging? -
i learning makefiles , decided write first exercise. have directory 2 files:
makefile makefile.cpp
here makefile.cpp (surprise surprise!):
#include <iostream> int main() { std::cout << "hello world!\n"; return 0; }
and here makefile:
cc = g++ files = makefile.cpp out_exe = makefileout build: $(files) $(cc) -o $(out_exe) $(files)
and run make -d , long log:
$ make -d gnu make 3.81 copyright (c) 2006 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. program built x86_64-pc-linux-gnu reading makefiles... reading makefile `makefile'... updating makefiles.... considering target file `makefile'. looking implicit rule `makefile'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.o'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.c'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.cc'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.c'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.cpp'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.p'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.r'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.mod'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.sh'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile,v'. trying pattern rule stem `makefile'. trying implicit prerequisite `rcs/makefile,v'. trying pattern rule stem `makefile'. trying implicit prerequisite `rcs/makefile'. trying pattern rule stem `makefile'. trying implicit prerequisite `s.makefile'. trying pattern rule stem `makefile'. trying implicit prerequisite `sccs/s.makefile'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.o'. looking rule intermediate file `makefile.o'. avoiding implicit rule recursion. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.c'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.cc'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.c'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.cpp'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.p'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.r'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.mod'. trying pattern rule stem `makefile.o'. trying implicit prerequisite `makefile.o,v'. trying pattern rule stem `makefile.o'. trying implicit prerequisite `rcs/makefile.o,v'. trying pattern rule stem `makefile.o'. trying implicit prerequisite `rcs/makefile.o'. trying pattern rule stem `makefile.o'. trying implicit prerequisite `s.makefile.o'. trying pattern rule stem `makefile.o'. trying implicit prerequisite `sccs/s.makefile.o'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.c'. looking rule intermediate file `makefile.c'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.y'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.l'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.w'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.w'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `makefile.c,v'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `rcs/makefile.c,v'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `rcs/makefile.c'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `s.makefile.c'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `sccs/s.makefile.c'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.y'. looking rule intermediate file `makefile.y'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.y'. trying implicit prerequisite `makefile.y,v'. trying pattern rule stem `makefile.y'. trying implicit prerequisite `rcs/makefile.y,v'. trying pattern rule stem `makefile.y'. trying implicit prerequisite `rcs/makefile.y'. trying pattern rule stem `makefile.y'. trying implicit prerequisite `s.makefile.y'. trying pattern rule stem `makefile.y'. trying implicit prerequisite `sccs/s.makefile.y'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.l'. looking rule intermediate file `makefile.l'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.l'. trying implicit prerequisite `makefile.l,v'. trying pattern rule stem `makefile.l'. trying implicit prerequisite `rcs/makefile.l,v'. trying pattern rule stem `makefile.l'. trying implicit prerequisite `rcs/makefile.l'. trying pattern rule stem `makefile.l'. trying implicit prerequisite `s.makefile.l'. trying pattern rule stem `makefile.l'. trying implicit prerequisite `sccs/s.makefile.l'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.w'. looking rule intermediate file `makefile.w'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.w'. trying implicit prerequisite `makefile.w,v'. trying pattern rule stem `makefile.w'. trying implicit prerequisite `rcs/makefile.w,v'. trying pattern rule stem `makefile.w'. trying implicit prerequisite `rcs/makefile.w'. trying pattern rule stem `makefile.w'. trying implicit prerequisite `s.makefile.w'. trying pattern rule stem `makefile.w'. trying implicit prerequisite `sccs/s.makefile.w'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.w'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.cc'. looking rule intermediate file `makefile.cc'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.cc'. trying implicit prerequisite `makefile.cc,v'. trying pattern rule stem `makefile.cc'. trying implicit prerequisite `rcs/makefile.cc,v'. trying pattern rule stem `makefile.cc'. trying implicit prerequisite `rcs/makefile.cc'. trying pattern rule stem `makefile.cc'. trying implicit prerequisite `s.makefile.cc'. trying pattern rule stem `makefile.cc'. trying implicit prerequisite `sccs/s.makefile.cc'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.c'. looking rule intermediate file `makefile.c'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.c'. trying implicit prerequisite `makefile.c,v'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `rcs/makefile.c,v'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `rcs/makefile.c'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `s.makefile.c'. trying pattern rule stem `makefile.c'. trying implicit prerequisite `sccs/s.makefile.c'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.cpp'. looking rule intermediate file `makefile.cpp'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `makefile.cpp,v'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `rcs/makefile.cpp,v'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `rcs/makefile.cpp'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `s.makefile.cpp'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `sccs/s.makefile.cpp'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.p'. looking rule intermediate file `makefile.p'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.web'. trying pattern rule stem `makefile.p'. trying implicit prerequisite `makefile.p,v'. trying pattern rule stem `makefile.p'. trying implicit prerequisite `rcs/makefile.p,v'. trying pattern rule stem `makefile.p'. trying implicit prerequisite `rcs/makefile.p'. trying pattern rule stem `makefile.p'. trying implicit prerequisite `s.makefile.p'. trying pattern rule stem `makefile.p'. trying implicit prerequisite `sccs/s.makefile.p'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.web'. looking rule intermediate file `makefile.web'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.web'. trying implicit prerequisite `makefile.web,v'. trying pattern rule stem `makefile.web'. trying implicit prerequisite `rcs/makefile.web,v'. trying pattern rule stem `makefile.web'. trying implicit prerequisite `rcs/makefile.web'. trying pattern rule stem `makefile.web'. trying implicit prerequisite `s.makefile.web'. trying pattern rule stem `makefile.web'. trying implicit prerequisite `sccs/s.makefile.web'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. looking rule intermediate file `makefile.f'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.r'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `makefile.f,v'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `rcs/makefile.f,v'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `rcs/makefile.f'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `s.makefile.f'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `sccs/s.makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.f'. looking rule intermediate file `makefile.f'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.f'. trying implicit prerequisite `makefile.f,v'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `rcs/makefile.f,v'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `rcs/makefile.f'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `s.makefile.f'. trying pattern rule stem `makefile.f'. trying implicit prerequisite `sccs/s.makefile.f'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.r'. looking rule intermediate file `makefile.r'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.l'. trying pattern rule stem `makefile.r'. trying implicit prerequisite `makefile.r,v'. trying pattern rule stem `makefile.r'. trying implicit prerequisite `rcs/makefile.r,v'. trying pattern rule stem `makefile.r'. trying implicit prerequisite `rcs/makefile.r'. trying pattern rule stem `makefile.r'. trying implicit prerequisite `s.makefile.r'. trying pattern rule stem `makefile.r'. trying implicit prerequisite `sccs/s.makefile.r'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.r'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. looking rule intermediate file `makefile.s'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `makefile.s,v'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `rcs/makefile.s,v'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `rcs/makefile.s'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `s.makefile.s'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `sccs/s.makefile.s'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.s'. looking rule intermediate file `makefile.s'. avoiding implicit rule recursion. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.s'. trying implicit prerequisite `makefile.s,v'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `rcs/makefile.s,v'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `rcs/makefile.s'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `s.makefile.s'. trying pattern rule stem `makefile.s'. trying implicit prerequisite `sccs/s.makefile.s'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.mod'. looking rule intermediate file `makefile.mod'. avoiding implicit rule recursion. avoiding implicit rule recursion. trying pattern rule stem `makefile.mod'. trying implicit prerequisite `makefile.mod,v'. trying pattern rule stem `makefile.mod'. trying implicit prerequisite `rcs/makefile.mod,v'. trying pattern rule stem `makefile.mod'. trying implicit prerequisite `rcs/makefile.mod'. trying pattern rule stem `makefile.mod'. trying implicit prerequisite `s.makefile.mod'. trying pattern rule stem `makefile.mod'. trying implicit prerequisite `sccs/s.makefile.mod'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.c'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.cc'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.c'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.cpp'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.p'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.f'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.r'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.s'. trying pattern rule stem `makefile'. rejecting impossible implicit prerequisite `makefile.mod'. trying pattern rule stem `makefile'. trying implicit prerequisite `makefile.sh'. looking rule intermediate file `makefile.sh'. avoiding implicit rule recursion. trying pattern rule stem `makefile.sh'. trying implicit prerequisite `makefile.sh,v'. trying pattern rule stem `makefile.sh'. trying implicit prerequisite `rcs/makefile.sh,v'. trying pattern rule stem `makefile.sh'. trying implicit prerequisite `rcs/makefile.sh'. trying pattern rule stem `makefile.sh'. trying implicit prerequisite `s.makefile.sh'. trying pattern rule stem `makefile.sh'. trying implicit prerequisite `sccs/s.makefile.sh'. no implicit rule found `makefile'. finished prerequisites of target file `makefile'. no need remake target `makefile'. updating goal targets.... considering target file `build'. file `build' not exist. considering target file `makefile.cpp'. looking implicit rule `makefile.cpp'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `makefile.cpp,v'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `rcs/makefile.cpp,v'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `rcs/makefile.cpp'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `s.makefile.cpp'. trying pattern rule stem `makefile.cpp'. trying implicit prerequisite `sccs/s.makefile.cpp'. no implicit rule found `makefile.cpp'. finished prerequisites of target file `makefile.cpp'. no need remake target `makefile.cpp'. finished prerequisites of target file `build'. must remake target `build'. g++ -o makefileout makefile.cpp putting child 0x01a6de60 (build) pid 6157 on chain. live child 0x01a6de60 (build) pid 6157 reaping winning child 0x01a6de60 pid 6157 removing child 0x01a6de60 pid 6157 chain. remade target file `build'.
the question have: am doing wrong? why logging being produced such simple example?
also, makefile seems recompile object code if source code older latest make
. in other words, have never seen message, "there nothing do."
thank you!
i'll address edit:
my makefile seems recompile object code if source code older latest make
in answer.
consider makefile:
cc = g++ files = makefile.cpp out_exe = makefileout build: $(files) $(cc) -o $(out_exe) $(files)
here target build
, never constructed (and that's why see compilation occurring every time). simplest fix should be:
cc = g++ files = makefile.cpp out_exe = makefileout ${out_exe}: $(files) $(cc) -o $(out_exe) $(files)
with new rule make
check makefileout
, not build
, providing expected behavior.
if want experiment little more may use makefile issuing following commands:
rm -f makefileout touch build make
you'll se if executable not present, make
won't compile it. leave question why (a simple) exercise.
Comments
Post a Comment