10/31 How can I save the output of a subshell command into a Makefile
variable? I want something like TIMESTAMP=`date '+%Y-%b-%d-%H:%M'`,
and then use that in the following rule:
checkpoint : clean
tar cf ../$(TIMESTAMP).tar .
------------
But instead of returning the date string, it makes tar files named
date '+%Y-%b-%d-%H:%M'.tar ... What am I doing wrong?
\_ 1. Which shell?
2. Loose the brackets. They have a special meaning in most shells
3. Post the exact commands/script you're trying to run
\_ What version of make? From Solaris 8 make(1S)
\_ What version of make? From Solaris 8 make(1S) -jon
Command Substitutions
To incorporate the standard output of a shell command in a
macro, use a definition of the form:
MACRO:sh =command
The command is executed only once, standard error output is
discarded, and NEWLINE characters are replaced with SPACEs.
If the command has a non-zero exit status, make halts with
an error.
To capture the output of a shell command in a macro refer-
ence, use a reference of the form:
$(MACRO:sh)
where MACRO is the name of a macro containing a valid Bourne
shell command line. In this case, the command is executed
whenever the reference is evaluated. As with shell command
substitutions, the reference is replaced with the standard
output of the command. If the command has a non-zero exit
status, make halts with an error. |