presence: Invoke pfpgen.py

Invoke the new parser during build.

Change-Id: I3a3c8c227a79e6f80a051c5e1d3a9a2b7f4e9656
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/configure.ac b/configure.ac
index 11d557e..e6ba9d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,13 +76,24 @@
        # Add optional yaml file argument
        AC_ARG_VAR(FAN_DETECT_YAML_FILE,
                   [The fan presence detection definition file to use])
+       AC_ARG_VAR(PRESENCE_CONFIG,
+                  [The fan presence config file.])
+
        AS_IF([test "x$FAN_DETECT_YAML_FILE" == "x"],
              [FAN_DETECT_YAML_FILE="\${top_srcdir}/presence/example/fan-detect.yaml"])
+       AS_IF([test "x$PRESENCE_CONFIG" == "x"],
+             [PRESENCE_CONFIG="\${top_srcdir}/presence/example/example.yaml"])
+
        AC_DEFINE_UNQUOTED([FAN_DETECT_YAML_FILE], ["$FAN_DETECT_YAML_FILE"],
                           [The fan presence detection definition file to use])
+       AC_DEFINE_UNQUOTED([PRESENCE_CONFIG], ["$PRESENCE_CONFIG"],
+                          [The fan presence config file.])
 
        AC_SUBST([GEN_FAN_DETECT_DEFS],
                 ["$PYTHON \${top_srcdir}/presence/gen-fan-detect-defs.py -y $FAN_DETECT_YAML_FILE"])
+       AC_SUBST([PFPGEN],
+                ["$PYTHON \${top_srcdir}/presence/pfpgen.py generate-cpp -i $PRESENCE_CONFIG"])
+
        AC_CONFIG_FILES([presence/Makefile])
        ])
 
diff --git a/presence/.gitignore b/presence/.gitignore
new file mode 100644
index 0000000..c992cd8
--- /dev/null
+++ b/presence/.gitignore
@@ -0,0 +1 @@
+/generated.hpp
diff --git a/presence/Makefile.am b/presence/Makefile.am
index 33f13a3..134ee3c 100644
--- a/presence/Makefile.am
+++ b/presence/Makefile.am
@@ -27,7 +27,12 @@
 	${PHOSPHOR_DBUS_INTERFACES_CFLAGS} \
 	$(LIBEVDEV_CFLAGS)
 
-BUILT_SOURCES = fan_detect_defs.cpp
+BUILT_SOURCES = fan_detect_defs.cpp generated.hpp
+TEMPLATES = \
+	templates/generated.mako.hpp
 
 fan_detect_defs.cpp: ${srcdir}/gen-fan-detect-defs.py $(FAN_DETECT_YAML_FILE)
 	$(AM_V_GEN)$(GEN_FAN_DETECT_DEFS) > $(builddir)/$@
+
+generated.hpp: $(TEMPLATES) ${srcdir}/pfpgen.py $(PRESENCE_CONFIG)
+	$(AM_V_GEN)$(PFPGEN) > $(builddir)/$@
diff --git a/presence/tach_detect.cpp b/presence/tach_detect.cpp
index 6284f89..6ec5a5c 100644
--- a/presence/tach_detect.cpp
+++ b/presence/tach_detect.cpp
@@ -17,6 +17,7 @@
 #include <vector>
 #include "fan_enclosure.hpp"
 #include "fan_detect_defs.hpp"
+#include "generated.hpp"
 #include "sdbusplus.hpp"
 #include "tach_sensor.hpp"