Added build support for Solaris.
authorFredrik Skogman <skogman@gmail.com>
Thu, 8 Sep 2016 22:49:44 +0000 (06:49 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 8 Sep 2016 22:52:42 +0000 (06:52 +0800)
README.build.md
doc/html/md_README.build.html
lib/lws-plat-unix.c
lib/private-libwebsockets.h

index 50b802d..136da5b 100644 (file)
@@ -100,19 +100,19 @@ compiled in, use
        $ cmake .. -DCMAKE_BUILD_TYPE=DEBUG
 ```
 
-       **NOTE6**
-       To build on Solaris the linker needs to be informed to use lib socket
-       and libnsl, and only builds in 64bit mode.
+**NOTE6**
+To build on Solaris the linker needs to be informed to use lib socket
+and libnsl, and only builds in 64bit mode.
 
-    ```bash
+```bash
        $ cmake .. -DCMAKE_C_FLAGS=-m64 -DCMAKE_EXE_LINKER_FLAGS="-lsocket -lnsl"
-    ```
+```
 
 4. Finally you can build using the generated Makefile:
 
-    ```bash
+```bash
        $ make
   ```
+ ```
 
 @section cmq Quirk of cmake
 
index f160b6d..8f67c33 100644 (file)
@@ -89,7 +89,11 @@ Building on Unix:</h1>
 <li>Generate the build files (default is Make files): <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cd /path/to/src</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;$ mkdir build</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;$ cd build</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;$ cmake ..</div></div><!-- fragment --></li>
 <li>Finally you can build using the generated Makefile: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ make &amp;&amp; sudo make install</div></div><!-- fragment --> <b>NOTE</b>: The <code>build/</code><code>directory can have any name and be located anywhere on your filesystem, and that the argument</code>..` given to cmake is simply the source directory of <b>libwebsockets</b> containing the <a href="CMakeLists.txt">CMakeLists.txt</a> project file. All examples in this file assumes you use ".."</li>
 </ol>
-<p><b>NOTE2</b>: A common option you may want to give is to set the install path, same as &ndash;prefix= with autotools. It defaults to /usr/local. You can do this by, eg </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .</div></div><!-- fragment --><p><b>NOTE3</b>: On machines that want libraries in lib64, you can also add the following to the cmake line </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;-DLIB_SUFFIX=64</div></div><!-- fragment --><p><b>NOTE4</b>: If you are building against a non-distro OpenSSL (eg, in order to get access to ALPN support only in newer OpenSSL versions) the nice way to express that in one cmake command is eg, </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/ssl \</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/usr/local/ssl \</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         -DLWS_WITH_HTTP2=1</div></div><!-- fragment --><p>When you run the test apps using non-distro SSL, you have to force them to use your libs, not the distro ones </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ LD_LIBRARY_PATH=/usr/local/ssl/lib libwebsockets-test-server --ssl</div></div><!-- fragment --><p>To get it to build on latest openssl (2016-04-10) it needed this approach </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cmake .. -DLWS_WITH_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=/usr/local/include/openssl -DLWS_OPENSSL_LIBRARIES=&quot;/usr/local/lib64/libssl.so;/usr/local/lib64/libcrypto.so&quot;</div></div><!-- fragment --><p><b>NOTE5</b>: To build with debug info and _DEBUG for lower priority debug messages compiled in, use </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG</div></div><!-- fragment --><h1><a class="anchor" id="cmq"></a>
+<p><b>NOTE2</b>: A common option you may want to give is to set the install path, same as &ndash;prefix= with autotools. It defaults to /usr/local. You can do this by, eg </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .</div></div><!-- fragment --><p><b>NOTE3</b>: On machines that want libraries in lib64, you can also add the following to the cmake line </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;-DLIB_SUFFIX=64</div></div><!-- fragment --><p><b>NOTE4</b>: If you are building against a non-distro OpenSSL (eg, in order to get access to ALPN support only in newer OpenSSL versions) the nice way to express that in one cmake command is eg, </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/ssl \</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/usr/local/ssl \</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         -DLWS_WITH_HTTP2=1</div></div><!-- fragment --><p>When you run the test apps using non-distro SSL, you have to force them to use your libs, not the distro ones </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ LD_LIBRARY_PATH=/usr/local/ssl/lib libwebsockets-test-server --ssl</div></div><!-- fragment --><p>To get it to build on latest openssl (2016-04-10) it needed this approach </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cmake .. -DLWS_WITH_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=/usr/local/include/openssl -DLWS_OPENSSL_LIBRARIES=&quot;/usr/local/lib64/libssl.so;/usr/local/lib64/libcrypto.so&quot;</div></div><!-- fragment --><p><b>NOTE5</b>: To build with debug info and _DEBUG for lower priority debug messages compiled in, use </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG</div></div><!-- fragment --><p><b>NOTE6</b> To build on Solaris the linker needs to be informed to use lib socket and libnsl, and only builds in 64bit mode.</p>
+<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DCMAKE_C_FLAGS=-m64 -DCMAKE_EXE_LINKER_FLAGS=&quot;-lsocket -lnsl&quot;</div></div><!-- fragment --><ol type="1">
+<li>Finally you can build using the generated Makefile:</li>
+</ol>
+<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ make</div></div><!-- fragment --><h1><a class="anchor" id="cmq"></a>
 Quirk of cmake</h1>
 <p>When changing cmake options, for some reason the only way to get it to see the changes sometimes is delete the contents of your build directory and do the cmake from scratch.</p>
 <h1><a class="anchor" id="cmw"></a>
index 248c2a6..c3e5894 100644 (file)
@@ -215,7 +215,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
 #if defined(__APPLE__) || \
     defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
     defined(__NetBSD__) || \
-        defined(__CYGWIN__) || defined(__OpenBSD__)
+        defined(__CYGWIN__) || defined(__OpenBSD__) || defined (__sun)
 
                /*
                 * didn't find a way to set these per-socket, need to
@@ -242,10 +242,13 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
 
        /* Disable Nagle */
        optval = 1;
-#if !defined(__APPLE__) && \
-    !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && \
-    !defined(__NetBSD__) && \
-    !defined(__OpenBSD__)
+#if defined (__sun)
+       if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
+               return 1;
+#elif !defined(__APPLE__) && \
+      !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) &&        \
+      !defined(__NetBSD__) && \
+      !defined(__OpenBSD__)
        if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
                return 1;
 #else
index 5e7f0f6..c9da8fc 100644 (file)
@@ -178,6 +178,8 @@ char *ets_strchr(const char *s, int c);
 #if defined (__ANDROID__)
 #include <syslog.h>
 #include <sys/resource.h>
+#elif defined (__sun)
+#include <syslog.h>
 #else
 #if !defined(LWS_WITH_ESP8266)
 #include <sys/syslog.h>
@@ -377,6 +379,12 @@ extern "C" {
        #endif
 #endif
 
+#if defined(__sun) && defined(__GNUC__)
+# define BYTE_ORDER __BYTE_ORDER__
+# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
+#endif
+
 #if !defined(BYTE_ORDER)
 # define BYTE_ORDER __BYTE_ORDER
 #endif
@@ -397,6 +405,14 @@ extern "C" {
 #define MSG_NOSIGNAL SO_NOSIGPIPE
 #endif
 
+/*
+ * Solaris 11.X only supports POSIX 2001, MSG_NOSIGNAL appears in
+ * POSIX 2008.
+ */
+#ifdef __sun
+#define MSG_NOSIGNAL 0
+#endif
+
 #ifdef _WIN32
 #ifndef FD_HASHTABLE_MODULUS
 #define FD_HASHTABLE_MODULUS 32