Improve version processing in Makefile.