This should fix the build on latest CURRENT and is mostly equal to upstream commit 3ea5fa3 Reported by: soralx at cydem dot org