swrh/dotmk — Issue #1: OBJDIR doesn't work well with sources in other directories
Author: swrh
Created: 2011-11-14 18:12:20+00:00
State: open

When using the OBJDIR variable and compiling sources that are in directories relative to the parent directory we can see that make creates unexpected directories.

```
lui5i$ cat foo/Makefile
PROG=foo
OBJDIR=.obj
SRCS=../src/bar.c
include mk/build.mk
lui5i$ LANG=C tree -a
.
|-- foo
| |-- Makefile
| `-- mk
| |-- build.mk
| `-- subdir.mk
`-- src
`-- bar.c

3 directories, 4 files
lui5i$ make -C foo
make: Entering directory `/tmp/foobar.d/foo/foobar/foo'
mkdir -pv .obj/../src/
mkdir: created directory `.obj'
mkdir: created directory `.obj/../src/'
gcc -Wall -Wunused -O2 -DNDEBUG -c -o .obj/../src/bar.o ../src/bar.c
gcc .obj/../src/bar.o -o foo
make: Leaving directory `/tmp/foobar.d/foo/foobar/foo'
lui5i$ LANG=C tree -a
.
|-- foo
| |-- .obj
| |-- Makefile
| |-- foo
| |-- mk
| | |-- build.mk
| | `-- subdir.mk
| `-- src
| `-- bar.o
`-- src
`-- bar.c

5 directories, 6 files
lui5i$ make -C foo distclean
make: Entering directory `/tmp/foobar.d/foo/foobar/foo'
rm -f foo .obj/../src/bar.o
rm -f .depend
make: Leaving directory `/tmp/foobar.d/foo/foobar/foo'
lui5i$ LANG=C tree -a
.
|-- foo
| |-- .obj
| |-- Makefile
| |-- mk
| | |-- build.mk
| | `-- subdir.mk
| `-- src
`-- src
`-- bar.c

5 directories, 4 files
lui5i$
```

Result: the "src" directory was created in the current directory while the correct behavior would be being created in the ".obj" directory. I suggest we create ALL object files in OBJDIR when it is set, with no sub-directories.