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/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index 1de90ab..40ea488 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -32,6 +32,7 @@
 #include <boost/program_options/variables_map.hpp>
 #include <boost/program_options/parsers.hpp>
 
+#include "version.hpp"
 #include "core/face-uri.hpp"
 #include "network.hpp"
 
@@ -248,6 +249,7 @@
        "Whitelisted network, e.g., 192.168.2.0/24 or ::1/128")
       ("blacklist,b", po::value<std::vector<Network> >(&m_blackList)->composing(),
        "Blacklisted network, e.g., 192.168.2.32/30 or ::1/128")
+      ("version,V", "show version and exit")
       ;
 
     po::variables_map options;
@@ -269,6 +271,12 @@
         return 0;
       }
 
+    if (options.count("version"))
+      {
+        std::cout << NFD_VERSION_BUILD_STRING << std::endl;
+        return 0;
+      }
+
     if (m_autoregPrefixes.empty())
       {
         std::cerr << "ERROR: at least one --prefix must be specified" << std::endl << std::endl;