Add systemd unit file for ndns-daemon

Refs: #4594
Change-Id: If0f1c20f795c8695f522736e3f05e983c12738db
diff --git a/systemd/ndns.service.in b/systemd/ndns.service.in
new file mode 100644
index 0000000..e8bc6c8
--- /dev/null
+++ b/systemd/ndns.service.in
@@ -0,0 +1,54 @@
+# Copyright (c) 2015-2019, Arizona Board of Regents.
+#
+# This file is part of NDNS (Named Data Networking Domain Name Service).
+# See AUTHORS.md for complete list of NDNS authors and contributors.
+#
+# NDNS is free software: you can redistribute it and/or modify it under the terms
+# of the GNU General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later version.
+#
+# NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Eric Newberry <enewberry@email.arizona.edu>
+# Author: Davide Pesavento <davidepesa@gmail.com>
+
+[Unit]
+Description=Domain Name Service for NDN
+Documentation=man:ndns-daemon(1)
+BindsTo=nfd.service
+After=nfd.service
+
+[Service]
+Environment=HOME=%S/ndn/ndns
+ExecStart=@BINDIR@/ndns-daemon
+Restart=on-failure
+RestartPreventExitStatus=2
+User=ndns
+
+LockPersonality=yes
+MemoryDenyWriteExecute=yes
+NoNewPrivileges=yes
+PrivateDevices=yes
+PrivateTmp=yes
+PrivateUsers=yes
+ProtectControlGroups=yes
+ProtectHome=yes
+ProtectKernelModules=yes
+ProtectKernelTunables=yes
+ProtectSystem=full
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=yes
+RestrictRealtime=yes
+StateDirectory=ndn/ndns
+SystemCallArchitectures=native
+SystemCallErrorNumber=EPERM
+SystemCallFilter=~@clock @cpu-emulation @debug @module @mount @obsolete @privileged @raw-io @reboot @setuid @swap
+
+[Install]
+WantedBy=multi-user.target
+WantedBy=nfd.service
diff --git a/tools/wscript b/tools/wscript
index a7cb43f..0b109de 100644
--- a/tools/wscript
+++ b/tools/wscript
@@ -1,7 +1,5 @@
 # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
-import os.path
-
 top = '..'
 
 def build(bld):
@@ -30,18 +28,16 @@
         srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
         srcObjects = ''
         if srcFiles:
-            srcObjects = 'tools-%s-objects' % name
+            srcObjects = 'tool-%s-objects' % name
             bld.objects(target=srcObjects,
                         source=srcFiles,
-                        use='ndn-cxx',
-                        includes=name)
+                        use='ndns-objects')
             testableObjects.append(srcObjects)
 
         bld.program(name=name,
                     target='../bin/%s' % name,
                     source=[mainFile],
-                    use='ndns-objects ' + srcObjects,
-                    includes=name)
+                    use='ndns-objects ' + srcObjects)
 
     bld.objects(target='tools-objects',
                 source=[],
diff --git a/wscript b/wscript
index 20dcad5..31fa6a7 100644
--- a/wscript
+++ b/wscript
@@ -58,7 +58,6 @@
         name='version.hpp',
         source='src/version.hpp.in',
         target='src/version.hpp',
-        install_path=None,
         VERSION_STRING=VERSION_BASE,
         VERSION_BUILD=VERSION,
         VERSION=int(VERSION_SPLIT[0]) * 1000000 +
@@ -70,34 +69,39 @@
 
     bld.objects(
         name='ndns-objects',
-        source=bld.path.ant_glob('src/**/*.cpp', excl=['src/main.cpp',]),
+        source=bld.path.ant_glob('src/**/*.cpp'),
         use='version NDN_CXX BOOST',
         includes='src',
         export_includes='src')
 
-    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}',
-            VERSION=VERSION)
-
     bld.recurse('tests')
-
     bld.recurse('tools')
 
     bld(features='subst',
+        name='conf-samples',
         source=['validator.conf.sample.in', 'ndns.conf.sample.in'],
         target=['validator.conf.sample', 'ndns.conf.sample'],
         install_path='${SYSCONFDIR}/ndns',
-        name='validator-sample',
         ANCHORPATH='anchors/root.cert',
         RELATION='is-prefix-of',
         DEFAULT_CONFIG_PATH='%s/ndns' % bld.env['SYSCONFDIR'],
-        DEFAULT_DATABASE_PATH='%s/ndns' % bld.env['LOCALSTATEDIR'],
-        help='the validator configuration of ndns')
+        DEFAULT_DATABASE_PATH='%s/ndns' % bld.env['LOCALSTATEDIR'])
+
+    if Utils.unversioned_sys_platform() == 'linux':
+        bld(features='subst',
+            name='ndns.service',
+            source='systemd/ndns.service.in',
+            target='systemd/ndns.service')
+
+    if bld.env.SPHINX_BUILD:
+        bld(features='sphinx',
+            name='manpages',
+            builder='man',
+            config='docs/conf.py',
+            outdir='docs/manpages',
+            source=bld.path.ant_glob('docs/manpages/**/*.rst'),
+            install_path='${MANDIR}',
+            VERSION=VERSION)
 
 def docs(bld):
     from waflib import Options