2012-10-02 13:49:27 +00:00
|
|
|
##
|
|
|
|
## Makefile for uhub
|
|
|
|
## Copyright (C) 2007-2012, Jan Vidar Krey <janvidar@extatic.org>
|
|
|
|
#
|
|
|
|
|
2012-10-02 20:16:30 +00:00
|
|
|
cmake_minimum_required (VERSION 2.8.3)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-02 21:01:57 +00:00
|
|
|
project (uhub NONE)
|
|
|
|
enable_language(C)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
set (UHUB_VERSION_MAJOR 0)
|
|
|
|
set (UHUB_VERSION_MINOR 4)
|
|
|
|
set (UHUB_VERSION_PATCH 1)
|
|
|
|
|
2012-10-04 21:59:20 +00:00
|
|
|
set (PROJECT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
option(RELEASE "Release build, debug build if disabled" ON)
|
|
|
|
option(LINK_SUPPORT "Allow hub linking" OFF)
|
|
|
|
option(SSL_SUPPORT "Enable SSL support" ON)
|
2012-10-02 21:59:11 +00:00
|
|
|
option(USE_OPENSSL "Use OpenSSL's SSL support" OFF)
|
2012-10-02 19:38:45 +00:00
|
|
|
option(SQLITE_SUPPORT "Enable SQLite support" ON)
|
2012-10-02 21:01:57 +00:00
|
|
|
option(ADC_STRESS "Enable the stress tester client" OFF)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
find_package(Git)
|
|
|
|
|
|
|
|
if (SSL_SUPPORT)
|
2012-10-02 21:59:11 +00:00
|
|
|
if (USE_OPENSSL)
|
|
|
|
find_package(OpenSSL)
|
|
|
|
else()
|
|
|
|
find_package(GnuTLS)
|
|
|
|
endif()
|
|
|
|
if (NOT GNUTLS_FOUND AND NOT OPENSSL_FOUND)
|
|
|
|
message(FATAL_ERROR "Neither OpenSSL nor GnuTLS are not found!")
|
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
|
|
|
|
2012-10-02 13:49:27 +00:00
|
|
|
include_directories("${PROJECT_SOURCE_DIR}")
|
|
|
|
|
|
|
|
set (network_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/network/backend.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/connection.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/epoll.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/kqueue.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/select.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/timeout.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/timer.c
|
|
|
|
${PROJECT_SOURCE_DIR}/network/network.c
|
2012-10-12 12:24:03 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/network/openssl.c
|
2012-10-02 21:01:57 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/network/ipcalc.c
|
2012-10-02 13:49:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set (uhub_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/core/auth.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/command_parser.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/commands.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/config.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/eventqueue.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/hub.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/hubevent.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/inf.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/ioqueue.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/netevent.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/probe.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/route.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/user.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/usermanager.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/plugincallback.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/plugininvoke.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/pluginloader.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set (adc_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/adc/message.c
|
|
|
|
${PROJECT_SOURCE_DIR}/adc/sid.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set (utils_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/util/cbuffer.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/config_token.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/credentials.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/floodctl.c
|
2012-10-02 19:38:45 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/util/getopt.c
|
2012-10-02 13:49:27 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/util/list.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/log.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/memory.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/misc.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/rbtree.c
|
|
|
|
${PROJECT_SOURCE_DIR}/util/tiger.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set (adcclient_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/tools/adcclient.c
|
2012-10-02 20:38:51 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/core/ioqueue.c
|
2012-10-02 13:49:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
add_library(adc STATIC ${adc_SOURCES})
|
|
|
|
add_library(network STATIC ${network_SOURCES})
|
|
|
|
add_library(utils STATIC ${utils_SOURCES})
|
2012-10-02 19:38:45 +00:00
|
|
|
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
add_dependencies(adc utils)
|
|
|
|
add_dependencies(network utils)
|
|
|
|
|
|
|
|
add_executable(uhub ${PROJECT_SOURCE_DIR}/core/main.c ${uhub_SOURCES} )
|
|
|
|
|
|
|
|
add_library(mod_example MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_example.c ${utils_SOURCES})
|
|
|
|
add_library(mod_welcome MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_welcome.c ${utils_SOURCES} ${network_SOURCES})
|
|
|
|
add_library(mod_logging MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_logging.c ${utils_SOURCES} ${PROJECT_SOURCE_DIR}/adc/sid.c ${network_SOURCES})
|
|
|
|
add_library(mod_auth_simple MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_simple.c ${utils_SOURCES})
|
|
|
|
add_library(mod_chat_history MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_history.c ${utils_SOURCES})
|
|
|
|
add_library(mod_chat_only MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_only.c ${utils_SOURCES})
|
|
|
|
add_library(mod_topic MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_topic.c ${utils_SOURCES})
|
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
if (SQLITE_SUPPORT)
|
|
|
|
add_library(mod_auth_sqlite MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_sqlite.c ${utils_SOURCES})
|
|
|
|
add_executable(uhub-passwd ${PROJECT_SOURCE_DIR}/tools/uhub-passwd.c ${PROJECT_SOURCE_DIR}/util/misc.c ${PROJECT_SOURCE_DIR}/util/memory.c ${PROJECT_SOURCE_DIR}/util/log.c ${PROJECT_SOURCE_DIR}/util/list.c)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
target_link_libraries(mod_auth_sqlite sqlite3)
|
|
|
|
target_link_libraries(uhub-passwd sqlite3)
|
|
|
|
set_target_properties(mod_auth_sqlite PROPERTIES PREFIX "")
|
2012-10-02 20:38:51 +00:00
|
|
|
|
|
|
|
if (UNIX)
|
|
|
|
target_link_libraries(uhub pthread)
|
|
|
|
endif()
|
2012-10-02 19:38:45 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(uhub ws2_32)
|
|
|
|
target_link_libraries(mod_logging ws2_32)
|
|
|
|
target_link_libraries(mod_welcome ws2_32)
|
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
set_target_properties(
|
|
|
|
mod_example
|
|
|
|
mod_welcome
|
|
|
|
mod_logging
|
|
|
|
mod_auth_simple
|
|
|
|
mod_chat_history
|
|
|
|
mod_chat_only
|
|
|
|
mod_topic
|
|
|
|
PROPERTIES PREFIX "")
|
|
|
|
|
|
|
|
target_link_libraries(uhub ${CMAKE_DL_LIBS} adc network utils)
|
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
if(UNIX)
|
|
|
|
add_library(adcclient STATIC ${adcclient_SOURCES})
|
2012-10-02 21:01:57 +00:00
|
|
|
add_executable(uhub-admin ${PROJECT_SOURCE_DIR}/tools/admin.c)
|
2012-10-02 19:38:45 +00:00
|
|
|
target_link_libraries(uhub-admin adcclient adc network utils)
|
2012-10-02 21:01:57 +00:00
|
|
|
|
|
|
|
if (ADC_STRESS)
|
|
|
|
add_executable(adcrush ${PROJECT_SOURCE_DIR}/tools/adcrush.c ${adcclient_SOURCES})
|
|
|
|
target_link_libraries(adcrush adcclient adc network utils)
|
|
|
|
endif()
|
2012-10-02 19:38:45 +00:00
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-02 21:01:57 +00:00
|
|
|
if(GIT_FOUND AND IS_DIRECTORY ".git")
|
2012-10-02 13:49:27 +00:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --pretty=format:%h OUTPUT_VARIABLE UHUB_REVISION)
|
|
|
|
set (UHUB_GIT_VERSION "${UHUB_VERSION_MAJOR}.${UHUB_VERSION_MINOR}.${UHUB_VERSION_PATCH}-git-${UHUB_REVISION}")
|
|
|
|
else()
|
2012-10-02 21:01:57 +00:00
|
|
|
set (UHUB_GIT_VERSION "${UHUB_VERSION_MAJOR}.${UHUB_VERSION_MINOR}.${UHUB_VERSION_PATCH}-release")
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OPENSSL_FOUND)
|
2012-10-02 21:59:11 +00:00
|
|
|
set(SSL_LIBS ${OPENSSL_LIBRARIES})
|
|
|
|
add_definitions(-DSSL_SUPPORT=1 -DSSL_USE_OPENSSL=1)
|
2012-10-02 13:49:27 +00:00
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
2012-10-02 21:59:11 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (GNUTLS_FOUND)
|
|
|
|
set(SSL_LIBS ${GNUTLS_LIBRARIES})
|
|
|
|
add_definitions(-DSSL_SUPPORT=1 -DSSL_USE_GNUTLS=1 ${GNUTLS_DEFINITIONS})
|
|
|
|
include_directories(${GNUTLS_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SSL_SUPPORT)
|
|
|
|
target_link_libraries(uhub ${SSL_LIBS})
|
2012-10-02 19:38:45 +00:00
|
|
|
if(UNIX)
|
2012-10-02 21:59:11 +00:00
|
|
|
target_link_libraries(uhub-admin ${SSL_LIBS})
|
2012-10-02 19:38:45 +00:00
|
|
|
endif()
|
2012-10-02 21:59:11 +00:00
|
|
|
target_link_libraries(mod_welcome ${SSL_LIBS})
|
|
|
|
target_link_libraries(mod_logging ${SSL_LIBS})
|
2012-10-02 21:59:11 +00:00
|
|
|
if (ADC_STRESS)
|
2012-10-02 21:59:11 +00:00
|
|
|
target_link_libraries(adcrush ${SSL_LIBS})
|
2012-10-02 21:59:11 +00:00
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
configure_file ("${PROJECT_SOURCE_DIR}/version.h.in" "${PROJECT_SOURCE_DIR}/version.h")
|
|
|
|
|
|
|
|
mark_as_advanced(FORCE CMAKE_BUILD_TYPE)
|
|
|
|
if (RELEASE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
else()
|
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
2012-10-02 21:59:11 +00:00
|
|
|
# add_definitions(-DDEBUG)
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-10-02 21:01:57 +00:00
|
|
|
if (UNIX)
|
|
|
|
install( TARGETS uhub RUNTIME DESTINATION bin )
|
|
|
|
install( TARGETS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_only mod_topic DESTINATION /var/lib/uhub/ OPTIONAL )
|
|
|
|
install( FILES ${CMAKE_SOURCE_DIR}/uhub.conf ${CMAKE_SOURCE_DIR}/plugins.conf ${CMAKE_SOURCE_DIR}/rules.txt ${CMAKE_SOURCE_DIR}/motd.txt DESTINATION /etc/uhub OPTIONAL )
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-02 21:01:57 +00:00
|
|
|
if (SQLITE_SUPPORT)
|
|
|
|
install( TARGETS uhub-passwd RUNTIME DESTINATION bin )
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|