daemon: basic systemd integration

Notify systemd when NFD is ready/reloading/terminating

Change-Id: I833b48fbcaf6ecc2c4bb8a1da67d4eb9a050c116
Refs: #2815
diff --git a/wscript b/wscript
index c5f8b33..6773293 100644
--- a/wscript
+++ b/wscript
@@ -41,15 +41,16 @@
              tooldir=['.waf-tools'])
 
     nfdopt = opt.add_option_group('NFD Options')
-    opt.addUnixOptions(nfdopt)
-    opt.addWebsocketOptions(nfdopt)
 
+    opt.addUnixOptions(nfdopt)
+    opt.addDependencyOptions(nfdopt, 'libresolv')
+    opt.addDependencyOptions(nfdopt, 'librt')
     opt.addDependencyOptions(nfdopt, 'libpcap')
     nfdopt.add_option('--without-libpcap', action='store_true', default=False,
                       help='Disable libpcap (Ethernet face support will be disabled)')
-
-    opt.addDependencyOptions(nfdopt, 'librt')
-    opt.addDependencyOptions(nfdopt, 'libresolv')
+    nfdopt.add_option('--without-systemd', action='store_true', default=False,
+                      help='Disable systemd integration')
+    opt.addWebsocketOptions(nfdopt)
 
     nfdopt.add_option('--with-tests', action='store_true', default=False,
                       help='Build unit tests')
@@ -87,6 +88,13 @@
                'pch', 'boost', 'dependency-checker', 'websocket',
                'doxygen', 'sphinx_build'])
 
+    if conf.options.with_tests:
+        conf.env.WITH_TESTS = True
+        conf.define('WITH_TESTS', 1)
+    if conf.options.with_other_tests:
+        conf.env.WITH_OTHER_TESTS = True
+        conf.define('WITH_OTHER_TESTS', 1)
+
     conf.find_program('bash', var='BASH')
 
     if 'PKG_CONFIG_PATH' not in os.environ:
@@ -94,6 +102,9 @@
     conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
                    uselib_store='NDN_CXX', mandatory=True)
 
+    conf.check_cfg(package='libsystemd', args=['--cflags', '--libs'],
+                   uselib_store='SYSTEMD', mandatory=False)
+
     conf.checkDependency(name='librt', lib='rt', mandatory=False)
     conf.checkDependency(name='libresolv', lib='resolv', mandatory=False)
 
@@ -103,14 +114,6 @@
 
     conf.check_cxx(header_name='valgrind/valgrind.h', define_name='HAVE_VALGRIND', mandatory=False)
 
-    if conf.options.with_tests:
-        conf.env.WITH_TESTS = True
-        conf.define('WITH_TESTS', 1)
-
-    if conf.options.with_other_tests:
-        conf.env.WITH_OTHER_TESTS = True
-        conf.define('WITH_OTHER_TESTS', 1)
-
     boost_libs = 'system chrono program_options thread log log_setup'
     if conf.options.with_tests or conf.options.with_other_tests:
         boost_libs += ' unit_test_framework'
@@ -122,13 +125,14 @@
                    ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)')
 
     conf.load('unix-socket')
-    conf.checkWebsocket(mandatory=True)
 
     if not conf.options.without_libpcap:
         conf.checkDependency(name='libpcap', lib='pcap', mandatory=True,
                              errmsg='not found, but required for Ethernet face support. '
                                     'Specify --without-libpcap to disable Ethernet face support.')
 
+    conf.checkWebsocket(mandatory=True)
+
     conf.check_compiler_flags()
 
     # Loading "late" to prevent tests from being compiled with profiling flags
@@ -201,7 +205,7 @@
     bld.program(name='nfd',
                 target='bin/nfd',
                 source='daemon/main.cpp',
-                use='daemon-objects rib-objects')
+                use='daemon-objects rib-objects SYSTEMD')
 
     bld.recurse('tools')
     bld.recurse('tests')