Consider the following makefile:
foo :
mkdir foo
foo/a.out : foo a.in
cp a.in foo/a.out
foo/b.out : foo b.in
cp b.in foo/b.out
an
I like @Beta's answer, but it is not portable. For a simple portable workaround, create a sentinel file when you create the directory, and depend on the sentinel file instead.
foo/.dir:
mkdir -p foo
touch $@
foo/a.out: a.in foo/.dir
cp $< $@
foo/b.out: b.in foo/.dir
cp $< $@
This can be further simplified with a pattern rule:
foo/%.out: %.in foo/.dir
cp $< $@