Code

use relaytool to weak link libssl
authoracspike <acspike@users.sourceforge.net>
Sun, 7 Jan 2007 17:51:26 +0000 (17:51 +0000)
committeracspike <acspike@users.sourceforge.net>
Sun, 7 Jan 2007 17:51:26 +0000 (17:51 +0000)
Makefile.am
acinclude.m4 [new file with mode: 0644]
build.xml
build28.xml
configure.ac
m4/Makefile.am
m4/relaytool.m4 [new file with mode: 0644]
packaging/autopackage/default.apspec.in
src/dom/io/socket.cpp
src/pedro/pedroutil.cpp

index 650f1d3f820c368e2a4bb9cc538d3f78ee75a751..c06d15db32206316dc2b8f83a6f0a91948eed0d7 100644 (file)
@@ -24,6 +24,7 @@ man_MANS = inkscape.1 \
                inkview.1
 
 EXTRA_DIST = \
+       acinclude.m4 \
        fix-roff-punct  \
        intltool-extract.in     \
        intltool-merge.in       \
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..5cd65ae
--- /dev/null
@@ -0,0 +1,30 @@
+dnl  Usage: RELAYTOOL(LIBRARY_NAME, LIBS, CFLAGS, ACTION-IF-WEAK-LINK-IS-POSSIBLE)
+
+dnl  Example:
+dnl  RELAYTOOL("gtkspell", GTKSPELL_LIBS, GTKSPELL_CFLAGS, gtkspell_weak=yes)
+dnl  Will modify GTKSPELL_LIBS to include a call to relaytool if available
+dnl  or if not, will modify GTKSPELL_CFLAGS to include -D switches to define
+dnl  libgtkspell_is_present=1 and libgtkspell_symbol_is_present=1
+
+AC_DEFUN([RELAYTOOL], [
+    if test -z "$RELAYTOOL_PROG"; then
+        AC_PATH_PROG(RELAYTOOL_PROG, relaytool, no)
+    fi
+
+    AC_MSG_CHECKING(whether we can weak link $1)
+
+    _RELAYTOOL_PROCESSED_NAME=`echo "$1" | sed 's/-/_/g;s/\./_/g;'`
+    _RELAYTOOL_UPPER_NAME=`echo $_RELAYTOOL_PROCESSED_NAME | tr '[[:lower:]]' '[[:upper:]]'`
+
+    if test "$RELAYTOOL_PROG" = "no"; then
+        AC_MSG_RESULT(no)
+        $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='static const int lib${_RELAYTOOL_PROCESSED_NAME}_is_present = 1; static int __attribute__((unused)) lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *m) { return 1; }' $$3"
+    else
+        AC_MSG_RESULT(yes)
+        $2=`echo $$2|sed 's/\`/\\\\\`/g;'`
+        $2="-Wl,--gc-sections \`relaytool --relay $1 $$2\`"
+       $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='extern int lib${_RELAYTOOL_PROCESSED_NAME}_is_present; extern int lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *s);' $$3"
+        $4
+    fi
+])
+
index 77f89ae6ab7c87b17b82dc5b04501fcbff1310c0..43368b645eb6b4c7fbc71f23e57c539e0420ab86 100644 (file)
--- a/build.xml
+++ b/build.xml
             -DHAVE_CONFIG_H
             -DXP_WIN <!-- for JS -->
                        -D_INTL_REDIRECT_INLINE
+            -DRELAYTOOL_SSL='static const int libssl_is_present=1; static int __attribute__((unused)) libssl_symbol_is_present(char *s){ return 1; }' <!-- inkboard -->
             -DWITH_INKBOARD -DHAVE_SSL <!-- inkboard -->
         </defines>
         <includes>
index 5acbf67d722062e76b4f4d6bc3612b7c24116823..d4c0262cfe36839aa2fb45871e43aeb52739fb9b 100644 (file)
@@ -93,6 +93,7 @@
             -DHAVE_CONFIG_H\r
             -DXP_WIN <!-- for JS -->\r
                        -D_INTL_REDIRECT_INLINE\r
+            -DRELAYTOOL_SSL='static const int libssl_is_present=1; static int __attribute__((unused)) libssl_symbol_is_present(char *s){ return 1; }' <!-- inkboard -->\r
             -DWITH_INKBOARD -DHAVE_SSL <!-- inkboard -->\r
         </defines>\r
         <includes>\r
index 0eb5d66e1fcff8a51757dfa6b97748e8dfc971f1..639e4746a52c3916a6f42c0a699f166f9fe9d69e 100644 (file)
@@ -494,6 +494,8 @@ if test "x$with_inkboard" = "xyes"; then
                if test "x$with_inkboard_ssl" = "xyes"; then
                        dnl OpenSSL found; enable SSL support in Pedro
                        INKBOARD_CFLAGS="$INKBOARD_CFLAGS -DHAVE_SSL"
+                       RELAYTOOL([ssl], INKBOARD_LIBS, INKBOARD_CFLAGS, [inkboard_weak=yes])
+                       RELAYTOOL([crypto], INKBOARD_LIBS, INKBOARD_CFLAGS, [inkboard_weak=yes])
                        AC_DEFINE(WITH_INKBOARD_SSL,1,[Build in SSL support for Inkboard])
                fi
 else
index 26e2af705407c51f10af1ab3011161433359cb22..3343be6c528a91d69ffe2db009b74800d5e5c06f 100644 (file)
@@ -1,3 +1,3 @@
 EXTRA_DIST=codeset.m4 glibc21.m4 isc-posix.m4 progtest.m4 gettext.m4 \
-           iconv.m4 lcmessage.m4
+           iconv.m4 lcmessage.m4 relaytool.m4
 
diff --git a/m4/relaytool.m4 b/m4/relaytool.m4
new file mode 100644 (file)
index 0000000..5cd65ae
--- /dev/null
@@ -0,0 +1,30 @@
+dnl  Usage: RELAYTOOL(LIBRARY_NAME, LIBS, CFLAGS, ACTION-IF-WEAK-LINK-IS-POSSIBLE)
+
+dnl  Example:
+dnl  RELAYTOOL("gtkspell", GTKSPELL_LIBS, GTKSPELL_CFLAGS, gtkspell_weak=yes)
+dnl  Will modify GTKSPELL_LIBS to include a call to relaytool if available
+dnl  or if not, will modify GTKSPELL_CFLAGS to include -D switches to define
+dnl  libgtkspell_is_present=1 and libgtkspell_symbol_is_present=1
+
+AC_DEFUN([RELAYTOOL], [
+    if test -z "$RELAYTOOL_PROG"; then
+        AC_PATH_PROG(RELAYTOOL_PROG, relaytool, no)
+    fi
+
+    AC_MSG_CHECKING(whether we can weak link $1)
+
+    _RELAYTOOL_PROCESSED_NAME=`echo "$1" | sed 's/-/_/g;s/\./_/g;'`
+    _RELAYTOOL_UPPER_NAME=`echo $_RELAYTOOL_PROCESSED_NAME | tr '[[:lower:]]' '[[:upper:]]'`
+
+    if test "$RELAYTOOL_PROG" = "no"; then
+        AC_MSG_RESULT(no)
+        $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='static const int lib${_RELAYTOOL_PROCESSED_NAME}_is_present = 1; static int __attribute__((unused)) lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *m) { return 1; }' $$3"
+    else
+        AC_MSG_RESULT(yes)
+        $2=`echo $$2|sed 's/\`/\\\\\`/g;'`
+        $2="-Wl,--gc-sections \`relaytool --relay $1 $$2\`"
+       $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='extern int lib${_RELAYTOOL_PROCESSED_NAME}_is_present; extern int lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *s);' $$3"
+        $4
+    fi
+])
+
index 9c332646b68c02e05963bd60b7d5e08c97a9d384..aec1dafdd3d374484cf018b44935caf2b36cd0c6 100644 (file)
@@ -16,7 +16,7 @@ PackageDesktop: share/applications/inkscape.desktop
 if [ ! -x configure ]; then
     ./autogen.sh
 fi
-export APBUILD_STATIC="popt gc gccpp gtkmm-2.4 gdkmm-2.4 atkmm-1.6 pangomm-1.4 glibmm-2.4 sigc-2.0 Xrender lcms cairo Xfixes Xext ssl crypto"
+export APBUILD_STATIC="popt gc gccpp gtkmm-2.4 gdkmm-2.4 atkmm-1.6 pangomm-1.4 glibmm-2.4 sigc-2.0 Xrender lcms cairo Xfixes Xext"
 export APBUILD_PROJECTNAME=inkscape
 
 PATH=/usr/local/src/inkscape/extra/static/bin:$PATH
index 31eeb56bad3a0a0fd8ac9e2bb9af5ad79fc3d772..22b03b8b3d853869c745de75cd67fdc9466f46ce 100644 (file)
@@ -53,6 +53,8 @@
 #ifdef HAVE_SSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
+
+RELAYTOOL_SSL
 #endif
 
 
@@ -205,12 +207,15 @@ void TcpSocket::init()
         WSAStartup( wVersionRequested, &wsaData );
 #endif
 #ifdef HAVE_SSL
-        sslStream  = NULL;
-        sslContext = NULL;
+       if (libssl_is_present)
+       {
+            sslStream  = NULL;
+            sslContext = NULL;
            CRYPTO_set_locking_callback(cryptoLockCallback);
-        CRYPTO_set_id_callback(cryptoIdCallback);
-        SSL_library_init();
-        SSL_load_error_strings();
+            CRYPTO_set_id_callback(cryptoIdCallback);
+            SSL_library_init();
+            SSL_load_error_strings();
+       }
 #endif
         tcp_socket_inited = true;
         }
@@ -285,6 +290,8 @@ static void infoCallback(const SSL *ssl, int where, int ret)
 bool TcpSocket::startTls()
 {
 #ifdef HAVE_SSL
+    if (libssl_is_present)
+    {
     sslStream  = NULL;
     sslContext = NULL;
 
@@ -335,6 +342,7 @@ bool TcpSocket::startTls()
         }
 
     sslEnabled = true;
+    }
 #endif /*HAVE_SSL*/
     return true;
 }
@@ -397,6 +405,8 @@ bool TcpSocket::disconnect()
     bool ret  = true;
     connected = false;
 #ifdef HAVE_SSL
+    if (libssl_is_present)
+    {
     if (sslEnabled)
         {
         if (sslStream)
@@ -419,6 +429,7 @@ bool TcpSocket::disconnect()
         }
     sslStream  = NULL;
     sslContext = NULL;
+    }
 #endif /*HAVE_SSL*/
 
 #ifdef __WIN32__
@@ -460,7 +471,10 @@ long TcpSocket::available()
     if (count<=0 && sslEnabled)
         {
 #ifdef HAVE_SSL
-        return SSL_pending(sslStream);
+       if (libssl_is_present)
+       {
+            return SSL_pending(sslStream);
+       }
 #endif
         }
     return count;
@@ -480,6 +494,8 @@ bool TcpSocket::write(int ch)
     if (sslEnabled)
         {
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         int r = SSL_write(sslStream, &c, 1);
         if (r<=0)
             {
@@ -490,6 +506,7 @@ bool TcpSocket::write(int ch)
                     return -1;
                 }
             }
+       }
 #endif
         }
     else
@@ -518,6 +535,8 @@ bool TcpSocket::write(const DOMString &strArg)
     if (sslEnabled)
         {
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         int r = SSL_write(sslStream, (unsigned char *)str.c_str(), len);
         if (r<=0)
             {
@@ -528,6 +547,7 @@ bool TcpSocket::write(const DOMString &strArg)
                     return -1;
                 }
             }
+       }
 #endif
         }
     else
@@ -572,6 +592,8 @@ int TcpSocket::read()
     if (sslEnabled)
         {
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         if (!sslStream)
             return -1;
         int r = SSL_read(sslStream, &ch, 1);
@@ -591,6 +613,7 @@ int TcpSocket::read()
                      ERR_error_string(ERR_get_error(), NULL));
                 return -1;
             }
+       }
 #endif
         }
     else
index e08bed0a6062a8ea31db59cdac65005c16d7e5f4..13577bf8f716dd1bf99c57492fe7886a08ef5442 100644 (file)
@@ -48,6 +48,9 @@
 
 #endif /* UNIX */
 
+#ifdef HAVE_SSL
+RELAYTOOL_SSL
+#endif
 
 
 namespace Pedro
@@ -995,12 +998,15 @@ void TcpSocket::init()
         WSAStartup( wVersionRequested, &wsaData );
 #endif
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         sslStream  = NULL;
         sslContext = NULL;
            CRYPTO_set_locking_callback(cryptoLockCallback);
         CRYPTO_set_id_callback(cryptoIdCallback);
         SSL_library_init();
         SSL_load_error_strings();
+       }
 #endif
         tcp_socket_inited = true;
         }
@@ -1027,7 +1033,12 @@ bool TcpSocket::isConnected()
 bool TcpSocket::getHaveSSL()
 {
 #ifdef HAVE_SSL
-    return true;
+    if (libssl_is_present)
+    {
+        return true;
+    } else {
+       return false;
+    }
 #else
     return false;
 #endif
@@ -1094,7 +1105,13 @@ bool TcpSocket::startTls()
            "SSL starttls() error:  client not compiled with SSL enabled\n");
     return false;
 #else /*HAVE_SSL*/
-
+    if (!libssl_is_present)
+    {
+    fprintf(stderr,
+           "SSL starttls() error:  the correct version of libssl was not found \n");
+    return false;
+    } else {
+           
     sslStream  = NULL;
     sslContext = NULL;
 
@@ -1157,6 +1174,7 @@ bool TcpSocket::startTls()
 
     sslEnabled = true;
     return true;
+    }
 #endif /* HAVE_SSL */
 }
 
@@ -1218,6 +1236,8 @@ bool TcpSocket::disconnect()
     bool ret  = true;
     connected = false;
 #ifdef HAVE_SSL
+    if (libssl_is_present)
+    {
     if (sslEnabled)
         {
         if (sslStream)
@@ -1240,6 +1260,7 @@ bool TcpSocket::disconnect()
         }
     sslStream  = NULL;
     sslContext = NULL;
+    }
 #endif /*HAVE_SSL*/
 
 #ifdef __WIN32__
@@ -1281,7 +1302,10 @@ long TcpSocket::available()
     if (count<=0 && sslEnabled)
         {
 #ifdef HAVE_SSL
-        return SSL_pending(sslStream);
+       if (libssl_is_present)
+       {
+            return SSL_pending(sslStream);
+       }
 #endif
         }
     return count;
@@ -1301,6 +1325,8 @@ bool TcpSocket::write(int ch)
     if (sslEnabled)
         {
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         int r = SSL_write(sslStream, &c, 1);
         if (r<=0)
             {
@@ -1311,6 +1337,7 @@ bool TcpSocket::write(int ch)
                     return -1;
                 }
             }
+       }
 #endif
         }
     else
@@ -1337,6 +1364,8 @@ bool TcpSocket::write(char *str)
     if (sslEnabled)
         {
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         int r = SSL_write(sslStream, (unsigned char *)str, len);
         if (r<=0)
             {
@@ -1347,6 +1376,7 @@ bool TcpSocket::write(char *str)
                     return -1;
                 }
             }
+       }
 #endif
         }
     else
@@ -1396,6 +1426,8 @@ int TcpSocket::read()
     if (sslEnabled)
         {
 #ifdef HAVE_SSL
+       if (libssl_is_present)
+       {
         if (!sslStream)
             return -1;
         int r = SSL_read(sslStream, &ch, 1);
@@ -1415,6 +1447,7 @@ int TcpSocket::read()
                      ERR_error_string(ERR_get_error(), NULL));
                 return -1;
             }
+       }
 #endif
         }
     else