Index: resources/tspsg.rc
===================================================================
--- resources/tspsg.rc	(revision 7ba743d98394952eae50e1c0eea8ff7ca1dd1535)
+++ resources/tspsg.rc	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
@@ -23,9 +23,7 @@
 	PRODUCTVERSION BUILD_VERSION_MAJOR,BUILD_VERSION_MINOR,BUILD_RELEASE,BUILD_NUMBER
 	FILEFLAGSMASK 0x17L
-#if defined(DEBUG)
+#ifdef DEBUG
 	FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE | VS_FF_PRIVATEBUILD
-#elif !defined(TSPSG_RELEASE_BUILD) || (BUILD_NUMBER == 65535)
-	FILEFLAGS VS_FF_PRERELEASE | VS_FF_SPECIALBUILD
-#elif BUILD_RELEASE < 11
+#elif !defined(TSPSG_RELEASE_BUILD)
 	FILEFLAGS VS_FF_PRERELEASE
 #else
@@ -51,13 +49,11 @@
             VALUE "InternalName", "TSPSG"
             VALUE "LegalCopyright", "Copyright © 2007-2010 Oleksii ""Lёppa"" Serdiuk <contacts[at]oleksii[dot]name>"
-#ifdef QT_NO_DEBUG
+#ifdef DEBUG
+            VALUE "OriginalFilename", "tspsgd.exe"
+#else
             VALUE "OriginalFilename", "tspsg.exe"
-#else
-            VALUE "OriginalFilename", "tspsgd.exe"
 #endif
-#ifndef QT_NO_DEBUG
+#ifdef DEBUG
             VALUE "PrivateBuild", "Debug development build"
-#elif BUILD_NUMBER == 65535
-            VALUE "SpecialBuild", "Internal development build"
 #endif
         END
Index: src/main.cpp
===================================================================
--- src/main.cpp	(revision 7ba743d98394952eae50e1c0eea8ff7ca1dd1535)
+++ src/main.cpp	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
@@ -42,5 +42,5 @@
 {
 #ifdef Q_WS_S60
-    // No enough memory for solution graph generation with tasks
+    // Not enough memory for solution graph generation with tasks
     // of 20 and more cities if we use non-raster graphics system.
     QApplication::setGraphicsSystem("raster");
Index: src/mainwindow.cpp
===================================================================
--- src/mainwindow.cpp	(revision 7ba743d98394952eae50e1c0eea8ff7ca1dd1535)
+++ src/mainwindow.cpp	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
@@ -552,5 +552,9 @@
     about += QString("&nbsp;&nbsp;&nbsp;&nbsp;%1: <b>%2</b><br>").arg(tr("Runtime"), qVersion());
     about.append(QString("%1: <b>%2x%3</b><br>").arg(tr("Logical screen DPI")).arg(logicalDpiX()).arg(logicalDpiY()));
-    about += tr("Buid <b>%1</b>, built on <b>%2</b> at <b>%3</b> with <b>%4</b> compiler.").arg(BUILD_NUMBER).arg(__DATE__).arg(__TIME__).arg(COMPILER) + "<br>";
+QString tag;
+#ifdef REVISION_STR
+    tag = tr(" from git revision <b>%1</b>").arg(REVISION_STR);
+#endif
+    about += tr("Build <b>%1</b>, built%5 on <b>%2</b> at <b>%3</b> with <b>%4</b> compiler.").arg(BUILD_NUMBER).arg(__DATE__).arg(__TIME__).arg(COMPILER).arg(tag) + "<br>";
     about += QString("%1: <b>%2</b><br>").arg(tr("Algorithm"), CTSPSolver::getVersionId());
     about += "<br>";
Index: src/version.h
===================================================================
--- src/version.h	(revision 7ba743d98394952eae50e1c0eea8ff7ca1dd1535)
+++ src/version.h	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
@@ -49,19 +49,19 @@
 /*!
  * \def BUILD_STATUS
- * \brief TSPSG build status
+ * \brief TSPSG build status (e.g., alpha1, beta3)
  */
 #ifdef DEBUG
-#   ifndef BUILD_STATUS_TYPE
-#       define BUILD_STATUS (debug build BUILD_NUMBER)
+#   ifndef BUILD_STATUS
+#       define BUILD_STATUS_STR (debug build)
 #   else
-#       define BUILD_STATUS (debug BUILD_STATUS_TYPE BUILD_STATUS_NUMBER)
+#       define BUILD_STATUS_STR (debug BUILD_STATUS)
 #   endif
 #else
 #   if !defined(TSPSG_RELEASE_BUILD)
-#       define BUILD_STATUS (nightly build)
-#   elif !defined(BUILD_STATUS_TYPE)
-#       define BUILD_STATUS (build BUILD_NUMBER)
+#       define BUILD_STATUS_STR (nightly build)
+#   elif !defined(BUILD_STATUS)
+#       define BUILD_STATUS_STR (build BUILD_NUMBER)
 #   else
-#       define BUILD_STATUS (BUILD_STATUS_TYPE BUILD_STATUS_NUMBER)
+#       define BUILD_STATUS_STR (BUILD_STATUS)
 #   endif // TSPSG_RELEASE_BUILD
 #endif // DEBUG
@@ -73,5 +73,15 @@
 
 //! Full version of TSPSG in the form: \c major.minor.release.build \c status.
-#define BUILD_VERSION QUOTE(BUILD_VERSION_MAJOR.BUILD_VERSION_MINOR.BUILD_RELEASE BUILD_STATUS)
+#define BUILD_VERSION QUOTE(BUILD_VERSION_MAJOR.BUILD_VERSION_MINOR.BUILD_RELEASE BUILD_STATUS_STR)
+
+/*!
+ * \def REVISION_STR
+ * \brief Git revision from which build was made
+ */
+#ifdef REVISION
+#   define REVISION_STR QUOTE(REVISION)
+#else
+#   define REVISION_STR "$Format:%H$"
+#endif
 
 #endif // VERSION_H
Index: tspsg.pro
===================================================================
--- tspsg.pro	(revision 7ba743d98394952eae50e1c0eea8ff7ca1dd1535)
+++ tspsg.pro	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
@@ -31,35 +31,11 @@
 QMAKE_TARGET_COPYRIGHT = Copyright © 2007-2011 Oleksii "Lёppa" Serdiuk <contacts[at]oleksii[dot]name>
 
-# Versioning
-BUILD_VERSION_MAJOR = 0
-BUILD_VERSION_MINOR = 1
-BUILD_RELEASE = 5
-
-# These are only defined on releases
-#DEFINES += TSPSG_RELEASE_BUILD
-#DEFINES += BUILD_STATUS_TYPE=beta
-#DEFINES += BUILD_STATUS_NUMBER=2
-
-#REVISION = 170
-isEmpty(REVISION) {
-    REVISION = $$system(svnversion)
-}
-isEmpty(REVISION)|isEqual(REVISION,exported) {
-    REVISION = 0
-} else {
-    REVISION = $$replace(REVISION,":","")
-    REVISION = $$replace(REVISION,"M","")
-}
-SHORT_VERSION = $$sprintf("%1.%2",$$BUILD_VERSION_MAJOR,$$BUILD_VERSION_MINOR)
-win32-msvc*|wincewm* {
-    VERSION = $$SHORT_VERSION
-} else {
-    VERSION = $$sprintf("%1.%2",$$SHORT_VERSION,$$BUILD_RELEASE)
-}
+# Version detection
+include(version.pri)
 
 DEFINES += BUILD_VERSION_MAJOR=$$BUILD_VERSION_MAJOR \
     BUILD_VERSION_MINOR=$$BUILD_VERSION_MINOR \
     BUILD_RELEASE=$$BUILD_RELEASE \
-    BUILD_NUMBER=$$REVISION
+    BUILD_NUMBER=$$BUILD_NUMBER
 
 CONFIG(release, debug|release) {
Index: version.pri
===================================================================
--- version.pri	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
+++ version.pri	(revision 1299ea5b493c15fd10dafb2dc996f7bc38f1daf8)
@@ -0,0 +1,58 @@
+######################################################################
+#
+#  TSPSG: TSP Solver and Generator
+#  Copyright (C) 2007-2011 Lёppa <contacts[at]oleksii[dot]name>
+#
+#  $Id: $Format:%h %ai %an$ $
+#  $URL: http://tspsg.info/ $
+#
+#  This file is part of TSPSG.
+#
+######################################################################
+
+exists(".git/") {
+    DESC = $$system("git describe --abbrev=40")
+} else:exists(".tag") {
+    DESC = $$cat(".tag")
+}
+!isEmpty(DESC) {
+    DESC = $$split(DESC, "-")
+    VER = $$member(DESC, 0)
+    VER = $$split(VER, ".")
+
+    BUILD_VERSION_MAJOR = $$member(VER, 0)
+    BUILD_VERSION_MINOR = $$member(VER, 1)
+    BUILD_RELEASE = $$member(VER, 2)
+    count(DESC, 2) {
+        # We're exactly at a tag - use whatever is provided by it
+        BUILD_NUMBER = $$member(VER, 3)
+        isEmpty(BUILD_NUMBER) {
+            BUILD_NUMBER = 0
+        }
+
+        DEFINES += TSPSG_RELEASE_BUILD
+        DEFINES += BUILD_STATUS=$$member(DESC, 1)
+    } else {
+        TMP = $$member(VER, 3)
+        TMP = $$replace(TMP, "0$", "")
+        BUILD_NUMBER = $$TMP$$member(DESC, 2)
+        REVISION = $$member(DESC, 3)
+        REVISION = $$replace(REVISION, "^g", "")
+
+        DEFINES += REVISION=$$REVISION
+    }
+
+    SHORT_VERSION = $$sprintf("%1.%2",$$BUILD_VERSION_MAJOR,$$BUILD_VERSION_MINOR)
+    win32-msvc*|wincewm* {
+        VERSION = $$SHORT_VERSION
+    } else {
+        VERSION = $$sprintf("%1.%2",$$SHORT_VERSION,$$BUILD_RELEASE)
+    }
+} else {
+    # We can't deduce in case we don't have git or repo was exported.
+    # For this case defaults are provided.
+    BUILD_VERSION_MAJOR = 0
+    BUILD_VERSION_MINOR = 1
+    BUILD_RELEASE = 4
+    BUILD_NUMBER = 0
+}
