diff --git a/Makefile.am b/Makefile.am index c6d4315ed..f73047f0e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,9 @@ include aminclude.am -SUBDIRS = ltdl \ +SUBDIRS = \ + compat \ + ltdl \ mmatch \ cJSON \ base \ diff --git a/base/Makefile.am b/base/Makefile.am index 9c947730b..5a2947c7b 100644 --- a/base/Makefile.am +++ b/base/Makefile.am @@ -53,6 +53,7 @@ libbase_la_SOURCES = \ libbase_la_CXXFLAGS = \ -DI2_BASE_BUILD \ $(LTDLINCL) \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/mmatch libbase_la_LDFLAGS = \ @@ -61,4 +62,5 @@ libbase_la_LDFLAGS = \ libbase_la_LIBADD = \ $(LIBLTDL) \ + $(BOOST_LDFLAGS) \ ${top_builddir}/mmatch/libmmatch.la diff --git a/base/application.cpp b/base/application.cpp index 63c21556c..d1c4fd5d1 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -26,6 +26,7 @@ using namespace icinga; Application::Ptr I2_EXPORT Application::m_Instance; +bool I2_EXPORT Application::m_ShuttingDown = false; /** * Constructor for the Application class. @@ -50,7 +51,6 @@ Application::Application(void) m_Debugging = true; #endif /* _WIN32 */ - m_ShuttingDown = false; m_ConfigHive = make_shared(); } @@ -59,6 +59,8 @@ Application::Application(void) */ Application::~Application(void) { + m_ShuttingDown = true; + /* stop all components */ for (map::iterator i = m_Components.begin(); i != m_Components.end(); i++) { @@ -81,7 +83,10 @@ Application::~Application(void) */ Application::Ptr Application::GetInstance(void) { - return m_Instance; + if (m_ShuttingDown) + return Application::Ptr(); + else + return m_Instance; } /** diff --git a/base/application.h b/base/application.h index 3996cd779..5b22db9f6 100644 --- a/base/application.h +++ b/base/application.h @@ -45,7 +45,7 @@ public: virtual int Main(const vector& args) = 0; - void Shutdown(void); + static void Shutdown(void); static void Log(string message); @@ -65,9 +65,9 @@ protected: string GetExeDirectory(void) const; private: - static Application::Ptr m_Instance; + static Application::Ptr m_Instance; /**< The application instance. */ - bool m_ShuttingDown; /**< Whether the application is in the process of + static bool m_ShuttingDown; /**< Whether the application is in the process of shutting down. */ ConfigHive::Ptr m_ConfigHive; /**< The application's configuration. */ map< string, shared_ptr > m_Components; /**< Components that diff --git a/base/object.cpp b/base/object.cpp index be1858b12..8bee4935c 100644 --- a/base/object.cpp +++ b/base/object.cpp @@ -33,4 +33,5 @@ Object::Object(void) */ Object::~Object(void) { -} \ No newline at end of file +} + diff --git a/compat/Makefile.am b/compat/Makefile.am new file mode 100644 index 000000000..229d9e1a2 --- /dev/null +++ b/compat/Makefile.am @@ -0,0 +1,9 @@ +EXTRA_DIST=include + +dist-hook: + mkdir -p boost && \ + bcp --boost=$(BOOST_PATH)/include tr1 smart_ptr bind function make_shared boost && \ + rm -Rf include && \ + mkdir include && \ + mv boost/boost include/ && \ + rm -Rf boost diff --git a/components/configfile/Makefile.am b/components/configfile/Makefile.am index cd38dcb1b..fc98fd555 100644 --- a/components/configfile/Makefile.am +++ b/components/configfile/Makefile.am @@ -9,6 +9,7 @@ configfile_la_SOURCES = \ i2-configfile.h configfile_la_CXXFLAGS = \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/icinga \ -I${top_srcdir}/jsonrpc \ @@ -20,6 +21,7 @@ configfile_la_LDFLAGS = \ -version-info 0:0:0 configfile_la_LIBADD = \ + $(BOOST_LDFLAGS) \ $(top_builddir)/base/libbase.la \ $(top_builddir)/icinga/libicinga.la \ $(top_builddir)/cJSON/libcJSON.la diff --git a/components/configrpc/Makefile.am b/components/configrpc/Makefile.am index aa92bba17..dabb9e384 100644 --- a/components/configrpc/Makefile.am +++ b/components/configrpc/Makefile.am @@ -9,6 +9,7 @@ configrpc_la_SOURCES = \ i2-configrpc.h configrpc_la_CXXFLAGS = \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ -I${top_srcdir}/icinga @@ -19,6 +20,7 @@ configrpc_la_LDFLAGS = \ -version-info 0:0:0 configrpc_la_LIBADD = \ + $(BOOST_LDFLAGS) \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/icinga/libicinga.la diff --git a/components/demo/Makefile.am b/components/demo/Makefile.am index 0406f4d3f..b47f5fc2b 100644 --- a/components/demo/Makefile.am +++ b/components/demo/Makefile.am @@ -9,6 +9,7 @@ demo_la_SOURCES = \ i2-demo.h demo_la_CXXFLAGS = \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ -I${top_srcdir}/cJSON \ @@ -20,6 +21,7 @@ demo_la_LDFLAGS = \ -version-info 0:0:0 demo_la_LIBADD = \ + $(BOOST_LDFLAGS) \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/icinga/libicinga.la diff --git a/components/discovery/Makefile.am b/components/discovery/Makefile.am index 7d536eddf..41f0912cd 100644 --- a/components/discovery/Makefile.am +++ b/components/discovery/Makefile.am @@ -10,13 +10,21 @@ discovery_la_SOURCES = \ discoverymessage.h \ i2-discovery.h -discovery_la_CXXFLAGS = -I${top_srcdir}/base \ +discovery_la_CXXFLAGS = \ + $(BOOST_CPPFLAGS) \ + -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ -I${top_srcdir}/cJSON \ -I${top_srcdir}/icinga -discovery_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined -pthread -discovery_la_LIBADD = ${top_builddir}/base/libbase.la \ +discovery_la_LDFLAGS = \ + -module \ + -version-info 0:0:0 \ + -no-undefined + +discovery_la_LIBADD = \ + $(BOOST_LDFLAGS) \ + ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/cJSON/libcJSON.la \ ${top_builddir}/icinga/libicinga.la diff --git a/config/ax_boost_base.m4 b/config/ax_boost_base.m4 index 54a2a1bee..f72bc2c3d 100644 --- a/config/ax_boost_base.m4 +++ b/config/ax_boost_base.m4 @@ -17,7 +17,7 @@ # # This macro calls: # -# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) +# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) AC_SUBST(BOOST_PATH) # # And sets: # @@ -100,6 +100,7 @@ if test "x$want_boost" = "xyes"; then dnl or if you install boost with RPM if test "$ac_boost_path" != ""; then BOOST_CPPFLAGS="-I$ac_boost_path/include" + BOOST_PATH="$ac_boost_path" for ac_boost_path_tmp in $libsubdirs; do if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" @@ -107,13 +108,14 @@ if test "x$want_boost" = "xyes"; then fi done elif test "$cross_compiling" != yes; then - for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + for ac_boost_path_tmp in /usr /usr/local /opt /opt/local "`pwd`/compat" ; do if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then for libsubdir in $libsubdirs ; do if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" + BOOST_PATH="$ac_boost_path_tmp" break; fi done @@ -246,6 +248,7 @@ if test "x$want_boost" = "xyes"; then else AC_SUBST(BOOST_CPPFLAGS) AC_SUBST(BOOST_LDFLAGS) + AC_SUBST(BOOST_PATH) AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) # execute ACTION-IF-FOUND (if present): ifelse([$2], , :, [$2]) diff --git a/configure.ac b/configure.ac index 3169ddeb2..e51b07232 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [])], [], [AC_M AC_OUTPUT([ Makefile +compat/Makefile base/Makefile cJSON/Makefile components/Makefile diff --git a/icinga-app/Makefile.am b/icinga-app/Makefile.am index 626250697..6cc726a25 100644 --- a/icinga-app/Makefile.am +++ b/icinga-app/Makefile.am @@ -9,6 +9,7 @@ icinga_SOURCES = \ icinga_CXXFLAGS = \ -DI2_ICINGALAUNCHER_BUILD \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ -I${top_srcdir}/cJSON \ @@ -16,6 +17,7 @@ icinga_CXXFLAGS = \ -I${top_srcdir} icinga_LDADD = \ + $(BOOST_LDFLAGS) \ ${top_builddir}/base/libbase.la \ ${top_builddir}/icinga/libicinga.la \ -dlopen ${top_builddir}/components/configfile/configfile.la \ diff --git a/icinga/Makefile.am b/icinga/Makefile.am index 85f99d2ec..e127ac305 100644 --- a/icinga/Makefile.am +++ b/icinga/Makefile.am @@ -23,6 +23,7 @@ libicinga_la_CFLAGS = -DI2_ICINGA_BUILD libicinga_la_CXXFLAGS = \ -DI2_ICINGA_BUILD \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ -I${top_srcdir}/cJSON \ @@ -33,5 +34,6 @@ libicinga_la_LDFLAGS = \ -version-info 0:0:0 libicinga_la_LIBADD = \ + $(BOOST_LDFLAGS) \ ${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/base/libbase.la diff --git a/jsonrpc/Makefile.am b/jsonrpc/Makefile.am index ffa2fe50b..b4c38a408 100644 --- a/jsonrpc/Makefile.am +++ b/jsonrpc/Makefile.am @@ -21,6 +21,7 @@ libjsonrpc_la_SOURCES = \ libjsonrpc_la_CXXFLAGS = \ -DI2_JSONRPC_BUILD \ + $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/cJSON @@ -29,5 +30,6 @@ libjsonrpc_la_LDFLAGS = \ -version-info 0:0:0 libjsonrpc_la_LIBADD = \ + $(BOOST_LDFLAGS) \ ${top_builddir}/base/libbase.la \ ${top_builddir}/cJSON/libcJSON.la