rework handling of srcdir != builddir (patch from Flameeyes)