Is there a way to replace \ s / with Gnu Make team goals?

I run recursive make on windows, using targets for each directory, using slashes to separate path components. If someone starts

> make foo/bar

it will work fine. But if someone starts

> make foo\bar

he will not find the target for the assembly:

make: Nothing to be done for `foo\bar'.

I would love it if I could add something similar to my top level Makefile:

MAKECMDGOALS = $(subst \,/,$(MAKECMDGOALS))

But such things do not work. MAKECMDGOALS can only be read. Or even if I can do a backslash for all my usual purposes, for example:

$(DIRS): %: $(subst /,\,%)

But that doesn't work either. How can this be done?

+3
source share
2 answers

, script, 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

Makefile $( bstarget, $(DIRS))

+1

, 4 () .

0

Source: https://habr.com/ru/post/1756660/


All Articles