presence: Add service file to repo

This adds the fan presence service files, one for YAML mode and a
different one for JSON mode, to the repository.  Which one is installed
is based on the --enable-json value.

The JSON mode service file is designed to start as part of the system
reaching the multi-user target.  The YAML mode service file is designed
to start when the chassis is powered on.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ifd65c98a0d8eab83a06c303221e4b4c69c4a0f7b
diff --git a/configure.ac b/configure.ac
index c31f09b..9523a0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,21 @@
     AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
 )
 
+PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([systemdsystemunitdir],
+     [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
+     [with_systemdsystemunitdir=auto])
+AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
+     def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+
+     AS_IF([test "x$def_systemdsystemunitdir" = "x"],
+   [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
+    [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
+    with_systemdsystemunitdir=no],
+   [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
+AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
+      [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
+
 AC_ARG_ENABLE([json],
     AS_HELP_STRING([--enable-json], [Use json at runtime to configure fan packages.]))
 AC_ARG_ENABLE([presence],
@@ -92,6 +107,7 @@
         # Set config flag for runtime json usage
         AC_DEFINE([PRESENCE_USE_JSON], [1], [Fan presence use runtime json configuration])
         AC_MSG_NOTICE([Fan presence json configuration usage enabled])
+        AC_CONFIG_FILES([presence/service_files/json/phosphor-fan-presence-tach@.service])
     ],
     [
         # Add optional yaml file argument
@@ -105,6 +121,8 @@
 
        AC_SUBST([PFPGEN],
                 ["$PYTHON \${top_srcdir}/presence/pfpgen.py generate-cpp -i $PRESENCE_CONFIG"])
+
+        AC_CONFIG_FILES([presence/service_files/yaml/phosphor-fan-presence-tach@.service])
     ])
 
     AC_ARG_VAR(NUM_PRESENCE_LOG_ENTRIES, [Maximum number of entries in the message log])
@@ -262,6 +280,10 @@
     AC_CONFIG_FILES([sensor-monitor/Makefile])
 ])
 
+eval "eval BINDIR=$bindir"
+AC_SUBST([BINDIR])
+
+
 # Create configured output
 AC_CONFIG_FILES([Makefile test/Makefile presence/test/Makefile monitor/test/Makefile])
 AC_OUTPUT