Next: , Previous: , Up: Controlling Make   [Contents][Index]


4.10.4 Setting a variable to an expanded string (‘set variable’)

set varible variable string

Sets variable to the value string, but string is expanded first as it would be when you use expand.

One nice use of set variable in debugging is to set the value of SHELL to include tracing in that. Here’s an example:

remake<0> set variable SHELL $(SHELL) -x
Variable SHELL now has value '/bin/sh -x'
remake<1>

Now we’ll show this in a real example - stepping (or actually “next”ing though the top-level makefile in the source distribution for GNU Remake:

$ remake -X
Reading makefiles...

(/tmp/remake/Makefile:256)
Makefile.in: Makefile.am config/readline.m4 gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 acinclude.m4 configure.ac aclocal.m4
remake<0> set variable SHELL $(SHELL) -x
Variable SHELL now has value '/bin/sh -x'
remake<1> n
Updating goal targets....
 /tmp/remake/Makefile:250	File `all' does not exist.

(/tmp/remake/Makefile:250)
all: config.h
remake<2> p SHELL
Makefile:156 (origin: debugger) SHELL = /bin/bash -x
remake<3> n
   Prerequisite `stamp-h1' is newer than target `config.h'.
  /tmp/remake/Makefile:288	Must remake target `config.h'.

(/tmp/remake/Makefile:288)
config.h: stamp-h1
remake<4> n
if test ! -f config.h; then \
  rm -f stamp-h1; \
  remake stamp-h1; \
else :; fi
+ test '!' -f config.h
+ :
  /tmp/remake/Makefile:288	Successfully remade target file `config.h'.

Above we see the script source code followed by the trace information – we took the “else” branch which has the null statement “:”.