build+core: Add printing of version number in daemons and tools

This commit also changes how version number is handled.  Version is now
fully controlled from top-level wscript.  In addition to that, a new
NFD_VERSION_BUILD_STRING macro is set to include more detailed
information, including commit ID (e.g., "0.1.0-rc1-1-g5c86570").

Change-Id: I448eb627e0c42dc814de1107cf7bb0dc94fa2a89
Refs: #1575
diff --git a/tools/ndn-tlv-peek.cpp b/tools/ndn-tlv-peek.cpp
index ee0436f..ec0a9b0 100644
--- a/tools/ndn-tlv-peek.cpp
+++ b/tools/ndn-tlv-peek.cpp
@@ -25,6 +25,8 @@
  * @author Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
  */
 
+#include "version.hpp"
+
 #include <boost/asio.hpp>
 
 #include <ndn-cxx/face.hpp>
@@ -63,7 +65,9 @@
       "   [-l lifetime] - set InterestLifetime in time::milliseconds\n"
       "   [-p]          - print payload only, not full packet\n"
       "   [-w timeout]  - set Timeout in time::milliseconds\n"
-      "   [-h]          - print help and exit\n\n";
+      "   [-h]          - print help and exit\n"
+      "   [-V]          - print version and exit\n"
+      "\n";
     exit(1);
   }
 
@@ -228,37 +232,40 @@
 {
   int option;
   ndntlvpeek::NdnTlvPeek ndnTlvPeek (argv[0]);
-  while ((option = getopt(argc, argv, "hfrm:M:l:pw:")) != -1)
-    {
-      switch (option) {
-        case 'h':
-          ndnTlvPeek.usage();
-          break;
-        case 'f':
-          ndnTlvPeek.setMustBeFresh();
-          break;
-        case 'r':
-          ndnTlvPeek.setRightmostChildSelector();
-          break;
-        case 'm':
-          ndnTlvPeek.setMinSuffixComponents(atoi(optarg));
-          break;
-        case 'M':
-          ndnTlvPeek.setMaxSuffixComponents(atoi(optarg));
-          break;
-        case 'l':
-          ndnTlvPeek.setInterestLifetime(atoi(optarg));
-          break;
-        case 'p':
-          ndnTlvPeek.setPayloadOnly();
-          break;
-        case 'w':
-          ndnTlvPeek.setTimeout(atoi(optarg));
-          break;
-        default:
-          ndnTlvPeek.usage();
-      }
+  while ((option = getopt(argc, argv, "hfrm:M:l:pw:V")) != -1) {
+    switch (option) {
+    case 'h':
+      ndnTlvPeek.usage();
+      break;
+    case 'f':
+      ndnTlvPeek.setMustBeFresh();
+      break;
+    case 'r':
+      ndnTlvPeek.setRightmostChildSelector();
+      break;
+    case 'm':
+      ndnTlvPeek.setMinSuffixComponents(atoi(optarg));
+      break;
+    case 'M':
+      ndnTlvPeek.setMaxSuffixComponents(atoi(optarg));
+      break;
+    case 'l':
+      ndnTlvPeek.setInterestLifetime(atoi(optarg));
+      break;
+    case 'p':
+      ndnTlvPeek.setPayloadOnly();
+      break;
+    case 'w':
+      ndnTlvPeek.setTimeout(atoi(optarg));
+      break;
+    case 'V':
+      std::cout << NFD_VERSION_BUILD_STRING << std::endl;
+      return 0;
+    default:
+      ndnTlvPeek.usage();
+      break;
     }
+  }
 
   argc -= optind;
   argv += optind;