file `foo'.
/home/jgc/Makefile:10 File `baz' does not exist.
/home/jgc/Makefile:13 File `bam' does not exist.
/home/jgc/Makefile:13 Must remake target `bam'.
+ touch bam
/home/jgc/Makefile:13 Successfully remade target file `bam'.
/home/jgc/Makefile:10 Must remake target `baz'.
+ touch baz
/home/jgc/Makefile:10 Successfully remade target file `baz'.
/home/jgc/Makefile:2 Must remake target `all'. Is a phony target.
/home/jgc/Makefile:2 Successfully remade target file `all'.
Makefile terminated.
Use q to quit or R to restart
:
mdb<0>
Targets, Macro Values and Expansion
When stopped in the debugger it's possible to interrogate information about targets in the Makefile, macro values (expanded and unexpanded) and commands. For example, in the Makefile above, when stopped at a breakpoint we can ask for all the information remake has about the all target using the target command:
./remake -X
Reading makefiles...
Updating makefiles....
Updating goal targets....
/home/jgc/Makefile:2 File `all' does not exist.
(/home/jgc/Makefile:2)
all: foo bar baz
mdb<0> target all
all: foo bar baz
# Phony target (prerequisite of .PHONY).
# Implicit rule search has not been done.
# Implicit/static pattern stem: `'
# File does not exist.
# File has not been updated.
# automatic
# @ := all
# automatic
# % :=
# automatic
# * :=
# automatic
# + := foo bar baz
# automatic
# | :=
# automatic
# < := all
# automatic
# ^ := foo bar baz
# automatic
# ? :=
mdb<0>
Here you can see that all is a phony target, and information about the automatic variables that will be set for this rule. You are not restricted to asking about the current target, let's see the state of foo:
mdb<0> target foo
foo: bar
# Implicit rule search has not been done.
# Implicit/static pattern stem: `'
# Modification time never checked.
# File has not been updated.
# automatic
# @ := foo
# automatic
# % :=
# automatic
# * :=
# automatic
# + := bar
# automatic
# | :=
# automatic
# < := bar
# automatic
# ^ := bar
# automatic
# ? :=
# commands to execute (from `Makefile', line 5):
@touch $@
Since target foo has commands they are listed at the bottom (with where to find them in
which Makefile). If we wanted to see the expanded form of the commands we'd use the expand modified to the target command:
mdb<1> target foo expand
foo:
# commands to execute (from `Makefile', line 5):
@touch $@
# commands to execute (from `Makefile', line 5):
@touch foo
mdb<2>
To get information about a macro we use the print and examine commands: print gives the definition of the macro and examine gives its post-expansion value. Here we ask for the definition of built-in COMPILE.c macro (which contains the command used to compile .c files):
mdb<0> print COMPILE.c
(origin default) COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
To see the expanded value we examine it:
mdb<0> examine COMPILE.c
(origin default) COMPILE.c := cc -c
remake also lets you set macro values using set (which expands a string and sets the macro to that value) and setq (which sets the macro to a string without expansion). For example, we could change CC from cc to gcc:
mdb<1> print CC
(origin default) CC = cc
mdb<1> setq CC gcc
Variable CC now has value 'gcc'
mdb<3> print CC
(origin debugger) CC = gcc
mdb<2> examine COMPILE.c
(origin default) COMPILE.c := gcc -c
mdb<5>
Conclusion
In this article I've only touched on






