Fixed build on OSX. 04/3004/1
authorJoakim Söderberg <joakim.soderberg@gmail.com>
Wed, 6 Feb 2013 06:27:39 +0000 (15:27 +0900)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:30 +0000 (13:01 -0800)
- For some reason the "extern int pid_daemon" usage in libwebsockets.c would cause an "undefined symbols" linker error for the test-apps. This only happens with the CMake project, not the normal Makefiles. I have no clue why this is. Fixed it by getting the pid via a function instead.

- Added test-server-extpoll

- Renamed the library from libwebsocket -> libwebsockets

CMakeLists.txt
lib/daemonize.c
lib/libwebsockets.c
lib/private-libwebsockets.h

index 4dee826..deaeca4 100644 (file)
@@ -33,6 +33,7 @@ option(WITH_BUILTIN_GETIFADDRS "Use BSD getifaddrs implementation from libwebsoc
 option(WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF)
 option(WITHOUT_CLIENT "Don't build the client part of the library" OFF)
 option(WITHOUT_SERVER "Don't build the server part of the library" OFF)
+option(WITHOUT_SERVER_EXTPOLL "Don't build a server version that uses external poll" OFF)
 option(WITH_LIBCRYPTO "Use libcrypto MD5 and SHA1 implementations" ON)
 option(WITHOUT_PING "Don't build the ping test application" OFF)
 option(WITHOUT_DEBUG "Don't compile debug related code" OFF)
@@ -237,7 +238,7 @@ source_group("Sources"          FILES ${SOURCES})
 #
 # Create the lib.
 #
-add_library(websocket STATIC
+add_library(websockets STATIC
                        ${HDR_PRIVATE}
                        ${HDR_PUBLIC}
                        ${SOURCES})
@@ -287,7 +288,7 @@ endif()
 message("ZLib include dirs: ${ZLIB_INCLUDE_DIRS}")
 message("ZLib libraries: ${ZLIB_LIBRARIES}")
 include_directories(${ZLIB_INCLUDE_DIRS})
-target_link_libraries(websocket ${ZLIB_LIBRARIES})
+target_link_libraries(websockets ${ZLIB_LIBRARIES})
 
 #
 # OpenSSL
@@ -310,18 +311,18 @@ if (WITH_SSL)
        message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
        message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
        include_directories(${OPENSSL_INCLUDE_DIR})
-       target_link_libraries(websocket ${OPENSSL_LIBRARIES})
+       target_link_libraries(websockets ${OPENSSL_LIBRARIES})
 endif(WITH_SSL)
 
 #
 # Platform specific libs.
 #
 if (WIN32)
-       target_link_libraries(websocket ws2_32.lib)
+       target_link_libraries(websockets ws2_32.lib)
 endif()
 
 if (UNIX)
-       target_link_libraries(websocket m)
+       target_link_libraries(websockets m)
 endif()
 
 #
@@ -352,7 +353,7 @@ if (NOT WITHOUT_TESTAPPS)
                source_group("Headers"   FILES ${TEST_HDR})
                source_group("Sources"   FILES ${TEST_SRCS})
                add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR})
-               target_link_libraries(${TEST_NAME} websocket)
+               target_link_libraries(${TEST_NAME} websockets)
 
                set_property(
                                        TARGET ${TEST_NAME}
@@ -383,6 +384,22 @@ if (NOT WITHOUT_TESTAPPS)
        endif(NOT WITHOUT_SERVER)
 
        #
+       # test-server-extpoll
+       #
+       if (NOT WITHOUT_SERVER_EXTPOLL)
+               create_test_app(test-server-extpoll
+                       "test-server/test-server.c"
+                       ""
+                       "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
+                       
+                       # Set defines for this executable only.
+                       set_property(
+                               TARGET test-server-extpoll
+                               PROPERTY COMPILE_DEFINITIONS EXTERNAL_POLL INSTALL_DATADIR="${SSL_CERT_DIR}"
+                               )
+       endif(NOT WITHOUT_SERVER_EXTPOLL)
+
+       #
        # test-fraggle
        #
        if (NOT WITHOUT_FRAGGLE)
index c56ad7f..ab537a0 100644 (file)
 int pid_daemon;
 static char *lock_path;
 
+int get_daemonize_pid()
+{
+       return pid_daemon;
+}
+
 static void
 child_handler(int signum)
 {
index 17fd7ef..d747166 100644 (file)
@@ -1513,7 +1513,8 @@ libwebsocket_create_context(int port, const char *interf,
 #endif
 
 #ifndef LWS_NO_DAEMONIZE
-       extern int pid_daemon;
+       extern int get_daemonize_pid();
+       int pid_daemon = get_daemonize_pid();
 #endif
 
        lwsl_notice("Initial logging level %d\n", log_level);
@@ -1561,6 +1562,7 @@ libwebsocket_create_context(int port, const char *interf,
                if (wsdll)
                        poll = (PFNWSAPOLL)GetProcAddress(wsdll, "WSAPoll");
 
+               /* Finally fall back to emulated poll if all else fails */
                if (!poll)
                        poll = emulated_poll;
        }
index 769f2a7..5d618ae 100644 (file)
 
 #include <sys/stat.h>
 
+#ifndef inline
+ #ifdef __inline
+  #define inline __inline
+ #elif defined(__inline__)
+  #define inline __inline__
+ #endif
+#endif
+
 #ifdef WIN32
 #define LWS_NO_DAEMONIZE
 
@@ -390,8 +398,8 @@ struct libwebsocket {
 };
 
 #ifndef LWS_LATENCY
-#define lws_latency(context, wsi, action, ret, completion)
-#define lws_latency_pre(context, wsi)
+static void lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi, const char *action, int ret, int completion) { while (0); }
+static void lws_latency_pre(struct libwebsocket_context *context, struct libwebsocket *wsi) { while (0); }
 #else
 #define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0)
 extern void