Q: Is there a way to substitute \ with / for Gnu Make command goals? I'm running a recursive make on windows using targets for each directory using forward slashes to separate path components. If someone runs
> make foo/bar

it will run fine. But if someone runs
> make foo\bar

it won't find the target to build:
make: Nothing to be done for `foo\bar'.

I would love it if I could add something like this to my top level Makefile:
MAKECMDGOALS = $(subst \,/,$(MAKECMDGOALS))

But such things do not work. MAKECMDGOALS can only be read. Or even if I can make backslash targets for all my regular targets like this:
$(DIRS): %: $(subst /,\,%)

But this too doesn't work. Whats the best way around this?

A: I've figured out a fairly nice way of handling this without resorting to a script to wrap make:
# $(call bstarget, foo foo/bar baz frob/niz)
# will result in the following targets being defined in place:
#   foo\bar: foo/bar
#   brob\niz: from/niz
bstarget = $(eval \
    $(foreach TARGET, $1, \
        $(if $(findstring /, $(TARGET)), \
            $(call bstargeteval, $(subst /,\,$(TARGET)), $(TARGET)))))
define bstargeteval
$1: $2

endef

Then it can be called in my Makefile with $(call bstarget, $(DIRS))

A: I think you need 4 backslashes (escaping) in your subst expression.
