]> granicus.if.org Git - icinga2/commitdiff
Fixed Solaris compatibility.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 29 May 2012 14:24:55 +0000 (16:24 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 29 May 2012 14:56:25 +0000 (16:56 +0200)
16 files changed:
base/Makefile.am
base/delegate.h
base/socket.cpp
base/socket.h
compat/Makefile.am
components/configfile/Makefile.am
components/configrpc/Makefile.am
components/demo/Makefile.am
components/discovery/Makefile.am
config/ax_check_compile_flag.m4 [deleted file]
config/ax_check_openssl.m4 [new file with mode: 0644]
configure.ac
icinga-app/Makefile.am
icinga-app/icinga.cpp
icinga/Makefile.am
jsonrpc/Makefile.am

index f2d1317b4132f3b590bba5356f1b2621114fa95e..e6cefbe3f6f3abab77ebeee79640328b10d6f4d0 100644 (file)
@@ -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
index f1aa22e10d6fc3e8e8480ca5171655bb45a47f4b..be73560369fc6fc6cdb6396dddacbb8d75329676 100644 (file)
@@ -37,7 +37,13 @@ int delegate_fwd(int (TObject::*function)(TArgs), weak_ptr<TObject> wref, TArgs
 template<class TObject, class TArgs>
 function<int (TArgs)> bind_weak(int (TObject::*function)(TArgs), const weak_ptr<TObject>& wref)
 {
-       return bind(&delegate_fwd<TObject, TArgs>, function, wref, placeholders::_1);
+       return bind(&delegate_fwd<TObject, TArgs>, function, wref,
+#ifdef HAVE_BOOST
+           _1
+#else /* HAVE_BOOST */
+           placeholders::_1
+#endif /* HAVE_BOOST */
+       );
 }
 
 template<class TObject, class TArgs>
index dfe44994b2bd0e01d3268d240407af47cbefed84..dba50bf5224086ded59f70c9a9029eff6fdc5945 100644 (file)
@@ -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
+}
index 75c70d1c1df2e1ef2633d7f469734d0de0fd2ae8..8bba41e58822f1a20d4896a38f4d4ad01a4112e5 100644 (file)
@@ -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);
 
index 267c1c6c819bb0feb5c3a14f08f261fd5919d307..38a07f7a4602830f488fc618f1b6d0ff688f493b 100644 (file)
@@ -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
index 489c1eeea2acef7654d076c41ce71e1a6d9f013b..931ae6790258e8ef2e0906da4cb098b459e9bdd3 100644 (file)
@@ -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
index ce65fe0c1cd846b20d6a4449489c032a19742604..054c8ebc2e5c2e40f03900ae486fe2baf6201a11 100644 (file)
@@ -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
index f02d03f7a241968817301c6d119420e4babf1d80..d9d4b079452ccd1246e53e0dfc437f4ce7cc8735 100644 (file)
@@ -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
index 3062aeb7b22deb09512a08c41c8b1ba9c619a838..3f3b6a300eb85d49e03604cb21a4cde86df59913 100644 (file)
@@ -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 (file)
index c3a8d69..0000000
+++ /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 <guidod@gmx.de>
-#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
-#
-#   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 <http://www.gnu.org/licenses/>.
-#
-#   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 (file)
index 0000000..a87c5a6
--- /dev/null
@@ -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 <openssl/hmac.h>
+#
+# LICENSE
+#
+#   Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
+#   Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com>
+#
+#   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 <openssl/foo.h>, 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 <openssl/ssl.h>], [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])
+])
index 3b748a02761374b5a18cb1f92617d9f2ea9ae5cb..2ab539c7a869fa0aa881e4cbfbb0558f24b4f87c 100644 (file)
@@ -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 <openssl/ssl.h>]], []),
-       [
-       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])
index 4169297716e1063ba652024a86d8522bd8a6eb19..dc864d7c2ffe44fa224d3a7571c05ca8181c7bcf 100644 (file)
@@ -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 \
index 095a0e41fd5e6d44463a77597e228727ac873c02..96dd96794d286cba96ff793162556126a32b9861 100644 (file)
@@ -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<IcingaApplication>();
        return instance->Run(argc, argv);
index c7c6db9b02a6c190e2e07f02c3b3288065b88d8a..318853ab492063d807832e1ecc82506a19a983a9 100644 (file)
@@ -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
index e6d75a546b600ffbb6ccf3faf4b96a15c21525c3..3d03875b239dff03131f170d69606ca22af3ed9f 100644 (file)
@@ -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