Disable transaction id support by default

Allow the transaction id support to be enabled via
configure options.
In the code, ifdef the code based if transaction support
is desired.

Change-Id: I98695268397f437b6fe14621f820fbcaecb45b7a
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 552dc69..175355c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,12 +22,18 @@
 	sdbusplus/utility/type_traits.hpp \
 	sdbusplus/vtable.hpp
 
-LIBSDBUSPLUS_FILES = \
+LIBSDBUSPLUS_FILES =
+
+if WANT_TRANSACTION
+LIBSDBUPLUS_FILES_TRANSACTION = \
 	sdbusplus/server/transaction.cpp
+endif
 
 libsdbusplusdir = ${libdir}
 libsdbusplus_LTLIBRARIES = libsdbusplus.la
-libsdbusplus_la_SOURCES = $(LIBSDBUSPLUS_FILES)
+libsdbusplus_la_SOURCES = \
+	$(LIBSDBUSPLUS_FILES) \
+	$(LIBSDBUPLUS_FILES_TRANSACTION)
 libsdbusplus_la_LDFLAGS = $(SYSTEMD_LIBS) -version-info 1:0:0 -shared
 libsdbusplus_la_CXXFLAGS = $(SYSTEMD_CFLAGS)
 
diff --git a/configure.ac b/configure.ac
index f278240..493ca4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,15 @@
 
 AM_CONDITIONAL([WANT_LIBSDBUSPLUS], [test "x$enable_libsdbusplus" != "xno"])
 
+# setup transaction
+AC_ARG_ENABLE([transaction],
+    AS_HELP_STRING([--enable-transaction], [Enable transaction id support.]))
+AC_ARG_VAR(WANT_TRANSACTION, [Enable transaction id support.])
+AS_IF([test "x$enable_transaction" = "xyes"], \
+    [WANT_TRANSACTION="1"], \
+    [WANT_TRANSACTION="0"])
+AM_CONDITIONAL([WANT_TRANSACTION], [test "x$enable_transaction" = "xyes"])
+
 # Checks for header files.
 AS_IF([test "x$enable_libsdbusplus" != "xno"],
       [AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])])])
@@ -78,4 +87,8 @@
 # Create configured output
 AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile tools/setup.py])
 AC_CONFIG_FILES([sdbusplus.pc])
+AC_CONFIG_FILES([sdbusplus/bus.hpp])
+AC_CONFIG_FILES([sdbusplus/server.hpp])
+AC_CONFIG_FILES([tools/sdbusplus/templates/interface.mako.server.cpp])
+AC_CONFIG_FILES([tools/sdbusplus/templates/method.mako.prototype.hpp])
 AC_OUTPUT
diff --git a/sdbusplus/bus.hpp b/sdbusplus/bus.hpp.in
similarity index 99%
rename from sdbusplus/bus.hpp
rename to sdbusplus/bus.hpp.in
index 48c8791..94d5588 100644
--- a/sdbusplus/bus.hpp
+++ b/sdbusplus/bus.hpp.in
@@ -239,7 +239,7 @@
 
 inline bus::bus(busp_t b) : _bus(b)
 {
-#ifndef DISABLE_TRANSACTION
+#if @WANT_TRANSACTION@
     // Emitting object added causes a message to get the properties
     // which can trigger a 'transaction' in the server bindings.  If
     // the bus isn't up far enough, this causes an assert deep in
diff --git a/sdbusplus/server.hpp b/sdbusplus/server.hpp.in
similarity index 91%
rename from sdbusplus/server.hpp
rename to sdbusplus/server.hpp.in
index 22bf440..b177d5e 100644
--- a/sdbusplus/server.hpp
+++ b/sdbusplus/server.hpp.in
@@ -8,4 +8,6 @@
 #include <sdbusplus/server/object.hpp>
 #include <sdbusplus/server/match.hpp>
 #include <sdbusplus/server/bindings.hpp>
+#if @WANT_TRANSACTION@
 #include <sdbusplus/server/transaction.hpp>
+#endif
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp b/tools/sdbusplus/templates/interface.mako.server.cpp.in
similarity index 98%
rename from tools/sdbusplus/templates/interface.mako.server.cpp
rename to tools/sdbusplus/templates/interface.mako.server.cpp.in
index 14dfa01..165db62 100644
--- a/tools/sdbusplus/templates/interface.mako.server.cpp
+++ b/tools/sdbusplus/templates/interface.mako.server.cpp.in
@@ -64,7 +64,7 @@
     try
     {
         auto m = message::message(reply);
-#ifndef DISABLE_TRANSACTION
+#if @WANT_TRANSACTION@
         {
             auto tbus = m.get_bus();
             sdbusplus::server::transaction::Transaction t(tbus, m);
@@ -105,7 +105,7 @@
     try
     {
         auto m = message::message(value);
-#ifndef DISABLE_TRANSACTION
+#if @WANT_TRANSACTION@
         {
             auto tbus = m.get_bus();
             sdbusplus::server::transaction::Transaction t(tbus, m);
diff --git a/tools/sdbusplus/templates/method.mako.prototype.hpp b/tools/sdbusplus/templates/method.mako.prototype.hpp.in
similarity index 99%
rename from tools/sdbusplus/templates/method.mako.prototype.hpp
rename to tools/sdbusplus/templates/method.mako.prototype.hpp.in
index 0c4615e..f773f3f 100644
--- a/tools/sdbusplus/templates/method.mako.prototype.hpp
+++ b/tools/sdbusplus/templates/method.mako.prototype.hpp.in
@@ -128,7 +128,7 @@
         ### Need to add a ref to msg since we attached it to an
         ### sdbusplus::message.
         auto m = message::message(msg);
-#ifndef DISABLE_TRANSACTION
+#if @WANT_TRANSACTION@
         {
             auto tbus = m.get_bus();
             sdbusplus::server::transaction::Transaction t(tbus, m);