introduce library version plus git hash

This exposes the library version and git head hash it was built from
into LWS_LIBRARY_VERSION and LWS_BUILD_HASH.

These are combined into a version string that's both printed as a
notice log by the library and made available to the app using a new
api lws_get_library_version().  The version looks like

 1.1 178d78c

Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 75302d0..4ed528a 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -48,11 +48,16 @@
 #endif
 #endif
 
+#ifndef LWS_BUILD_HASH
+#define LWS_BUILD_HASH "unknown-build-hash"
+#endif
 
 static int log_level = LLL_ERR | LLL_WARN | LLL_NOTICE;
 static void lwsl_emit_stderr(int level, const char *line);
 static void (*lwsl_emit)(int level, const char *line) = lwsl_emit_stderr;
 
+static const char *library_version = LWS_LIBRARY_VERSION " " LWS_BUILD_HASH;
+
 static const char *log_level_names[] = {
 	"ERR",
 	"WARN",
@@ -66,6 +71,20 @@
 	"LATENCY",
 };
 
+/**
+ * lws_get_library_version: get version and git hash library built from
+ *
+ *	returns a const char * to a string like "1.1 178d78c"
+ *	representing the library version followed by the git head hash it
+ *	was built from
+ */
+
+const char *
+lws_get_library_version(void)
+{
+	return library_version;
+}
+
 int
 insert_wsi_socket_into_fds(struct libwebsocket_context *context, struct libwebsocket *wsi)
 {
@@ -1492,6 +1511,7 @@
 #endif
 
 	lwsl_notice("Initial logging level %d\n", log_level);
+	lwsl_notice("Library version: %s\n", library_version);
 	lwsl_info(" LWS_MAX_HEADER_NAME_LENGTH: %u\n", LWS_MAX_HEADER_NAME_LENGTH);
 	lwsl_info(" LWS_MAX_HEADER_LEN: %u\n", LWS_MAX_HEADER_LEN);
 	lwsl_info(" LWS_INITIAL_HDR_ALLOC: %u\n", LWS_INITIAL_HDR_ALLOC);