I have a simple loop in my makefile:
@ for i in $(APPDIRS) ; do \
$(MAKE) -C $$i real_clean ; \
done
I know $$ means process id of the script itself. What does the 'i' do? Am I iterating through the process id with the for loop?
$ is used both as the variable identifier for make and for the shell. So if you want the shell to expand a variable, rather than having the makefile do it, you need to escape the $ by using $$.
As a quick example, let's assume APPDIRS=a b c d e f and MAKE=make (and i unset in the makefile). Then your shell sees:
for i in a b c d e f ; do
make -C $i real_clean;
done
With a $ in place of the $$, it would see:
for i in a b c d e f ; do
make -C real_lean;
done
Which is definitely not what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With