docs: Updated installation instructions, AUTHORs, and other small updates

Change-Id: Ide2046742254255322e8cb84279ffd6a4ecb9b4b
diff --git a/.waf-tools/cryptopp.py b/.waf-tools/cryptopp.py
index a05326b..ab3f7f7 100644
--- a/.waf-tools/cryptopp.py
+++ b/.waf-tools/cryptopp.py
@@ -5,14 +5,14 @@
 
 When using this tool, the wscript will look like:
 
-	def options(opt):
-	        opt.tool_options('cryptopp', tooldir=["waf-tools"])
+    def options(opt):
+        opt.tool_options('cryptopp', tooldir=["waf-tools"])
 
-	def configure(conf):
-		conf.load('compiler_cxx cryptopp')
+    def configure(conf):
+        conf.load('compiler_cxx cryptopp')
 
-	def build(bld):
-		bld(source='main.cpp', target='app', use='CRYPTOPP')
+    def build(bld):
+        bld(source='main.cpp', target='app', use='CRYPTOPP')
 
 Options are generated, in order to specify the location of cryptopp includes/libraries.
 
@@ -22,56 +22,64 @@
 import re
 from waflib import Utils,Logs,Errors
 from waflib.Configure import conf
-CRYPTOPP_DIR=['/usr','/usr/local','/opt/local','/sw']
-CRYPTOPP_VERSION_FILE='config.h'
-CRYPTOPP_VERSION_CODE='''
-#include <iostream>
-#include <cryptopp/config.h>
-int main() { std::cout << CRYPTOPP_VERSION; }
-'''
+CRYPTOPP_DIR = ['/usr', '/usr/local', '/opt/local', '/sw']
+CRYPTOPP_VERSION_FILE = 'config.h'
 
 def options(opt):
-	opt.add_option('--cryptopp',type='string',default='',dest='cryptopp_dir',help='''path to where cryptopp is installed, e.g. /opt/local''')
-@conf
-def __cryptopp_get_version_file(self,dir):
-	try:
-		return self.root.find_dir(dir).find_node('%s/%s' % ('include/cryptopp', CRYPTOPP_VERSION_FILE))
-	except:
-		return None
-@conf
-def cryptopp_get_version(self,dir):
-	val=self.check_cxx(fragment=CRYPTOPP_VERSION_CODE,includes=['%s/%s' % (dir, 'include')], execute=True, define_ret = True, mandatory=True)
-	return val
-@conf
-def cryptopp_get_root(self,*k,**kw):
-	root=k and k[0]or kw.get('path',None)
-	# Logs.pprint ('RED', '   %s' %root)
-	if root and self.__cryptopp_get_version_file(root):
-		return root
-	for dir in CRYPTOPP_DIR:
-		if self.__cryptopp_get_version_file(dir):
-			return dir
-	if root:
-		self.fatal('CryptoPP not found in %s'%root)
-	else:
-		self.fatal('CryptoPP not found, please provide a --cryptopp argument (see help)')
-@conf
-def check_cryptopp(self,*k,**kw):
-	if not self.env['CXX']:
-		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
+    opt.add_option('--cryptopp', type='string', default='', dest='cryptopp_dir',
+                   help='''Path to where CryptoPP is installed, e.g. /opt/local''')
 
-	var=kw.get('uselib_store','CRYPTOPP')
-	self.start_msg('Checking Crypto++ lib')
-	root = self.cryptopp_get_root(*k,**kw)
-	self.env.CRYPTOPP_VERSION=self.cryptopp_get_version(root)
+@conf
+def __cryptopp_get_version_file(self, dir):
+    try:
+        return self.root.find_dir(dir).find_node('%s/%s' % ('include/cryptopp',
+                                                            CRYPTOPP_VERSION_FILE))
+    except:
+        return None
 
-	self.env['INCLUDES_%s'%var]= '%s/%s' % (root, "include")
-	self.env['LIB_%s'%var] = "cryptopp"
-	self.env['LIBPATH_%s'%var] = '%s/%s' % (root, "lib")
+@conf
+def __cryptopp_find_root_and_version_file(self, *k, **kw):
+    root = k and k[0]or kw.get('path', None)
 
-	self.end_msg(self.env.CRYPTOPP_VERSION)
-	if Logs.verbose:
-		Logs.pprint('CYAN','	CRYPTOPP include : %s'%self.env['INCLUDES_%s'%var])
-		Logs.pprint('CYAN','	CRYPTOPP lib     : %s'%self.env['LIB_%s'%var])
-		Logs.pprint('CYAN','	CRYPTOPP libpath : %s'%self.env['LIBPATH_%s'%var])
+    file = self.__cryptopp_get_version_file(root)
+    if root and file:
+        return (root, file)
+    for dir in CRYPTOPP_DIR:
+        file = self.__cryptopp_get_version_file(dir)
+        if file:
+            return (dir, file)
 
+    if root:
+        self.fatal('CryptoPP not found in %s' % root)
+    else:
+        self.fatal('CryptoPP not found, please provide a --cryptopp argument (see help)')
+
+@conf
+def check_cryptopp(self, *k, **kw):
+    if not self.env['CXX']:
+        self.fatal('Load a c++ compiler first, e.g., conf.load("compiler_cxx")')
+
+    var = kw.get('uselib_store','CRYPTOPP')
+    self.start_msg('Checking Crypto++ lib')
+    (root, file) = self.__cryptopp_find_root_and_version_file(*k, **kw)
+
+    try:
+        txt = file.read()
+        re_version = re.compile('^#define\\s+CRYPTOPP_VERSION\\s+(.*)', re.M)
+        match = re_version.search(txt)
+
+        if match:
+            self.env.CRYPTOPP_VERSION = match.group(1)
+            self.end_msg(self.env.CRYPTOPP_VERSION)
+        else:
+            self.fatal('CryptoPP files are present, but are not recognizable')
+    except:
+        self.fatal('CryptoPP not found or is not usable')
+
+    val = self.check_cxx(msg='Checking if CryptoPP library works',
+                         header_name='cryptopp/config.h',
+                         lib='cryptopp',
+                         cxxflags="-I%s/include" % root,
+                         linkflags="-L%s/lib" % root,
+                         mandatory=True,
+                         uselib_store=var)
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
new file mode 100644
index 0000000..f0f0482
--- /dev/null
+++ b/.waf-tools/default-compiler-flags.py
@@ -0,0 +1,60 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+#
+# Copyright (c) 2014, Regents of the University of California
+#
+# GPL 3.0 license, see the COPYING.md file for more information
+
+from waflib import Logs, Configure
+
+def options(opt):
+    opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
+                   help='''Compile in debugging mode without all optimizations (-O0)''')
+
+def configure(conf):
+    areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
+    if conf.options.debug:
+        conf.define('_DEBUG', 1)
+        defaultFlags = ['-O0', '-g3',
+                        '-Werror',
+                        '-Wall',
+                        '-fcolor-diagnostics', # only clang supports
+
+                        # to disable known warnings
+                        '-Wno-unused-variable', # cryptopp
+                        '-Wno-unused-function',
+                        '-Wno-deprecated-declarations',
+                        ]
+
+        if areCustomCxxflagsPresent:
+            missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
+            if len(missingFlags) > 0:
+                Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
+                           % " ".join(conf.env.CXXFLAGS))
+                Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
+        else:
+            conf.add_supported_cxxflags(cxxflags = defaultFlags)
+    else:
+        defaultFlags = ['-O2', '-g', '-Wall',
+
+                        # to disable known warnings
+                        '-Wno-unused-variable', # cryptopp
+                        '-Wno-unused-function',
+                        '-Wno-deprecated-declarations',
+                        ]
+        if not areCustomCxxflagsPresent:
+            conf.add_supported_cxxflags(cxxflags = defaultFlags)
+
+@Configure.conf
+def add_supported_cxxflags(self, cxxflags):
+    """
+    Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
+    """
+    self.start_msg('Checking allowed flags for c++ compiler')
+
+    supportedFlags = []
+    for flag in cxxflags:
+        if self.check_cxx(cxxflags=[flag], mandatory=False):
+            supportedFlags += [flag]
+
+    self.end_msg(' '.join (supportedFlags))
+    self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
diff --git a/.waf-tools/doxygen.py b/.waf-tools/doxygen.py
index 07014ee..ac8c70b 100644
--- a/.waf-tools/doxygen.py
+++ b/.waf-tools/doxygen.py
@@ -9,15 +9,30 @@
 Variables passed to bld():
 * doxyfile -- the Doxyfile to use
 
-ported from waf 1.5 (incomplete)
+When using this tool, the wscript will look like:
+
+	def options(opt):
+		opt.load('doxygen')
+
+	def configure(conf):
+		conf.load('doxygen')
+		# check conf.env.DOXYGEN, if it is mandatory
+
+	def build(bld):
+		if bld.env.DOXYGEN:
+			bld(features="doxygen", doxyfile='Doxyfile', ...)
+
+        def doxygen(bld):
+		if bld.env.DOXYGEN:
+			bld(features="doxygen", doxyfile='Doxyfile', ...)
 """
 
 from fnmatch import fnmatchcase
 import os, os.path, re, stat
-from waflib import Task, Utils, Node, Logs
+from waflib import Task, Utils, Node, Logs, Errors, Build
 from waflib.TaskGen import feature
 
-DOXY_STR = '${DOXYGEN} - '
+DOXY_STR = '"${DOXYGEN}" - '
 DOXY_FMTS = 'html latex man rft xml'.split()
 DOXY_FILE_PATTERNS = '*.' + ' *.'.join('''
 c cc cxx cpp c++ java ii ixx ipp i++ inl h hh hxx hpp h++ idl odl cs php php3
@@ -68,6 +83,11 @@
 			if not self.pars.get('OUTPUT_DIRECTORY'):
 				self.pars['OUTPUT_DIRECTORY'] = self.inputs[0].parent.get_bld().abspath()
 
+			# Override with any parameters passed to the task generator
+			if getattr(self.generator, 'pars', None):
+				for k, v in self.generator.pars.iteritems():
+					self.pars[k] = v
+
 			self.doxy_inputs = getattr(self, 'doxy_inputs', [])
 			if not self.pars.get('INPUT'):
 				self.doxy_inputs.append(self.inputs[0].parent)
@@ -92,19 +112,17 @@
 		return Task.Task.runnable_status(self)
 
 	def scan(self):
-		if self.pars.get('RECURSIVE') == 'YES':
-			Logs.warn("Doxygen RECURSIVE dependencies are not supported")
-
-		exclude_patterns = self.pars.get('EXCLUDE_PATTERNS', '').split()
-		file_patterns = self.pars.get('FILE_PATTERNS', '').split()
+		exclude_patterns = self.pars.get('EXCLUDE_PATTERNS','').split()
+		file_patterns = self.pars.get('FILE_PATTERNS','').split()
 		if not file_patterns:
 			file_patterns = DOXY_FILE_PATTERNS
-
+		if self.pars.get('RECURSIVE') == 'YES':
+			file_patterns = ["**/%s" % pattern for pattern in file_patterns]
 		nodes = []
 		names = []
 		for node in self.doxy_inputs:
 			if os.path.isdir(node.abspath()):
-				for m in node.ant_glob(file_patterns):
+				for m in node.ant_glob(incl=file_patterns, excl=exclude_patterns):
 					nodes.append(m)
 			else:
 				nodes.append(node)
@@ -112,8 +130,7 @@
 
 	def run(self):
 		dct = self.pars.copy()
-		# TODO will break if paths have spaces
-		dct['INPUT'] = ' '.join([x.abspath() for x in self.doxy_inputs])
+		dct['INPUT'] = ' '.join(['"%s"' % x.abspath() for x in self.doxy_inputs])
 		code = '\n'.join(['%s = %s' % (x, dct[x]) for x in self.pars])
 		code = code.encode() # for python 3
 		#fmt = DOXY_STR % (self.inputs[0].parent.abspath())
@@ -179,6 +196,19 @@
 			tsk.env['TAROPTS'] = ['cf']
 
 def configure(conf):
-	conf.find_program('doxygen', var='DOXYGEN')
-	conf.find_program('tar', var='TAR')
+	'''
+	Check if doxygen and tar commands are present in the system
 
+	If the commands are present, then conf.env.DOXYGEN and conf.env.TAR
+	variables will be set. Detection can be controlled by setting DOXYGEN and
+	TAR environmental variables.
+	'''
+
+	conf.find_program('doxygen', var='DOXYGEN', mandatory=False)
+	conf.find_program('tar', var='TAR', mandatory=False)
+
+# doxygen docs
+from waflib.Build import BuildContext
+class doxy(BuildContext):
+    cmd = "doxygen"
+    fun = "doxygen"
diff --git a/.waf-tools/openssl.py b/.waf-tools/openssl.py
index 7f599a9..4a5c01f 100644
--- a/.waf-tools/openssl.py
+++ b/.waf-tools/openssl.py
@@ -5,16 +5,16 @@
 
 When using this tool, the wscript will look like:
 
-	def options(opt):
-	        opt.tool_options('openssl')
+    def options(opt):
+        opt.tool_options('openssl')
 
-	def configure(conf):
-		conf.load('compiler_c openssl')
+    def configure(conf):
+        conf.load('compiler_c openssl')
 
-                conf.check_openssl()
+        conf.check_openssl()
 
-	def build(bld):
-		bld(source='main.cpp', target='app', use='OPENSSL')
+    def build(bld):
+        bld(source='main.cpp', target='app', use='OPENSSL')
 
 '''
 
@@ -23,37 +23,38 @@
 
 @conf
 def check_openssl(self,*k,**kw):
-        root = k and k[0] or kw.get('path',None) or Options.options.with_openssl
-        mandatory = kw.get('mandatory', True)
-        var = kw.get('var', 'OPENSSL')
+    root = k and k[0] or kw.get('path',None) or Options.options.with_openssl
+    mandatory = kw.get('mandatory', True)
+    var = kw.get('var', 'OPENSSL')
 
-        CODE = """
+    CODE = """
 #include <openssl/crypto.h>
 #include <stdio.h>
 
 int main(int argc, char **argv) {
-	(void)argc;
-        printf ("%s", argv[0]);
+    (void)argc;
+    printf("%s", argv[0]);
 
-	return 0;
+    return 0;
 }
 """
-        if root:
-                libcrypto = self.check_cc (lib=['ssl', 'crypto'],
-                                           header_name='openssl/crypto.h',
-                                           define_name='HAVE_%s' % var,
-                                           uselib_store=var,
-                                           mandatory = mandatory,
-                                           cflags="-I%s/include" % root,
-                                           linkflags="-L%s/lib" % root,
-                                           execute = True, fragment = CODE, define_ret = True)
-        else:
-                libcrypto = self.check_cc (lib=['ssl', 'crypto'],
-                                           header_name='openssl/crypto.h',
-                                           define_name='HAVE_%s' % var,
-                                           uselib_store=var,
-                                           mandatory = mandatory,
-                                           execute = True, fragment = CODE, define_ret = True)
+    if root:
+        libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
+                       msg='Checking for OpenSSL library',
+                       define_name='HAVE_%s' % var,
+                       uselib_store=var,
+                       mandatory=mandatory,
+                       cflags="-I%s/include" % root,
+                       linkflags="-L%s/lib" % root,
+                       fragment=CODE)
+    else:
+        libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
+                       msg='Checking for OpenSSL library',
+                       define_name='HAVE_%s' % var,
+                       uselib_store=var,
+                       mandatory=mandatory,
+                       fragment=CODE)
 
 def options(opt):
-        opt.add_option('--with-openssl',type='string',default='',dest='with_openssl',help='''Path to OpenSSL''')
+    opt.add_option('--with-openssl', type='string', default='',
+                   dest='with_openssl', help='''Path to OpenSSL''')
diff --git a/.waf-tools/sphinx_build.py b/.waf-tools/sphinx_build.py
index e1155d1..53cc431 100644
--- a/.waf-tools/sphinx_build.py
+++ b/.waf-tools/sphinx_build.py
@@ -10,8 +10,13 @@
 
 Usage for getting both html and pdf docs:
 
-    ctx(features='sphinx', source='docs/conf.py')
-    ctx(features='sphinx', source='docs/conf.py', buildername='latex')
+    def build(ctx):
+        ctx(features='sphinx', source='docs/conf.py')
+        ctx(features='sphinx', source='docs/conf.py', buildername='latex')
+
+    def sphinx(ctx):
+        ctx(features='sphinx', source='docs/conf.py')
+        ctx(features='sphinx', source='docs/conf.py', buildername='latex')
 
 Optional parameters and their defaults:
 
@@ -25,7 +30,7 @@
 
 
 import os
-from waflib import Task, TaskGen, Errors, Logs
+from waflib import Task, TaskGen, Errors, Logs, Build
 
 class RunSphinxBuild(Task.Task):
 	def scan(self):
@@ -84,7 +89,7 @@
 	buildername = getattr(tg, "buildername", "html")
 	srcdir = getattr(tg, "srcdir", confdir)
 	outdir = tg.path.find_or_declare (getattr(tg, "outdir", os.path.join(conf.parent.get_bld().abspath(), buildername))).abspath ()
-        
+
 	doctreedir = getattr(tg, "doctreedir", os.path.join(outdir, ".doctrees"))
 
 	# Set up the Sphinx instance.
@@ -93,7 +98,7 @@
 	# Get the main targets of the Sphinx build.
 	tgt_nodes = _get_main_targets(tg, s)
 
-	# Create the task and set the required attributes.  
+	# Create the task and set the required attributes.
 	task = tg.create_task("RunSphinxBuild", src=conf, tgt=tgt_nodes)
 	task.srcdir = tg.bld.root.find_node(s.srcdir)
 	task.outdir = tg.bld.root.find_node(s.outdir)
@@ -106,3 +111,9 @@
 
 	# Bypass the execution of process_source by setting the source to an empty list
 	tg.source = []
+
+# sphinx docs
+from waflib.Build import BuildContext
+class sphinx (BuildContext):
+    cmd = "sphinx"
+    fun = "sphinx"