>> Well, I guess I don't understand what you're asking. You'll need to be
>> more clear or, preferably, provide a specific example.
at> OK, here it is. Consider the following makefile:
at> DEPENDENCIES_FROM_SOURCES = $(patsubst
$(SOURCE_PATH)/%$(SOURCE_FILE_EXT),$(DEPENDENCY_PATH)/%$(DEPENDENCY_FILE_EXT),$(1))
at> $(INTERMEDIATE_PATH)/%$(OBJECT_FILE_EXT): \
at> $(SOURCE_PATH)/%$(SOURCE_FILE_EXT) \
at> $(DEPENDENCY_PATH)/%$(DEPENDENCY_FILE_EXT)
at> @$(eval DEPENDENCY_FILE := $(call DEPENDENCIES_FROM_SOURCES,$<))
at> # On the last line "$<" is canonical. Now conisder the case when SOURCE_PATH is "." - DEPENDENCIES_FROM_SOURCES does not
perform any
at> substitution, which is a problem.
at> # In order to work around it, I consider cononizing the argument to
DEPENDENCIES_FROM_SOURCE, e.g. like this:
Thanks. Although for future reference, completely self-contained,
runnable examples are easier to work with.
You have a few options here, depending on your situation. Note, none of
these are tested.
One option would be to change your DEPENDENCIES_FROM_SOURCES macro to
look like this:
DEPENDENCIES_FROM_SOURCES = $(patsubst $(if $(filter-out
.,$(SOURCE_PATH)),$(SOURCE_PATH)/)%$(SOURCE_FILE_EXT),$(DEPENDENCY_PATH)/%$(DEPENDENCY_FILE_EXT),$(1))
This uses $(SOURCE_PATH)/% if SOURCE_PATH is not ".", and just % if it
is. The problem here is that in the second case it will match anything
ending in $(SOURCE_FILE_EXT) which you might not want.
Or, you could do something like this:
DEPENDENCIES_FROM_SOURCES = $(patsubst $(SOURCE_PATH)/%$(SOURCE_FILE_EXT),$(DEPENDENCY_PATH)/%$(DEPENDENCY_FILE_EXT),$(patsubst
$*$(SOURCE_FILE_EXT),$(SOURCE_PATH)/$*$(SOURCE_FILE_EXT),$(1)))
This adds back in the $(SOURCE_FILE_PATH)/ prefix if it doesn't exist,
before the "outer" patsubst gets involved. Of course you can rearrange
this in various ways. The problem with this is it's tied to $* which
means this macro will now only work inside a rule.