Build fixes for CentOS 5.3

This commit is contained in:
Gunnar Beutner 2012-04-02 10:29:08 +02:00
parent 55efd625a3
commit d386a2cc4c
11 changed files with 47 additions and 49 deletions

View File

@ -18,7 +18,7 @@ icinga2doc_DATA = \
NEWS
EXTRA_DIST = $(icinga2doc_DATA)
EXTRA_DIST = $(icinga2doc_DATA) git_version.sh
# Remove doc directory on uninstall

View File

@ -1,10 +1,10 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = \
libbase.a
noinst_LTLIBRARIES = \
libbase.la
libbase_a_SOURCES = \
libbase_la_SOURCES = \
application.cpp \
application.h \
component.cpp \
@ -42,3 +42,8 @@ libbase_a_SOURCES = \
unix.h \
win32.cpp \
win32.h
libbase_la_LIBADD=$(LIBLTDL)
AM_CFLAGS=$(LTDLINCL)
AM_CXXFLAGS=$(LTDLINCL)

View File

@ -1,5 +1,9 @@
#include "i2-base.h"
#ifndef _WIN32
# include <ltdl.h>
#endif
using namespace icinga;
Application::RefType Application::Instance;
@ -178,12 +182,27 @@ Component::RefType Application::LoadComponent(string path, ConfigObject::RefType
Log("Loading component '%s'", path.c_str());
#ifdef _WIN32
HMODULE hModule = LoadLibrary(path.c_str());
#else /* _WIN32 */
lt_dlhandle hModule = 0;
lt_dladvise advise;
if (hModule == INVALID_HANDLE_VALUE)
if (!lt_dladvise_init(&advise) && !lt_dladvise_global(&advise)) {
hModule = lt_dlopenadvise(path.c_str(), advise);
}
lt_dladvise_destroy(&advise);
#endif /* _WIN32 */
if (hModule == NULL)
throw exception(/*"Could not load module"*/);
pCreateComponent = (Component *(*)())GetProcAddress(hModule, "CreateComponent");
#ifdef _WIN32
pCreateComponent = (Component *(*)())GetProcAddress(hModule, );
#else /* _WIN32 */
pCreateComponent = (Component *(*)())lt_dlsym(hModule, "CreateComponent");
#endif /* _WIN32 */
if (pCreateComponent == NULL)
throw exception(/*"Module does not contain CreateComponent function"*/);

View File

@ -27,6 +27,7 @@
<ClCompile Include="thread.cpp" />
<ClCompile Include="timer.cpp" />
<ClCompile Include="unix.cpp" />
<ClCompile Include="win32.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="application.h" />

View File

@ -10,34 +10,9 @@ void Sleep(unsigned long milliseconds)
usleep(milliseconds * 1000);
}
inline void closesocket(SOCKET fd)
void closesocket(SOCKET fd)
{
close(fd);
}
inline HMODULE LoadLibrary(const char *filename)
{
lt_dlhandle handle = 0;
lt_dladvise advise;
if (!lt_dladvise_init(&advise) && !lt_dladvise_global(&advise)) {
handle = lt_dlopenadvise(filename, advise);
}
lt_dladvise_destroy(&advise);
return handle;
}
inline void FreeLibrary(HMODULE module)
{
if (module)
lt_dlclose(module);
}
inline void *GetProcAddress(HMODULE module, const char *function)
{
return lt_dlsym(module, function);
}
#endif /* I2_PLATFORM == PLATFORM_UNIX */

View File

@ -23,12 +23,4 @@ void closesocket(SOCKET fd);
#define I2_EXPORT
#define I2_IMPORT
typedef void *HMODULE;
#define INVALID_HANDLE_VALUE NULL
HMODULE LoadLibrary(const char *filename);
void FreeLibrary(HMODULE module);
void *GetProcAddress(HMODULE module, const char *function);
#endif /* UNIX_H */

View File

@ -10,4 +10,5 @@ libconfigfilecomponent_la_SOURCES = \
libconfigfilecomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc
libconfigfilecomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
libconfigfilecomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
libconfigfilecomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/jsonrpc/libjsonrpc.la

View File

@ -10,4 +10,5 @@ libconfigrpccomponent_la_SOURCES = \
libconfigrpccomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc -I${top_srcdir}/icinga
libconfigrpccomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
libconfigrpccomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
libconfigfilecomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/jsonrpc/libjsonrpc.la

View File

@ -20,7 +20,11 @@ LT_INIT
LT_CONFIG_LTDL_DIR([ltdl])
LTDL_INIT
if test "x$with_included_ltdl" != "xyes"; then
AC_CHECK_LIB([ltdl], [lt_dladvise_init],
[],
[AC_MSG_ERROR([installed libltdl is too old])])
fi

View File

@ -12,5 +12,5 @@ icinga_SOURCES = \
icinga_CXXFLAGS = -I${top_srcdir}/base \
-I${top_srcdir}/jsonrpc -I${top_srcdir}
icinga_LDFLAGS = $(top_builddir)/base/libbase.a \
$(top_builddir)/jsonrpc/libjsonrpc.a -lltdl
icinga_LDFLAGS = $(top_builddir)/base/libbase.la \
$(top_builddir)/jsonrpc/libjsonrpc.la

View File

@ -1,10 +1,10 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = \
libjsonrpc.a
noinst_LTLIBRARIES = \
libjsonrpc.la
libjsonrpc_a_SOURCES = \
libjsonrpc_la_SOURCES = \
cJSON.c \
cJSON.h \
connectionmanager.cpp \
@ -19,4 +19,4 @@ libjsonrpc_a_SOURCES = \
netstring.cpp \
netstring.h
libjsonrpc_a_CXXFLAGS = -I${top_srcdir}/base
libjsonrpc_la_CXXFLAGS = -I${top_srcdir}/base