I'm currently writing a bigger makefile, which will handle a recursive structure of source files and it will put them in the same recursive structure in a destination directory. Basically you can assume this makefile:

```
DESTINATION_DIR = out
SOURCE_DIR = src
OBJECTS = out/abc.o out/subdir/test.o out/subdir/subdir/xyz.o

.PHONY: all
all: $(OBJECTS)

$(DESTINATION_DIR)/%.o: $(SOURCE_DIR)/%.c
    @echo "$@ --- $<"

```

As you can see I'm trying to replace $(DESTINATION\_DIR) with $(SOURCE\_DIR) in the dependency, but this doesn't work. How can I solve this? I even tried to use a replacement script this way:

```
%.o: $(shell myreplacementscript.py "%.c" "$(DESTINATION_DIR)" "$(SOURCE_DIR)")
    @echo "$@ --- $<"

```

but the percentage sign will be passed to my script without replacement. So how can I tell it that the output depends on the source file dynamically? I need to keep the sub directories in the OBJECTS variable, I can't flatten the structure. And the sub directories are dynamic, not predefined.

I've searched for others having the same problem but they either do have flat OBJECTS or a recursive make, which in my case isn't well suited because of interconnections between the directories according to dependencies.

**Summary/Error Message:**

It doesn't replace out/ in the OBJECTS with src/. So the error message is "Keine Regel vorhanden, um das Target »out/abc.o«, benötigt von »all«, zu erstellen. Schluss." which is the typical error "No rule to make target ...".

The full makefile can be seen here:
[Full Makefile](https://dl.dropboxusercontent.com/u/13838356/Makefile)

Whenever I leave the righthandside of the colon with %.html at the left side it works, but I need to have the source file as dependency to get a working incremental build (hopefully without creating dependency files).

Kind regards,

Daniel