I have this make target. Its intention is to rely on the output directory as well as the source. I used this for truncating the file name and leaving the directories its in.
build/%.o: src/%.cpp build/${%%/*}/
$(CC) $(CFLAGS) -o $@ $^
Then the directory make target:
%/:
mkdir -p $@
The problem is, ${%%/*}
isn't being substituted so it only ends up making the dir build//
instead of build/folder/folder/
.