Build fixes

Fix building under JHBuild and make `make distcheck` pass successfully.