build: split app/test pimgen invocation

Run pimgen twice, once for the application with the real YAML
and once for the testcase with the example YAML so that the
testcase can run and build sucessfully when an alternate YAML
tree is provided.

Move extra interface rule generation from pimgen to a makefile
generating script.

Change-Id: Ib0c01bd2207007b815019232a466fa16889f2005
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index 1f6470d..07f8453 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,8 +1,27 @@
+BUILT_SOURCES=generated.cpp extra_ifaces.cpp
+CLEANFILES=$(BUILT_SOURCES)
+
+AM_CPPFLAGS = -iquote$(top_srcdir)
+
 check_PROGRAMS =
 noinst_PROGRAMS = phosphor-inventory-test
+noinst_LTLIBRARIES = libtest.la
 
-phosphor_inventory_test_SOURCES = \
-	test.cpp
-phosphor_inventory_test_LDFLAGS = $(SYSTEMD_LIBS) $(PTHREAD_CFLAGS)
-phosphor_inventory_test_CFLAGS = $(SYSTEMD_CFLAGS)
-phosphor_inventory_test_LDADD = ${top_builddir}/libmanager.la
+extra_yamldir=$(top_srcdir)/example/extra_interfaces.d
+
+phosphor_inventory_test_SOURCES = test.cpp
+phosphor_inventory_test_LDADD = libtest.la
+phosphor_inventory_test_LDFLAGS = $(SDBSUPLUS_LIBS) $(PTHREAD_CFLAGS)
+phosphor_inventory_test_CFLAGS = $(SDBUSPLUS_CFLAGS)
+
+libtest_la_SOURCES = \
+	extra_ifaces.cpp \
+	generated.cpp
+libtest_la_LIBADD = $(top_builddir)/libmanagercommon.la $(SDBUSPLUS_LIBS)
+
+clean-local: clean-extra
+
+generated.cpp:
+	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/pimgen.py -d $(extra_yamldir)/.. -o $(builddir) generate-cpp
+
+-include Makefile.extra