Create correct SONAME by extracting version from git tag

Extracts latest tag (annotated or not) from git and use it for soname
versioning. Assumes that tags are of the form X.Y.Z, where X, Y, Z are
digits, which in turn requires that the tag points to HEAD.