build system fixes

This branch contains some build system fixes from debian packaging.