Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3161178
By: keithmarshall
Why do you want to use such an idiom, if $(SUBDIRS) is empty? Just write the
body of the for loop once, without the enclosing `for ...; do ...; done
Of course, if the definition of SUBDIRS is generated by running configure, and
an empty expansion *is* both possible and acceptable, then you should extend
the idiom, (using Makefile semantics):
if test -n "$(SUBDIRS)"; then for subdir in ""$(SUBDIRS); do (cd $$subdir && $(MAKE) whatever); done; fi
That way, if SUBDIRS *does* have an empty expansion, then the for loop will
not be executed. However, notice that you still need the ""$(SUBDIRS) idiom,
to satisfy the shell's syntax rules, when parsing the command. Also notice
the parentheses around the `cd $$subdir && ...' command; these simply ensure
that each invocation of the loop starts out with the same notion of the current
directory.
BTW, invoking the above Makefile fragment, but omitting the "" before the $(SUBDIRS)
in the for statement, and with SUBDIRS undefined, results in error messages
which suggest that make *does*, in fact, spawn /bin/sh to execute the for loop.
HTH.
Regards,
Keith.
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=338575
|