Scripts taken from autoconf 948ae97ca5703224bd3eada06b7a69f40dd15a02 (cherry picked from commit 36f2c342)