Reapply [50764d32f7] and fix by adding the missing bits to configure.ac