Use configure option yaml path to generate elog-errors.hpp

Add a config variable that can be passed via a recipe to
point the parser to a directory where the error yaml files are.
Rename elog-gen.hpp to elog-errors.hpp, which better matches the
exception error log file names.
Include elog-gen.hpp in elog.hpp so that callers that need to
create and commit error logs only need to include one header file.

Change-Id: Ie3cd65ac761c1f7b2c99c50a2273859283a5ab4b
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/.gitignore b/.gitignore
index 122f6eb..73be2c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,7 @@
 compile
 config.*
 depcomp
-elog-gen.hpp
+phosphor-logging/elog-errors.hpp
 install-sh
 logging-test
 logging_test.o
diff --git a/Makefile.am b/Makefile.am
index 973533d..169c235 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,9 +4,8 @@
 	phosphor-logging/elog.hpp \
 	phosphor-logging/elog-errors-HostEvent.hpp
 
-# Generate this header, don't export in a distro
 nodist_include_HEADERS = \
-	elog-gen.hpp \
+	phosphor-logging/elog-errors.hpp \
 	xyz/openbmc_project/Logging/Internal/Manager/server.hpp
 
 libphosphor_logging_FILES = \
@@ -35,13 +34,13 @@
 
 # Be sure to build needed files before compiling
 BUILT_SOURCES = \
-	elog-gen.hpp \
+	phosphor-logging/elog-errors.hpp \
 	elog-lookup.cpp \
 	xyz/openbmc_project/Logging/Internal/Manager/server.cpp \
 	xyz/openbmc_project/Logging/Internal/Manager/server.hpp
 
 CLEANFILES = \
-	elog-gen.hpp \
+	phosphor-logging/elog-errors.hpp \
 	elog-lookup.cpp \
 	xyz/openbmc_project/Logging/Internal/Manager/server.cpp \
 	xyz/openbmc_project/Logging/Internal/Manager/server.hpp
@@ -68,21 +67,19 @@
 
 ELOG_MAKO ?= elog-gen-template.mako.hpp
 LOOKUP_MAKO ?= elog-lookup-template.mako.cpp
-ELOG_YAML_DIR ?= "None"
-ELOG_YAML_DIR_TEST ?= ${abs_srcdir}/tools/
 ELOG_TEMPLATE_DIR ?= ${abs_srcdir}/tools/phosphor-logging/templates/
 REQ_FILES_TO_GEN ?= ${abs_srcdir}/tools/elog-gen.py\
-	$(ELOG_YAML_DIR_TEST)/$(ELOG_YAML)\
 	${ELOG_TEMPLATE_DIR}/$(ELOG_MAKO)
 
 # Be sure to package up the required script, yaml, and mako template to
 # generate the header file
 EXTRA_DIST = $(REQ_FILES_TO_GEN)
 
-elog-gen.hpp: $(REQ_FILES_TO_GEN)
-	$(AM_V_at)$(PYTHON) ${abs_srcdir}/tools/elog-gen.py -y ${ELOG_YAML_DIR} -u ${ELOG_YAML_DIR_TEST} -t ${ELOG_TEMPLATE_DIR} -m $(ELOG_MAKO) -o ${abs_srcdir}/elog-gen.hpp
+phosphor-logging/elog-errors.hpp: $(REQ_FILES_TO_GEN)
+	@mkdir -p `dirname $@`
+	$(AM_V_at)$(PYTHON) ${abs_srcdir}/tools/elog-gen.py -y ${YAML_DIR} -u ${YAML_DIR_TEST} -t ${ELOG_TEMPLATE_DIR} -m $(ELOG_MAKO) -o $@
 elog-lookup.cpp: $(REQ_FILES_TO_GEN)
-	$(AM_V_at)$(PYTHON) ${abs_srcdir}/tools/elog-gen.py -y ${ELOG_YAML_DIR} -u ${ELOG_YAML_DIR_TEST} -t ${ELOG_TEMPLATE_DIR} -m $(LOOKUP_MAKO) -o ${abs_srcdir}/elog-lookup.cpp
+	$(AM_V_at)$(PYTHON) ${abs_srcdir}/tools/elog-gen.py -y ${YAML_DIR} -u ${YAML_DIR_TEST} -t ${ELOG_TEMPLATE_DIR} -m $(LOOKUP_MAKO) -o $@
 
 pkgconfiglibdir = ${libdir}/pkgconfig
 pkgconfiglib_DATA = phosphor-logging.pc
diff --git a/configure.ac b/configure.ac
index c99fc1f..10655ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,14 @@
 AC_DEFINE(OBJ_LOGGING, "/xyz/openbmc_project/logging", [The log manager DBus object path.])
 AC_DEFINE(OBJ_INTERNAL, "/xyz/openbmc_project/logging/internal/manager", [The private log manager DBus object path.])
 AC_DEFINE(OBJ_ENTRY, "/xyz/openbmc_project/logging/entry", [The log entry DBus object path.])
+
+AC_ARG_VAR(YAML_DIR_TEST, [The path to the test error yaml files.])
+AS_IF([test "x$YAML_DIR_TEST" == "x"], \
+    [YAML_DIR_TEST="${srcdir}/tools/"])
+AC_ARG_VAR(YAML_DIR, [The path to the yaml error files.])
+AS_IF([test "x$YAML_DIR" == "x"], \
+    [YAML_DIR="None"])
+
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile test/Makefile])
 AC_CONFIG_FILES([phosphor-logging.pc])
diff --git a/logging_test.cpp b/logging_test.cpp
index 63b59b7..96d2a36 100644
--- a/logging_test.cpp
+++ b/logging_test.cpp
@@ -5,7 +5,6 @@
 #include <sstream>
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
-#include "elog-gen.hpp"
 
 using namespace phosphor;
 using namespace logging;
diff --git a/phosphor-logging/elog.hpp b/phosphor-logging/elog.hpp
index 8a35ba5..fe79bdc 100644
--- a/phosphor-logging/elog.hpp
+++ b/phosphor-logging/elog.hpp
@@ -3,6 +3,7 @@
 #include <tuple>
 #include <utility>
 #include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog-errors.hpp>
 
 namespace phosphor
 {
diff --git a/tools/elog-gen.py b/tools/elog-gen.py
index 1a79139..360ae11 100755
--- a/tools/elog-gen.py
+++ b/tools/elog-gen.py
@@ -238,8 +238,8 @@
                       help="input mako template file to use")
 
     parser.add_option("-o", "--output", dest="output_hpp",
-                      default="elog-gen.hpp",
-                      help="output hpp to generate, elog-gen.hpp is default")
+                      default="elog-errors.hpp",
+                      help="output hpp to generate, elog-errors.hpp default")
 
     parser.add_option("-y", "--yamldir", dest="yamldir",
                       default="None",