meson support: create meson.build files

This commit contains the meson.build files necessary to build the
project and unit tests. The normal procedure is to run the command
'meson build' followed by ninja -C build. Additionally, service files
are copied to remove autoconf-style naming convention (they cannot be
  removed before autoconf files are removed).

Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I6cf8f5c1c923a198ad2fb4638843645479fd0498
diff --git a/control/functor.hpp b/control/functor.hpp
index 59e15df..da5ffe1 100644
--- a/control/functor.hpp
+++ b/control/functor.hpp
@@ -102,7 +102,7 @@
      * Extract the property from the PropertiesChanged
      * message and run the handler function.
      */
-    void operator()(sdbusplus::bus_t& bus, sdbusplus::message_t& msg,
+    void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
                     Zone& zone) const
     {
         if (msg)
@@ -403,7 +403,7 @@
      * Extract the name owner from the NameOwnerChanged
      * message and run the handler function.
      */
-    void operator()(sdbusplus::bus_t& bus, sdbusplus::message_t& msg,
+    void operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
                     Zone& zone) const
     {
         if (msg)
diff --git a/control/main.cpp b/control/main.cpp
index 90f8e5c..201f7b0 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -16,14 +16,13 @@
 #include "config.h"
 
 #ifndef CONTROL_USE_JSON
-#include "../utils/flight_recorder.hpp"
 #include "argument.hpp"
 #include "manager.hpp"
 #else
+#include "../utils/flight_recorder.hpp"
 #include "json/manager.hpp"
 #endif
 
-#include "event.hpp"
 #include "sdbusplus.hpp"
 #include "sdeventplus.hpp"
 
diff --git a/control/meson.build b/control/meson.build
new file mode 100644
index 0000000..5225b0c
--- /dev/null
+++ b/control/meson.build
@@ -0,0 +1,107 @@
+
+include_dirs=[
+    '.',
+    '..'
+]
+
+deps=[
+    phosphor_dbus_interfaces_dep,
+    phosphor_logging_dep,
+    sdbusplus_dep,
+    sdeventplus_dep
+]
+
+sources = ['main.cpp']
+
+if conf.has('CONTROL_USE_JSON')
+    deps += json_dep
+    include_dirs += [
+        './json',
+        './json/actions',
+        './json/triggers'
+    ]
+    sources += [
+        'json/dbus_zone.cpp',
+        'json/event.cpp',
+        'json/fan.cpp',
+        'json/group.cpp',
+        'json/manager.cpp',
+        'json/profile.cpp',
+        'json/zone.cpp',
+        'json/actions/count_state_floor.cpp',
+        'json/actions/count_state_target.cpp',
+        'json/actions/default_floor.cpp',
+        'json/actions/get_managed_objects.cpp',
+        'json/actions/mapped_floor.cpp',
+        'json/actions/missing_owner_target.cpp',
+        'json/actions/net_target_decrease.cpp',
+        'json/actions/net_target_increase.cpp',
+        'json/actions/override_fan_target.cpp',
+        'json/actions/pcie_card_floors.cpp',
+        'json/actions/request_target_base.cpp',
+        'json/actions/set_parameter_from_group_max.cpp',
+        'json/actions/timer_based_actions.cpp',
+        'json/utils/flight_recorder.cpp',
+        'json/utils/modifier.cpp',
+        'json/utils/pcie_card_metadata.cpp',
+        'json/triggers/init.cpp',
+        'json/triggers/parameter.cpp',
+        'json/triggers/signal.cpp',
+        'json/triggers/timer.cpp'
+    ]
+else
+    fan_zone_defs_cpp_dep = custom_target(
+        'fan_zone_defs.cpp',
+        input: files(
+            './gen-fan-zone-defs.py',
+            conf.get_unquoted('FAN_DEF_YAML_FILE'),
+            conf.get_unquoted('FAN_ZONE_YAML_FILE'),
+            conf.get_unquoted('ZONE_EVENTS_YAML_FILE'),
+            conf.get_unquoted('ZONE_CONDITIONS_YAML_FILE')
+        ),
+        command: [
+            python_prog, '@INPUT0@',
+            '-f','@INPUT1@',
+            '-z','@INPUT2@',
+            '-e','@INPUT3@',
+            '-c','@INPUT4@',
+            '-o', 'control'
+        ],
+        output: 'fan_zone_defs.cpp'
+    )
+
+    sources += [
+        'actions.cpp',
+        'argument.cpp',
+        'fan.cpp',
+        fan_zone_defs_cpp_dep,
+        'manager.cpp',
+        'preconditions.cpp',
+        'triggers.cpp',
+        'utility.cpp',
+        'zone.cpp'
+    ]
+
+endif
+
+phosphor_fan_control_include_directories = include_directories(include_dirs)
+phosphor_fan_control = executable(
+    'phosphor-fan-control',
+    sources,
+    dependencies:deps,
+    implicit_include_directories: false,
+    include_directories: phosphor_fan_control_include_directories,
+    install: true
+)
+
+fanctl = executable(
+  'fanctl',
+  'fanctl.cpp',
+      dependencies: [
+          cli11_dep,
+          fmt_dep,
+          sdbusplus_dep
+      ],
+  include_directories: phosphor_fan_control_include_directories,
+  install: true
+)
diff --git a/control/service_files/json/phosphor-fan-control@.service b/control/service_files/json/phosphor-fan-control@.service
new file mode 100644
index 0000000..5085590
--- /dev/null
+++ b/control/service_files/json/phosphor-fan-control@.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Phosphor Fan Control Daemon
+
+[Service]
+Restart=on-failure
+ExecStart=/usr/bin/phosphor-fan-control
diff --git a/control/service_files/yaml/phosphor-fan-control-init@.service b/control/service_files/yaml/phosphor-fan-control-init@.service
new file mode 100644
index 0000000..c012be8
--- /dev/null
+++ b/control/service_files/yaml/phosphor-fan-control-init@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Phosphor Fan Control Initialization
+Wants=obmc-power-on@%i.target
+After=obmc-power-on@%i.target
+Conflicts=obmc-chassis-powered-off@%i.target
+
+[Service]
+Restart=on-failure
+ExecStart=/usr/bin/phosphor-fan-control --init
+SyslogIdentifier=phosphor-fan-control
+
+[Install]
+WantedBy=obmc-chassis-poweron@%i.target
diff --git a/control/service_files/yaml/phosphor-fan-control@.service b/control/service_files/yaml/phosphor-fan-control@.service
new file mode 100644
index 0000000..693363a
--- /dev/null
+++ b/control/service_files/yaml/phosphor-fan-control@.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Phosphor Fan Control Daemon
+Conflicts=obmc-chassis-powered-off@%i.target
+
+[Service]
+Restart=on-failure
+ExecStart=/usr/bin/phosphor-fan-control --control
+SyslogIdentifier=phosphor-fan-control
+
+[Install]
+RequiredBy=obmc-fan-control-ready@%i.target