Next: , Previous: , Up: Sample Sessions   [Contents][Index]


1.1.3 A Larger Real-World Makefile Trace

GNU Make and GNU Remake work like many other interpreters. First Makefiles are read in and parsed and then they are “executed” which in GNU Make means that dependency checks are done and actions are performed based on those checks. However there is quite a bit work that may be done just in portion which reads in the Makefiles and performs variable expansion. Most of the time this information is will not be of much use. But if you should be interested in this phase, use the flag --trace=read.

$ remake –trace=read
GNU Make 3.82+dbg-0.5
Built for i686-pc-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefile `Makefile'...
Reading makefile `.deps/alloca.Po' (search path) (no ~ expansion)...
Reading makefile `.deps/getloadavg.Po' (search path) (no ~ expansion)...
Reading makefile `.deps/ar.Po' (search path) (no ~ expansion)...
Reading makefile `.deps/arscan.Po' (search path) (no ~ expansion)...
Reading makefile `.deps/break.Po' (search path) (no ~ expansion)...
Reading makefile `.deps/buildargv.Po' (search path) (no ~ expansion)...
Reading makefile `.deps/cmd.Po' (search path) (no ~ expansion)...
...

Now let’s do a simple trace on a real example — the Makefile the doc directory for the GNU Make + Debugger. Here it is in its entirety:

$ remake –trace
GNU Make 3.82+dbg-0.5
Built for i686-pc-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating goal targets....
 /tmp/remake/doc/Makefile:245	File `all' does not exist.
   /tmp/remake/doc/Makefile:545	File `all-am' does not exist.
  /tmp/remake/doc/Makefile:545	Must remake target `all-am'.
  /tmp/remake/doc/Makefile:545	Successfully remade target file `all-am'.
/tmp/remake/doc/Makefile:245	Must remake target `all'.
/tmp/remake/doc/Makefile:245	Successfully remade target file `all'.
remake: Nothing to be done for `all'.
$

As before, after Updating goal targets... we show the position in the Makefile (/tmp/remake/doc/Makefile:245) of where target all appears and we see that this depends on target all-am which must also be remade.

Above, no shell commands needed to get run. So let us get just a little more complex and make the HTML pages which shows some running some shell code:

$ remake –trace remake.html
GNU Make 3.82+dbg-0.5
Built for i686-pc-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating goal targets....
 Prerequisite `remake.texi' is newer than target `remake.html'.
/tmp/remake/doc/Makefile:369	Must remake target `remake.html'.
Invoking recipe from Makefile:370 to update target `remake.html'.
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
rm -rf remake.htp
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if /bin/sh /tmp/remake/config/missing --run makeinfo --html   -I . \
 -o remake.htp `test -f 'remake.texi' || echo './'`remake.texi; \
then \
  rm -rf remake.html; \
  if test ! -d remake.htp && test -d remake; then \
    mv remake remake.html; else mv remake.htp remake.html; fi; \
else \
  if test ! -d remake.htp && test -d remake; then \
    rm -rf remake; else rm -Rf remake.htp remake.html; fi; \
  exit 1; \
fi
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/tmp/remake/doc/Makefile:369	Successfully remade target file `remake.html'.
$

To make remake.html we need to make remake.texi, but that file exists already. Then we remove file remake.htp. That is shown in the lines:

##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
rm -rf remake.htp
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

There is no output from running this command which would appear next. Instead, we see:

##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

which means we are about to runn a second shell command for this target:

if /bin/sh /tmp/remake/config/missing --run makeinfo --html   -I . \
 -o remake.htp `test -f 'remake.texi' || echo './'`remake.texi; \
then \
  rm -rf remake.html; \
  if test ! -d remake.htp && test -d remake; then \
    mv remake remake.html; else mv remake.htp remake.html; fi; \
else \
  if test ! -d remake.htp && test -d remake; then \
    rm -rf remake; else rm -Rf remake.htp remake.html; fi; \
  exit 1; \
fi

The backslashes in the above are there because this multi-line if statement is passed off to the shell as one command.


Next: , Previous: , Up: Sample Sessions   [Contents][Index]