On Mon, Aug 8, 2011 at 2:35 PM, Stephan Beal <[email protected]> wrote:
> True, but $(wildcard) can expand to multiple words, so the
> ifeq(1,$(words...)) hack is a bit safer against undesired side-effects if
> someone accidentally or maliciously adds a ? or * to the value.

Good point.

> i wasn't aware of $(if) (call me old-fashioned). That is certainly simpler
> than using if/endif blocks.

Another way:

$(info $(shell test -d $(WORK_DIR) || mkdir -p $(WORK_DIR)))

(the $(info) is there on the off chance it generates output). Also,
note a beneficial side effect of mkdir -p is that, unlike mkdir alone,
it's silent and happy if the dir already exists. So you can just do an
unequivocal

$(info $(shell mkdir -p foo))

to make sure a directory exists. It's never good to do a mkdir in a
recipe (race condition under -j), so all these ways are preferred in
that they work directly from the make process. In the OP's case it
might be necessary to combine them with target-specific variables:

foobar: _dummy := $(shell ...)

-David Boyce

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to