diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1af78db..f9b06dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,10 +8,18 @@ set(UHTTPD_VERSION_PATCH 1) # Check the third party Libraries find_package(Libev REQUIRED) +find_library(LIBDL dl) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/buffer ${CMAKE_CURRENT_BINARY_DIR} ${LIBEV_INCLUDE_DIR}) -set(EXTRA_LIBS ${LIBEV_LIBRARY} dl m) +set(EXTRA_LIBS ${LIBEV_LIBRARY} m) + +if(NOT ${LIBDL} STREQUAL "LIBDL-NOTFOUND") + message(STATUS "Found Libdl: ${LIBDL}") + list(APPEND EXTRA_LIBS ${LIBDL}) + add_definitions(-DHAVE_DLOPEN) +endif() + set(SOURCE_FILES uhttpd.c log.c connection.c buffer/buffer.c http-parser/http_parser.c ssl.c) set(UHTTPD_SSL_SUPPORT_CONFIG 1) @@ -100,7 +108,9 @@ target_link_libraries(uhttpd_s ${EXTRA_LIBS}) # configure a header file to pass some of the CMake settings to the source code configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) -add_subdirectory(plugins) +if(NOT ${LIBDL} STREQUAL "LIBDL-NOTFOUND") + add_subdirectory(plugins) +endif() install( FILES diff --git a/src/uhttpd.c b/src/uhttpd.c index 02f433b..9306637 100644 --- a/src/uhttpd.c +++ b/src/uhttpd.c @@ -26,9 +26,11 @@ #include #include #include -#include #include #include +#ifdef HAVE_DLOPEN +#include +#endif #include "uhttpd.h" #include "utils.h" @@ -113,6 +115,7 @@ static int uh_server_ssl_init(struct uh_server *srv, const char *cert, const cha static int uh_load_plugin(struct uh_server *srv, const char *path) { +#ifdef HAVE_DLOPEN struct uh_plugin *p; void *dlh; @@ -143,6 +146,10 @@ static int uh_load_plugin(struct uh_server *srv, const char *path) srv->plugins = p; return 0; +#else + uh_log_err("Not support plugin\n"); + return -1; +#endif } int uh_server_init(struct uh_server *srv, struct ev_loop *loop, const char *host, int port)