Proper integration for Boost.

This commit is contained in:
Gunnar Beutner 2012-05-25 22:04:03 +02:00
parent 041caeeb92
commit 94eba566af
15 changed files with 55 additions and 12 deletions

View File

@ -3,7 +3,9 @@
include aminclude.am include aminclude.am
SUBDIRS = ltdl \ SUBDIRS = \
compat \
ltdl \
mmatch \ mmatch \
cJSON \ cJSON \
base \ base \

View File

@ -53,6 +53,7 @@ libbase_la_SOURCES = \
libbase_la_CXXFLAGS = \ libbase_la_CXXFLAGS = \
-DI2_BASE_BUILD \ -DI2_BASE_BUILD \
$(LTDLINCL) \ $(LTDLINCL) \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/mmatch -I${top_srcdir}/mmatch
libbase_la_LDFLAGS = \ libbase_la_LDFLAGS = \
@ -61,4 +62,5 @@ libbase_la_LDFLAGS = \
libbase_la_LIBADD = \ libbase_la_LIBADD = \
$(LIBLTDL) \ $(LIBLTDL) \
$(BOOST_LDFLAGS) \
${top_builddir}/mmatch/libmmatch.la ${top_builddir}/mmatch/libmmatch.la

View File

@ -26,6 +26,7 @@
using namespace icinga; using namespace icinga;
Application::Ptr I2_EXPORT Application::m_Instance; Application::Ptr I2_EXPORT Application::m_Instance;
bool I2_EXPORT Application::m_ShuttingDown = false;
/** /**
* Constructor for the Application class. * Constructor for the Application class.
@ -50,7 +51,6 @@ Application::Application(void)
m_Debugging = true; m_Debugging = true;
#endif /* _WIN32 */ #endif /* _WIN32 */
m_ShuttingDown = false;
m_ConfigHive = make_shared<ConfigHive>(); m_ConfigHive = make_shared<ConfigHive>();
} }
@ -59,6 +59,8 @@ Application::Application(void)
*/ */
Application::~Application(void) Application::~Application(void)
{ {
m_ShuttingDown = true;
/* stop all components */ /* stop all components */
for (map<string, Component::Ptr>::iterator i = m_Components.begin(); for (map<string, Component::Ptr>::iterator i = m_Components.begin();
i != m_Components.end(); i++) { i != m_Components.end(); i++) {
@ -81,6 +83,9 @@ Application::~Application(void)
*/ */
Application::Ptr Application::GetInstance(void) Application::Ptr Application::GetInstance(void)
{ {
if (m_ShuttingDown)
return Application::Ptr();
else
return m_Instance; return m_Instance;
} }

View File

@ -45,7 +45,7 @@ public:
virtual int Main(const vector<string>& args) = 0; virtual int Main(const vector<string>& args) = 0;
void Shutdown(void); static void Shutdown(void);
static void Log(string message); static void Log(string message);
@ -65,9 +65,9 @@ protected:
string GetExeDirectory(void) const; string GetExeDirectory(void) const;
private: 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. */ shutting down. */
ConfigHive::Ptr m_ConfigHive; /**< The application's configuration. */ ConfigHive::Ptr m_ConfigHive; /**< The application's configuration. */
map< string, shared_ptr<Component> > m_Components; /**< Components that map< string, shared_ptr<Component> > m_Components; /**< Components that

View File

@ -34,3 +34,4 @@ Object::Object(void)
Object::~Object(void) Object::~Object(void)
{ {
} }

9
compat/Makefile.am Normal file
View File

@ -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

View File

@ -9,6 +9,7 @@ configfile_la_SOURCES = \
i2-configfile.h i2-configfile.h
configfile_la_CXXFLAGS = \ configfile_la_CXXFLAGS = \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \ -I${top_srcdir}/base \
-I${top_srcdir}/icinga \ -I${top_srcdir}/icinga \
-I${top_srcdir}/jsonrpc \ -I${top_srcdir}/jsonrpc \
@ -20,6 +21,7 @@ configfile_la_LDFLAGS = \
-version-info 0:0:0 -version-info 0:0:0
configfile_la_LIBADD = \ configfile_la_LIBADD = \
$(BOOST_LDFLAGS) \
$(top_builddir)/base/libbase.la \ $(top_builddir)/base/libbase.la \
$(top_builddir)/icinga/libicinga.la \ $(top_builddir)/icinga/libicinga.la \
$(top_builddir)/cJSON/libcJSON.la $(top_builddir)/cJSON/libcJSON.la

View File

@ -9,6 +9,7 @@ configrpc_la_SOURCES = \
i2-configrpc.h i2-configrpc.h
configrpc_la_CXXFLAGS = \ configrpc_la_CXXFLAGS = \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \ -I${top_srcdir}/base \
-I${top_srcdir}/jsonrpc \ -I${top_srcdir}/jsonrpc \
-I${top_srcdir}/icinga -I${top_srcdir}/icinga
@ -19,6 +20,7 @@ configrpc_la_LDFLAGS = \
-version-info 0:0:0 -version-info 0:0:0
configrpc_la_LIBADD = \ configrpc_la_LIBADD = \
$(BOOST_LDFLAGS) \
${top_builddir}/base/libbase.la \ ${top_builddir}/base/libbase.la \
${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \
${top_builddir}/icinga/libicinga.la ${top_builddir}/icinga/libicinga.la

View File

@ -9,6 +9,7 @@ demo_la_SOURCES = \
i2-demo.h i2-demo.h
demo_la_CXXFLAGS = \ demo_la_CXXFLAGS = \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \ -I${top_srcdir}/base \
-I${top_srcdir}/jsonrpc \ -I${top_srcdir}/jsonrpc \
-I${top_srcdir}/cJSON \ -I${top_srcdir}/cJSON \
@ -20,6 +21,7 @@ demo_la_LDFLAGS = \
-version-info 0:0:0 -version-info 0:0:0
demo_la_LIBADD = \ demo_la_LIBADD = \
$(BOOST_LDFLAGS) \
${top_builddir}/base/libbase.la \ ${top_builddir}/base/libbase.la \
${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \
${top_builddir}/icinga/libicinga.la ${top_builddir}/icinga/libicinga.la

View File

@ -10,13 +10,21 @@ discovery_la_SOURCES = \
discoverymessage.h \ discoverymessage.h \
i2-discovery.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}/jsonrpc \
-I${top_srcdir}/cJSON \ -I${top_srcdir}/cJSON \
-I${top_srcdir}/icinga -I${top_srcdir}/icinga
discovery_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined -pthread discovery_la_LDFLAGS = \
discovery_la_LIBADD = ${top_builddir}/base/libbase.la \ -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}/jsonrpc/libjsonrpc.la \
${top_builddir}/cJSON/libcJSON.la \ ${top_builddir}/cJSON/libcJSON.la \
${top_builddir}/icinga/libicinga.la ${top_builddir}/icinga/libicinga.la

View File

@ -17,7 +17,7 @@
# #
# This macro calls: # 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: # And sets:
# #
@ -100,6 +100,7 @@ if test "x$want_boost" = "xyes"; then
dnl or if you install boost with RPM dnl or if you install boost with RPM
if test "$ac_boost_path" != ""; then if test "$ac_boost_path" != ""; then
BOOST_CPPFLAGS="-I$ac_boost_path/include" BOOST_CPPFLAGS="-I$ac_boost_path/include"
BOOST_PATH="$ac_boost_path"
for ac_boost_path_tmp in $libsubdirs; do for ac_boost_path_tmp in $libsubdirs; do
if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
@ -107,13 +108,14 @@ if test "x$want_boost" = "xyes"; then
fi fi
done done
elif test "$cross_compiling" != yes; then 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 if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
for libsubdir in $libsubdirs ; do for libsubdir in $libsubdirs ; do
if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done done
BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
BOOST_PATH="$ac_boost_path_tmp"
break; break;
fi fi
done done
@ -246,6 +248,7 @@ if test "x$want_boost" = "xyes"; then
else else
AC_SUBST(BOOST_CPPFLAGS) AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS) AC_SUBST(BOOST_LDFLAGS)
AC_SUBST(BOOST_PATH)
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
# execute ACTION-IF-FOUND (if present): # execute ACTION-IF-FOUND (if present):
ifelse([$2], , :, [$2]) ifelse([$2], , :, [$2])

View File

@ -54,6 +54,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]], [])], [], [AC_M
AC_OUTPUT([ AC_OUTPUT([
Makefile Makefile
compat/Makefile
base/Makefile base/Makefile
cJSON/Makefile cJSON/Makefile
components/Makefile components/Makefile

View File

@ -9,6 +9,7 @@ icinga_SOURCES = \
icinga_CXXFLAGS = \ icinga_CXXFLAGS = \
-DI2_ICINGALAUNCHER_BUILD \ -DI2_ICINGALAUNCHER_BUILD \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \ -I${top_srcdir}/base \
-I${top_srcdir}/jsonrpc \ -I${top_srcdir}/jsonrpc \
-I${top_srcdir}/cJSON \ -I${top_srcdir}/cJSON \
@ -16,6 +17,7 @@ icinga_CXXFLAGS = \
-I${top_srcdir} -I${top_srcdir}
icinga_LDADD = \ icinga_LDADD = \
$(BOOST_LDFLAGS) \
${top_builddir}/base/libbase.la \ ${top_builddir}/base/libbase.la \
${top_builddir}/icinga/libicinga.la \ ${top_builddir}/icinga/libicinga.la \
-dlopen ${top_builddir}/components/configfile/configfile.la \ -dlopen ${top_builddir}/components/configfile/configfile.la \

View File

@ -23,6 +23,7 @@ libicinga_la_CFLAGS = -DI2_ICINGA_BUILD
libicinga_la_CXXFLAGS = \ libicinga_la_CXXFLAGS = \
-DI2_ICINGA_BUILD \ -DI2_ICINGA_BUILD \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \ -I${top_srcdir}/base \
-I${top_srcdir}/jsonrpc \ -I${top_srcdir}/jsonrpc \
-I${top_srcdir}/cJSON \ -I${top_srcdir}/cJSON \
@ -33,5 +34,6 @@ libicinga_la_LDFLAGS = \
-version-info 0:0:0 -version-info 0:0:0
libicinga_la_LIBADD = \ libicinga_la_LIBADD = \
$(BOOST_LDFLAGS) \
${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \
${top_builddir}/base/libbase.la ${top_builddir}/base/libbase.la

View File

@ -21,6 +21,7 @@ libjsonrpc_la_SOURCES = \
libjsonrpc_la_CXXFLAGS = \ libjsonrpc_la_CXXFLAGS = \
-DI2_JSONRPC_BUILD \ -DI2_JSONRPC_BUILD \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \ -I${top_srcdir}/base \
-I${top_srcdir}/cJSON -I${top_srcdir}/cJSON
@ -29,5 +30,6 @@ libjsonrpc_la_LDFLAGS = \
-version-info 0:0:0 -version-info 0:0:0
libjsonrpc_la_LIBADD = \ libjsonrpc_la_LIBADD = \
$(BOOST_LDFLAGS) \
${top_builddir}/base/libbase.la \ ${top_builddir}/base/libbase.la \
${top_builddir}/cJSON/libcJSON.la ${top_builddir}/cJSON/libcJSON.la