docs: Importing initial set of library documentation from wiki

To build documentation, doxygen (+graphviz dot) and sphinx-build are
required.  Manpages are build and installed during `./waf build` stage
if sphinx-build is present.

Documentation can be build using the following commands:

    # Full set of documentation (tutorials + API) in build/docs
    ./waf docs

    # Only tutorials in `build/docs`
    ./waf sphinx

    # Only API docs in `build/docs/doxygen`
    ./waf doxgyen

Change-Id: I4c08be08ca3e22068db54584f99467aa6cf38d04
Refs: #1462
diff --git a/wscript b/wscript
index 142f03a..42532e7 100644
--- a/wscript
+++ b/wscript
@@ -184,16 +184,30 @@
 
     bld.install_files("${SYSCONFDIR}/ndn", "client.conf.sample")
 
+    if bld.env['SPHINX_BUILD']:
+        bld(features="sphinx",
+            builder="man",
+            outdir="docs/manpages",
+            config="docs/conf.py",
+            source=bld.path.ant_glob('docs/manpages/**/*.rst'),
+            install_path="${MANDIR}/")
+
+def docs(bld):
+    from waflib import Options
+    Options.commands = ['doxygen', 'sphinx'] + Options.commands
+
 def doxygen(bld):
     if not bld.env.DOXYGEN:
-        bld.fatal("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
-    bld(features="doxygen",
-        doxyfile='docs/doxygen.conf')
+        Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
+    else:
+        bld(features="doxygen",
+            doxyfile='docs/doxygen.conf')
 
 def sphinx(bld):
     if not bld.env.SPHINX_BUILD:
         bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
-    bld(features="sphinx",
-        outdir="docs/html",
-        source=bld.path.ant_glob("docs/**/*.rst"),
-        config="docs/source/conf.py")
+    else:
+        bld(features="sphinx",
+            outdir="docs",
+            source=bld.path.ant_glob("docs/**/*.rst"),
+            config="docs/conf.py")