From: Fredrik Skogman Date: Thu, 8 Sep 2016 22:49:44 +0000 (+0800) Subject: Added build support for Solaris. X-Git-Tag: accepted/tizen/4.0/unified/20171012.191640~349 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=316960b87d40aa5809d50f30850583bf203ad97b;p=platform%2Fupstream%2Flibwebsockets.git Added build support for Solaris. --- diff --git a/README.build.md b/README.build.md index 50b802d..136da5b 100644 --- a/README.build.md +++ b/README.build.md @@ -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 diff --git a/doc/html/md_README.build.html b/doc/html/md_README.build.html index f160b6d..8f67c33 100644 --- a/doc/html/md_README.build.html +++ b/doc/html/md_README.build.html @@ -89,7 +89,11 @@ Building on Unix:
  • Generate the build files (default is Make files):
    1 $ cd /path/to/src
    2 $ mkdir build
    3 $ cd build
    4 $ cmake ..
  • Finally you can build using the generated Makefile:
    1 $ make && sudo make install
    NOTE: The build/directory can have any name and be located anywhere on your filesystem, and that the argument..` given to cmake is simply the source directory of libwebsockets containing the CMakeLists.txt project file. All examples in this file assumes you use ".."
  • -

    NOTE2: A common option you may want to give is to set the install path, same as –prefix= with autotools. It defaults to /usr/local. You can do this by, eg

    1 $ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .

    NOTE3: On machines that want libraries in lib64, you can also add the following to the cmake line

    1 -DLIB_SUFFIX=64

    NOTE4: 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,

    1 $ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/ssl \
    2  -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/usr/local/ssl \
    3  -DLWS_WITH_HTTP2=1

    When you run the test apps using non-distro SSL, you have to force them to use your libs, not the distro ones

    1 $ LD_LIBRARY_PATH=/usr/local/ssl/lib libwebsockets-test-server --ssl

    To get it to build on latest openssl (2016-04-10) it needed this approach

    1 cmake .. -DLWS_WITH_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=/usr/local/include/openssl -DLWS_OPENSSL_LIBRARIES="/usr/local/lib64/libssl.so;/usr/local/lib64/libcrypto.so"

    NOTE5: To build with debug info and _DEBUG for lower priority debug messages compiled in, use

    1 $ cmake .. -DCMAKE_BUILD_TYPE=DEBUG

    +

    NOTE2: A common option you may want to give is to set the install path, same as –prefix= with autotools. It defaults to /usr/local. You can do this by, eg

    1 $ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .

    NOTE3: On machines that want libraries in lib64, you can also add the following to the cmake line

    1 -DLIB_SUFFIX=64

    NOTE4: 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,

    1 $ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/ssl \
    2  -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/usr/local/ssl \
    3  -DLWS_WITH_HTTP2=1

    When you run the test apps using non-distro SSL, you have to force them to use your libs, not the distro ones

    1 $ LD_LIBRARY_PATH=/usr/local/ssl/lib libwebsockets-test-server --ssl

    To get it to build on latest openssl (2016-04-10) it needed this approach

    1 cmake .. -DLWS_WITH_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=/usr/local/include/openssl -DLWS_OPENSSL_LIBRARIES="/usr/local/lib64/libssl.so;/usr/local/lib64/libcrypto.so"

    NOTE5: To build with debug info and _DEBUG for lower priority debug messages compiled in, use

    1 $ 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.

    +
    1 $ cmake .. -DCMAKE_C_FLAGS=-m64 -DCMAKE_EXE_LINKER_FLAGS="-lsocket -lnsl"
      +
    1. Finally you can build using the generated Makefile:
    2. +
    +
    1 $ make

    Quirk of cmake

    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.

    diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c index 248c2a6..c3e5894 100644 --- a/lib/lws-plat-unix.c +++ b/lib/lws-plat-unix.c @@ -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 diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 5e7f0f6..c9da8fc 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -178,6 +178,8 @@ char *ets_strchr(const char *s, int c); #if defined (__ANDROID__) #include #include +#elif defined (__sun) +#include #else #if !defined(LWS_WITH_ESP8266) #include @@ -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