use of $$ versus $ in makefile and bash
I am puzzled concerning the use of the symbols "$" and "$$" in a
makefile. I do not understand why "$$" is required in some instances,
and "$" in other instances.
I have spent several hours searching through the documentation for
BASH and for GNU Make, but I have found no answer.
Here are three examples, all taken from the same makefile:
EXAMPLE 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ln -s ../journal.cls ../journal.hlx .
-(for d in ${SYMLINKDIR}; \
do \
pushd $$d && \
ln -sf $(addprefix ../,${SYMLINKTARGET}) .; \
popd; \
done;)
EXAMPLE 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(for d in $$(find . \
\( -type d \
-name '.svn' -prune -o \
-name 'hevea' -prune -o \
-name 'metatags' -prune \) -o \
-type d -print); \
do mkdir --parents ../stageweb/$$d; \
done;)
EXAMPLE 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(for bn in ${CLEANDIR}; \
do \
rm -f $(addprefix $$bn/*.,${CLEANEXT}); \
done;)
rm -f ${CLEANOTHER}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Also, in the third example, does the variable name "bn" have
significance? Could the name "b" or "c" or "x" be used instead? The
name "f" commonly is used in a for-loop when working with files, and
the name "d", when working with directories. The name "bn" appears
nowhere else in the makefile.
Reply to: