Improve version detection in configure script