From 132a62f4eb471a2aef5cae279b52b0eb07cec6ee Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 29 May 2012 16:24:55 +0200 Subject: [PATCH] Fixed Solaris compatibility. --- base/Makefile.am | 5 +- base/delegate.h | 8 +- base/socket.cpp | 4 +- base/socket.h | 6 +- compat/Makefile.am | 3 - components/configfile/Makefile.am | 2 +- components/configrpc/Makefile.am | 2 +- components/demo/Makefile.am | 2 +- components/discovery/Makefile.am | 2 +- config/ax_check_compile_flag.m4 | 72 ----------------- config/ax_check_openssl.m4 | 124 ++++++++++++++++++++++++++++++ configure.ac | 18 +---- icinga-app/Makefile.am | 4 +- icinga-app/icinga.cpp | 2 + icinga/Makefile.am | 2 +- jsonrpc/Makefile.am | 2 +- 16 files changed, 153 insertions(+), 105 deletions(-) delete mode 100644 config/ax_check_compile_flag.m4 create mode 100644 config/ax_check_openssl.m4 diff --git a/base/Makefile.am b/base/Makefile.am index f2d1317b4..e6cefbe3f 100644 --- a/base/Makefile.am +++ b/base/Makefile.am @@ -52,14 +52,17 @@ libbase_la_CPPFLAGS = \ -DI2_BASE_BUILD \ $(LTDLINCL) \ $(BOOST_CPPFLAGS) \ + $(OPENSSL_INCLUDES) \ -I${top_srcdir}/third-party/mmatch libbase_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ + $(OPENSSL_LDFLAGS) \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ libbase_la_LIBADD = \ $(LIBLTDL) \ - $(BOOST_LDFLAGS) \ + $(OPENSSL_LIBS) \ ${top_builddir}/third-party/mmatch/libmmatch.la diff --git a/base/delegate.h b/base/delegate.h index f1aa22e10..be7356036 100644 --- a/base/delegate.h +++ b/base/delegate.h @@ -37,7 +37,13 @@ int delegate_fwd(int (TObject::*function)(TArgs), weak_ptr wref, TArgs template function bind_weak(int (TObject::*function)(TArgs), const weak_ptr& wref) { - return bind(&delegate_fwd, function, wref, placeholders::_1); + return bind(&delegate_fwd, function, wref, +#ifdef HAVE_BOOST + _1 +#else /* HAVE_BOOST */ + placeholders::_1 +#endif /* HAVE_BOOST */ + ); } template diff --git a/base/socket.cpp b/base/socket.cpp index dfe44994b..dba50bf52 100644 --- a/base/socket.cpp +++ b/base/socket.cpp @@ -169,7 +169,7 @@ int Socket::GetLastSocketError(void) * * @param ex An exception. */ -void Socket::HandleSocketError(const exception& ex) +void Socket::HandleSocketError(const std::exception& ex) { if (OnError.HasObservers()) { SocketErrorEventArgs sea(ex); @@ -290,4 +290,4 @@ SocketException::SocketException(const string& message, int errorCode) string msg = message + ": " + details; SetMessage(msg.c_str()); -} \ No newline at end of file +} diff --git a/base/socket.h b/base/socket.h index 75c70d1c1..8bba41e58 100644 --- a/base/socket.h +++ b/base/socket.h @@ -29,9 +29,9 @@ namespace icinga { */ struct I2_BASE_API SocketErrorEventArgs : public EventArgs { - const exception& Exception; + const std::exception& Exception; - SocketErrorEventArgs(const exception& ex) + SocketErrorEventArgs(const std::exception& ex) : Exception(ex) { } }; @@ -78,7 +78,7 @@ protected: int GetError(void) const; static int GetLastSocketError(void); - void HandleSocketError(const exception& ex); + void HandleSocketError(const std::exception& ex); virtual void CloseInternal(bool from_dtor); diff --git a/compat/Makefile.am b/compat/Makefile.am index 267c1c6c8..38a07f7a4 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -5,6 +5,3 @@ include: bcp --boost=$(BOOST_PATH)/include tr1 smart_ptr bind function make_shared boost && \ rm -Rf include && mkdir include && \ mv boost/boost include/ - -clean: - rm -Rf include diff --git a/components/configfile/Makefile.am b/components/configfile/Makefile.am index 489c1eeea..931ae6790 100644 --- a/components/configfile/Makefile.am +++ b/components/configfile/Makefile.am @@ -16,13 +16,13 @@ configfile_la_CPPFLAGS = \ -I${top_srcdir}/third-party/cJSON configfile_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ -module \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ configfile_la_LIBADD = \ - $(BOOST_LDFLAGS) \ $(top_builddir)/base/libbase.la \ $(top_builddir)/icinga/libicinga.la \ $(top_builddir)/third-party/cJSON/libcJSON.la diff --git a/components/configrpc/Makefile.am b/components/configrpc/Makefile.am index ce65fe0c1..054c8ebc2 100644 --- a/components/configrpc/Makefile.am +++ b/components/configrpc/Makefile.am @@ -15,13 +15,13 @@ configrpc_la_CPPFLAGS = \ -I${top_srcdir}/icinga configrpc_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ -module \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ 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 f02d03f7a..d9d4b0794 100644 --- a/components/demo/Makefile.am +++ b/components/demo/Makefile.am @@ -15,13 +15,13 @@ demo_la_CPPFLAGS = \ -I${top_srcdir}/icinga demo_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ -module \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ 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 3062aeb7b..3f3b6a300 100644 --- a/components/discovery/Makefile.am +++ b/components/discovery/Makefile.am @@ -17,13 +17,13 @@ discovery_la_CPPFLAGS = \ -I${top_srcdir}/icinga discovery_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ -module \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ discovery_la_LIBADD = \ - $(BOOST_LDFLAGS) \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ ${top_builddir}/icinga/libicinga.la diff --git a/config/ax_check_compile_flag.m4 b/config/ax_check_compile_flag.m4 deleted file mode 100644 index c3a8d695a..000000000 --- a/config/ax_check_compile_flag.m4 +++ /dev/null @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/config/ax_check_openssl.m4 b/config/ax_check_openssl.m4 new file mode 100644 index 000000000..a87c5a6b6 --- /dev/null +++ b/config/ax_check_openssl.m4 @@ -0,0 +1,124 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# Look for OpenSSL in a number of default spots, or in a user-selected +# spot (via --with-openssl). Sets +# +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required +# +# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately +# +# This macro sets OPENSSL_INCLUDES such that source files should use the +# openssl/ directory in include directives: +# +# #include +# +# LICENSE +# +# Copyright (c) 2009,2010 Zmanda Inc. +# Copyright (c) 2009,2010 Dustin J. Mitchell +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) +AC_DEFUN([AX_CHECK_OPENSSL], [ + found=false + AC_ARG_WITH([openssl], + [AS_HELP_STRING([--with-openssl=DIR], + [root of the OpenSSL directory])], + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([Invalid --with-openssl value]) + ;; + *) ssldirs="$withval" + ;; + esac + ], [ + # if pkg-config is installed and openssl has installed a .pc file, + # then use that information and don't search ssldirs + AC_PATH_PROG([PKG_CONFIG], [pkg-config]) + if test x"$PKG_CONFIG" != x""; then + OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` + if test $? = 0; then + OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` + OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` + found=true + fi + fi + + # no such luck; use some default ssldirs + if ! $found; then + ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" + fi + ] + ) + + + # note that we #include , so the OpenSSL headers have to be in + # an 'openssl' subdirectory + + if ! $found; then + OPENSSL_INCLUDES= + for ssldir in $ssldirs; do + AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) + if test -f "$ssldir/include/openssl/ssl.h"; then + OPENSSL_INCLUDES="-I$ssldir/include" + OPENSSL_LDFLAGS="-L$ssldir/lib" + OPENSSL_LIBS="-lssl -lcrypto" + found=true + AC_MSG_RESULT([yes]) + break + else + AC_MSG_RESULT([no]) + fi + done + + # if the file wasn't found, well, go ahead and try the link anyway -- maybe + # it will just work! + fi + + # try the preprocessor and linker with our new flags, + # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS + + AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) + echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ + "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" + LIBS="$OPENSSL_LIBS $LIBS" + CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], [SSL_new(NULL)])], + [ + AC_MSG_RESULT([yes]) + $1 + ], [ + AC_MSG_RESULT([no]) + $2 + ]) + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + + AC_SUBST([OPENSSL_INCLUDES]) + AC_SUBST([OPENSSL_LIBS]) + AC_SUBST([OPENSSL_LDFLAGS]) +]) diff --git a/configure.ac b/configure.ac index 3b748a027..2ab539c7a 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ AC_LANG_CPLUSPLUS AC_PROG_CC AC_LANG_C -LT_INIT([dlopen]) +LT_INIT([dlopen disable-static win32-dll]) LT_CONFIG_LTDL_DIR([third-party/ltdl]) LTDL_INIT @@ -54,7 +54,7 @@ AX_CXX_GCC_ABI_DEMANGLE AX_PTHREAD AX_BOOST_BASE AX_BOOST_UNIT_TEST_FRAMEWORK - +AX_CHECK_OPENSSL([], [AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application])]) AC_CHECK_LIB(ssl, SSL_new) AC_CHECK_LIB(crypto, X509_NAME_oneline) AC_CHECK_LIB(eay32, X509_NAME_oneline) @@ -64,20 +64,6 @@ AC_CHECK_LIB(socket, getsockname) AC_CHECK_LIB(ws2_32, getsockname) AC_CHECK_LIB(shlwapi, PathRemoveFileSpecA) -AC_MSG_CHECKING([for OpenSSL]) -AC_LANG_PUSH(C) -AC_COMPILE_IFELSE( - AC_LANG_PROGRAM([[#include ]], []), - [ - AC_MSG_RESULT([yes]) - ], - [ - AC_MSG_RESULT([no]) - AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application]) - ] - ) -AC_LANG_POP(C) - AC_CHECK_LIB(sqlite3, sqlite3_open) AC_MSG_CHECKING([for SQLite3]) diff --git a/icinga-app/Makefile.am b/icinga-app/Makefile.am index 416929771..dc864d7c2 100644 --- a/icinga-app/Makefile.am +++ b/icinga-app/Makefile.am @@ -15,8 +15,10 @@ icinga_CPPFLAGS = \ -I${top_srcdir}/icinga \ -I${top_srcdir} +icinga_LDFLAGS = \ + $(BOOST_LDFLAGS) + 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-app/icinga.cpp b/icinga-app/icinga.cpp index 095a0e41f..96dd96794 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -34,7 +34,9 @@ using namespace icinga; */ int main(int argc, char **argv) { +#ifndef _WIN32 LTDL_SET_PRELOADED_SYMBOLS(); +#endif /* _WIN32 */ IcingaApplication::Ptr instance = make_shared(); return instance->Run(argc, argv); diff --git a/icinga/Makefile.am b/icinga/Makefile.am index c7c6db9b0..318853ab4 100644 --- a/icinga/Makefile.am +++ b/icinga/Makefile.am @@ -28,11 +28,11 @@ libicinga_la_CPPFLAGS = \ -I${top_srcdir} libicinga_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ 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 e6d75a546..3d03875b2 100644 --- a/jsonrpc/Makefile.am +++ b/jsonrpc/Makefile.am @@ -26,11 +26,11 @@ libjsonrpc_la_CPPFLAGS = \ -I${top_srcdir}/third-party/cJSON libjsonrpc_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ -no-undefined \ @RELEASE_INFO@ \ @VERSION_INFO@ libjsonrpc_la_LIBADD = \ - $(BOOST_LDFLAGS) \ ${top_builddir}/base/libbase.la \ ${top_builddir}/third-party/cJSON/libcJSON.la -- 2.40.0