Index: include/freeDiameter/CMakeLists.txt
===================================================================
--- include/freeDiameter/CMakeLists.txt	(revision 1136)
+++ include/freeDiameter/CMakeLists.txt	(revision 1159)
@@ -187,4 +187,31 @@
 ##########################
 
+# Additional hg version when relevant, stored in version.h
+if (EXISTS "${CMAKE_SOURCE_DIR}/.hg")
+	# Search for hg binary to use
+	FIND_PROGRAM(HGCOMMAND hg)
+	if (HGCOMMAND)
+		# Ok, add the custom target so that hg is executed at every build
+		ADD_CUSTOM_TARGET(version_information
+				   COMMAND ${CMAKE_COMMAND} -D HGCOMMAND="${HGCOMMAND}" -D SRC="${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" -D DST="${CMAKE_CURRENT_BINARY_DIR}/version.h" -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GetVersionWithHg.cmake"
+				   DEPENDS "${CMAKE_SOURCE_DIR}/.hg/dirstate"
+				   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				   COMMENT "Retrieving version of the hg repository"
+				   )
+	else (HGCOMMAND)
+		# Display at least "unknown" rev in this case
+		SET(FD_PROJECT_VERSION_HG "unknown")
+		CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+		ADD_CUSTOM_TARGET(version_information DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+	endif(HGCOMMAND)
+else (EXISTS "${CMAKE_SOURCE_DIR}/.hg")
+	# We use the pure version number without extension
+	CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+	ADD_CUSTOM_TARGET(version_information DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+endif (EXISTS "${CMAKE_SOURCE_DIR}/.hg")
+
+
+##########################
+
 # LFDPROTO_LIBS = libraries required by the libfdproto.
 SET(LFDPROTO_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${IDNA_LIBRARIES} PARENT_SCOPE)
Index: include/freeDiameter/libfdcore.h
===================================================================
--- include/freeDiameter/libfdcore.h	(revision 1155)
+++ include/freeDiameter/libfdcore.h	(revision 1159)
@@ -61,6 +61,5 @@
 		CHECK_PRELUDE(__call__);								\
 		if (__ret__ < 0) {									\
-			__ret__ = errno;								\
-			LOG(faillevel, "ERROR: in '%s' :\t%s",  #__call__ ,  gnutls_strerror(__ret__)); \
+			LOG(faillevel, "TLS ERROR: in '%s' :\t%s",  #__call__ ,  gnutls_strerror(__ret__)); \
 			__fallback__;									\
 		}											\
@@ -76,12 +75,6 @@
 #ifndef EXCLUDE_DEPRECATED
 /* Macro for transition, replace with CHECK_GNUTLS_GEN */
-#define CHECK_GNUTLS_DO( __call__, __fallback__ ) {						        \
-		CHECK_PRELUDE(__call__);								\
-		if (__ret__ < 0) {									\
-			__ret__ = errno;								\
-			TRACE_ERROR("ERROR: in '%s' :\t%s",  #__call__ ,  gnutls_strerror(__ret__));    \
-			__fallback__;									\
-		}											\
-}
+#define CHECK_GNUTLS_DO( __call__, __fallback__ )	\
+	CHECK_GNUTLS_GEN( FD_LOG_ERROR, __call__, __fallback__  )
 
 #endif /* EXCLUDE_DEPRECATED */
@@ -96,6 +89,6 @@
 int fd_core_initialize(void);
 
-/* Return a string describing the version of the library */
-const char *fd_core_version(void);
+/* A string describing the version of the library */
+extern const char fd_core_version[];
 
 /* Parse the freeDiameter.conf configuration file, load the extensions */
Index: include/freeDiameter/libfdproto.h
===================================================================
--- include/freeDiameter/libfdproto.h	(revision 1134)
+++ include/freeDiameter/libfdproto.h	(revision 1159)
@@ -123,4 +123,6 @@
 void fd_libproto_fini(void);
 
+/* Retrieve the version of the binary */
+extern const char fd_libproto_version[];
 
 /*============================================================*/
Index: include/freeDiameter/version.h.in
===================================================================
--- include/freeDiameter/version.h.in	(revision 1159)
+++ include/freeDiameter/version.h.in	(revision 1159)
@@ -0,0 +1,3 @@
+/* Following variable is expended at build time bbased on the result of "hg id" command */
+#cmakedefine FD_PROJECT_VERSION_HG
+#define FD_PROJECT_VERSION_HG_VAL "@FD_PROJECT_VERSION_HG@"
