From 8c8ad7be6d6d6e9ed4d35905f520ae7df74670e1 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Fri, 3 Apr 2026 18:13:31 +0300 Subject: [PATCH] Add cmake environment --- .github/workflows/c-cpp.yml | 3 + CMakeLists.txt | 550 ++++++++++++++++++ Makefile.FreeBSD | 2 +- Makefile.Linux | 5 +- Makefile.Solaris | 4 +- Makefile.Solaris-gcc | 4 +- Makefile.debug | 4 +- Makefile.msvc | 4 +- Makefile.msvc64 | 4 +- Makefile.msvcARM64 | 4 +- Makefile.msvcCE | 4 +- Makefile.openwrt-mips | 4 +- Makefile.unix | 4 +- Makefile.watcom | 4 +- Makefile.win | 4 +- Makefile.winCE | 4 +- cmake/FindODBC.cmake | 63 ++ cmake/FindPAM.cmake | 45 ++ cmake/FindPCRE2.cmake | 69 +++ cmake/plugins.cmake | 76 +++ src/plugins/FilePlugin/CMakeLists.txt | 4 + src/plugins/PCREPlugin/CMakeLists.txt | 20 + src/plugins/PamAuth/CMakeLists.txt | 19 + src/plugins/SSLPlugin/CMakeLists.txt | 17 + src/plugins/StringsPlugin/CMakeLists.txt | 4 + src/plugins/TrafficPlugin/CMakeLists.txt | 4 + src/plugins/TransparentPlugin/CMakeLists.txt | 6 + .../WindowsAuthentication/CMakeLists.txt | 10 + src/plugins/utf8tocp1251/CMakeLists.txt | 4 + 29 files changed, 908 insertions(+), 41 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake/FindODBC.cmake create mode 100644 cmake/FindPAM.cmake create mode 100644 cmake/FindPCRE2.cmake create mode 100644 cmake/plugins.cmake create mode 100644 src/plugins/FilePlugin/CMakeLists.txt create mode 100644 src/plugins/PCREPlugin/CMakeLists.txt create mode 100644 src/plugins/PamAuth/CMakeLists.txt create mode 100644 src/plugins/SSLPlugin/CMakeLists.txt create mode 100644 src/plugins/StringsPlugin/CMakeLists.txt create mode 100644 src/plugins/TrafficPlugin/CMakeLists.txt create mode 100644 src/plugins/TransparentPlugin/CMakeLists.txt create mode 100644 src/plugins/WindowsAuthentication/CMakeLists.txt create mode 100644 src/plugins/utf8tocp1251/CMakeLists.txt diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 163630d..a2d2331 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -77,3 +77,6 @@ jobs: set "INCLUDE=%INCLUDE%;c:/program files/openssl/include;c:/vcpkg/installed/x64-windows/include" nmake /F Makefile.msvc64 nmake /F Makefile.msvc64 clean + - name: make Windows MSVC + run: mkdir build && cd build && cmake .. && make + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..12a5e6a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,550 @@ +# +# 3proxy CMake build system +# + +cmake_minimum_required(VERSION 3.16) + +# Read version from RELEASE file +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE" PROJECT_VERSION LIMIT_COUNT 1) + +project(3proxy + VERSION ${PROJECT_VERSION} + LANGUAGES C + DESCRIPTION "3proxy - tiny free proxy server" +) + +# Include GNUInstallDirs for standard installation directories +include(GNUInstallDirs) + +# Add cmake module path +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +# Detect compiler +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") + set(COMPILER_IS_CLANG TRUE) + if(WIN32 AND CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + set(COMPILER_IS_CLANG_CL TRUE) + else() + set(COMPILER_IS_CLANG_CL FALSE) + endif() +else() + set(COMPILER_IS_CLANG FALSE) + set(COMPILER_IS_CLANG_CL FALSE) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + set(COMPILER_IS_GCC TRUE) +else() + set(COMPILER_IS_GCC FALSE) +endif() + +if(MSVC AND NOT COMPILER_IS_CLANG_CL) + set(COMPILER_IS_MSVC TRUE) +else() + set(COMPILER_IS_MSVC FALSE) +endif() + +# Options +option(3PROXY_BUILD_SHARED "Build shared libraries for plugins" ON) +option(3PROXY_USE_OPENSSL "Enable OpenSSL/SSLPlugin" ON) +option(3PROXY_USE_PCRE2 "Enable PCRE2/PCREPlugin" ON) +option(3PROXY_USE_PAM "Enable PAM/PamAuth" ON) +option(3PROXY_USE_ODBC "Enable ODBC support (Unix only, always ON on Windows)" OFF) +option(3PROXY_USE_SPLICE "Use Linux splice() for zero-copy (Linux only)" ON) +option(3PROXY_USE_POLL "Use poll() instead of select() (Unix only)" ON) +option(3PROXY_USE_WSAPOLL "Use WSAPoll instead of select() (Windows only)" ON) +option(3PROXY_USE_NETFILTER "Enable Linux netfilter support (Linux only)" ON) + +# Output directory +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +# Find threads library (cross-platform pthread equivalent) +find_package(Threads REQUIRED) + +# Set default build type if not specified +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) +endif() + +# Platform-independent position independent code for shared libraries +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Platform detection and configuration +if(WIN32) + # Windows-specific configuration + add_compile_definitions( + WIN32 + _WIN32 + _MBCS + _CONSOLE + PRINTF_INT64_MODIFIER="I64" + ) + + if(COMPILER_IS_MSVC) + # MSVC-specific settings + add_compile_definitions( + MSVC + WITH_SSL + ) + # Use static runtime library + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + # MSVC compiler options + add_compile_options( + /W3 # Warning level 3 + /GS # Buffer security check + /GA # Optimize for Windows applications + /GF # Enable string pooling + ) + # Optimization flags per build type + set(CMAKE_C_FLAGS_RELEASE "/O2") + + elseif(COMPILER_IS_CLANG_CL) + # clang-cl (Clang with MSVC frontend) + add_compile_definitions( + MSVC + WITH_SSL + ) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + add_compile_options( + -W3 + -fno-strict-aliasing + ) + + elseif(COMPILER_IS_CLANG OR COMPILER_IS_GCC) + # Clang or GCC on Windows (MinGW-like) + add_compile_definitions(WITH_STD_MALLOC) + add_compile_options(-fno-strict-aliasing) + + elseif(WATCOM) + # OpenWatcom-specific flags + add_compile_definitions( + WATCOM + MSVC + NOIPV6 + NODEBUG + NORADIUS + ) + endif() + + # Windows libraries + set(WINDOWS_LIBS ws2_32 advapi32 user32 kernel32 gdi32 crypt32) + + # Windows plugins (always built) + set(DEFAULT_PLUGINS + utf8tocp1251 + WindowsAuthentication + TrafficPlugin + StringsPlugin + FilePlugin + ) + +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Linux-specific configuration + add_compile_definitions( + _GNU_SOURCE + GETHOSTBYNAME_R + _THREAD_SAFE + _REENTRANT + ) + + if(COMPILER_IS_CLANG OR COMPILER_IS_GCC) + # Clang/GCC on Linux + add_compile_options(-fno-strict-aliasing) + endif() + + if(3PROXY_USE_SPLICE) + add_compile_definitions(WITHSPLICE) + endif() + + if(3PROXY_USE_NETFILTER) + add_compile_definitions(WITH_NETFILTER) + endif() + + set(DEFAULT_PLUGINS + StringsPlugin + TrafficPlugin + TransparentPlugin + ) + +elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD|Darwin|OpenBSD|NetBSD") + # BSD/macOS-specific configuration + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + # macOS-specific + add_compile_definitions(_DARWIN_UNLIMITED_SELECT) + endif() + + if(COMPILER_IS_CLANG OR COMPILER_IS_GCC) + add_compile_options(-fno-strict-aliasing) + endif() + + set(DEFAULT_PLUGINS + StringsPlugin + TrafficPlugin + TransparentPlugin + ) + +else() + # Generic Unix configuration + if(COMPILER_IS_CLANG OR COMPILER_IS_GCC) + add_compile_options(-fno-strict-aliasing) + endif() + + set(DEFAULT_PLUGINS + StringsPlugin + TrafficPlugin + TransparentPlugin + ) +endif() + +# Common definitions +if(WIN32) + # Windows: use WSAPOLL + if(3PROXY_USE_WSAPOLL) + add_compile_definitions(WITH_WSAPOLL) + else() + add_compile_definitions(FD_SETSIZE=4096) + endif() +else() + # Unix: use poll + if(3PROXY_USE_POLL) + add_compile_definitions(WITH_POLL) + else() + add_compile_definitions(FD_SETSIZE=4096) + endif() +endif() + +# Find dependencies + +# OpenSSL +set(OPENSSL_FOUND FALSE) +if(3PROXY_USE_OPENSSL) + find_package(OpenSSL QUIET) + if(OpenSSL_FOUND) + set(OPENSSL_FOUND TRUE) + add_compile_definitions(WITH_SSL) + message(STATUS "OpenSSL found: ${OPENSSL_VERSION}") + else() + message(STATUS "OpenSSL not found, SSLPlugin will not be built") + endif() +endif() + +# PCRE2 +set(PCRE2_FOUND FALSE) +if(3PROXY_USE_PCRE2) + find_package(PCRE2 QUIET) + if(PCRE2_FOUND) + message(STATUS "PCRE2 found: ${PCRE2_VERSION}") + else() + message(STATUS "PCRE2 not found, PCREPlugin will not be built") + endif() +endif() + +# PAM (Unix only) +set(PAM_FOUND FALSE) +if(3PROXY_USE_PAM AND NOT WIN32) + find_package(PAM QUIET) + if(PAM_FOUND) + message(STATUS "PAM found") + else() + message(STATUS "PAM not found, PamAuth will not be built") + endif() +endif() + +# ODBC (always enabled on Windows) +set(ODBC_FOUND FALSE) +if(WIN32 OR 3PROXY_USE_ODBC) + find_package(ODBC QUIET) + if(ODBC_FOUND) + message(STATUS "ODBC found") + else() + message(STATUS "ODBC not found, building without ODBC support") + endif() +endif() + +# Set NOODBC if ODBC is not found +if(NOT ODBC_FOUND) + add_compile_definitions(NOODBC) +endif() + +# Source files for 3proxy core +set(3PROXY_CORE_SOURCES + src/3proxy.c + src/auth.c + src/authradius.c + src/conf.c + src/datatypes.c + src/plugins.c + src/stringtable.c +) + +# MD4/MD5 sources for mycrypt +set(MD_SOURCES + src/libs/md4.c + src/libs/md5.c +) + +# ============================================================================ +# Object libraries for common sources (shared between executables) +# ============================================================================ + +# Common object library (sockmap, sockgetchar, common, log) +add_library(common_obj OBJECT + src/sockmap.c + src/sockgetchar.c + src/common.c + src/log.c +) +target_include_directories(common_obj PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + +# base64 object library +add_library(base64_obj OBJECT src/base64.c) +target_include_directories(base64_obj PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + +# ============================================================================ +# Object libraries for 3proxy (compiled WITHOUT WITHMAIN) +# These are used by the main 3proxy executable +# ============================================================================ + +# Server modules object library (without WITHMAIN) +add_library(srv_modules OBJECT + src/proxy.c + src/pop3p.c + src/smtpp.c + src/ftppr.c + src/tcppm.c + src/tlspr.c + src/auto.c + src/socks.c + src/webadmin.c + src/udppm.c + src/dnspr.c +) + +target_include_directories(srv_modules PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +# mainfunc object (proxymain.c compiled with MODULEMAINFUNC=mainfunc for 3proxy) +add_library(mainfunc OBJECT src/proxymain.c) +target_include_directories(mainfunc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_compile_definitions(mainfunc PRIVATE MODULEMAINFUNC=mainfunc) + +# ftp object (used only by 3proxy and ftppr) +add_library(ftp_obj OBJECT src/ftp.c) +target_include_directories(ftp_obj PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + +# mycrypt object for 3proxy (without WITHMAIN) +add_library(mycrypt_obj OBJECT src/mycrypt.c) +target_include_directories(mycrypt_obj PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + +# ============================================================================ +# Main 3proxy executable +# Uses srv_* object files (without WITHMAIN) +# ============================================================================ + +add_executable(3proxy + ${3PROXY_CORE_SOURCES} + ${MD_SOURCES} + $ + $ + $ + $ + $ + $ +) + +target_include_directories(3proxy PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src/libs +) + +target_link_libraries(3proxy PRIVATE Threads::Threads) + +if(ODBC_FOUND) + if(TARGET ODBC::ODBC) + target_link_libraries(3proxy PRIVATE ODBC::ODBC) + else() + target_link_libraries(3proxy PRIVATE ${ODBC_LIBRARIES}) + endif() +endif() + +if(WIN32) + target_link_libraries(3proxy PRIVATE ${WINDOWS_LIBS}) + if(OpenSSL_FOUND) + target_link_libraries(3proxy PRIVATE OpenSSL::SSL OpenSSL::Crypto) + endif() + if(COMPILER_IS_MSVC AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3proxy.rc) + target_sources(3proxy PRIVATE 3proxy.rc) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(3proxy PRIVATE dl) + if(OpenSSL_FOUND) + target_link_libraries(3proxy PRIVATE OpenSSL::SSL OpenSSL::Crypto) + endif() +endif() + +# Build mycrypt utility +add_executable(mycrypt + src/mycrypt.c + ${MD_SOURCES} + $ +) +target_compile_definitions(mycrypt PRIVATE WITHMAIN) +target_include_directories(mycrypt PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src/libs +) +target_link_libraries(mycrypt PRIVATE Threads::Threads) + +# Build standalone proxy executables +foreach(PROXY_NAME proxy socks pop3p smtpp ftppr tcppm udppm tlspr) + if(PROXY_NAME STREQUAL "ftppr" OR PROXY_NAME STREQUAL "proxy") + # ftppr and proxy use ftp_obj + add_executable(${PROXY_NAME} + src/${PROXY_NAME}.c + $ + $ + ) + else() + add_executable(${PROXY_NAME} + src/${PROXY_NAME}.c + $ + ) + endif() + + target_include_directories(${PROXY_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_compile_definitions(${PROXY_NAME} PRIVATE + WITHMAIN + NOPORTMAP + ) + + target_link_libraries(${PROXY_NAME} PRIVATE Threads::Threads) + + if(PROXY_NAME STREQUAL "proxy") + target_compile_definitions(${PROXY_NAME} PRIVATE ANONYMOUS) + endif() + + if(PROXY_NAME STREQUAL "tcppm" OR PROXY_NAME STREQUAL "udppm" OR PROXY_NAME STREQUAL "tlspr") + target_compile_definitions(${PROXY_NAME} PRIVATE PORTMAP) + endif() + + if(WIN32) + target_link_libraries(${PROXY_NAME} PRIVATE ${WINDOWS_LIBS}) + endif() + + if(PROXY_NAME STREQUAL "proxy" OR PROXY_NAME STREQUAL "smtpp") + target_sources(${PROXY_NAME} PRIVATE $) + endif() +endforeach() + +# Plugin output directory +set(PLUGIN_OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +if(WIN32) + set(PLUGIN_SUFFIX ".dll") +else() + set(PLUGIN_SUFFIX ".ld.so") +endif() + +# Include plugin definitions +include(cmake/plugins.cmake) + +# Build plugins +foreach(PLUGIN ${DEFAULT_PLUGINS}) + add_subdirectory(src/plugins/${PLUGIN}) +endforeach() + +if(OPENSSL_FOUND) + add_subdirectory(src/plugins/SSLPlugin) +endif() + +if(PCRE2_FOUND) + add_subdirectory(src/plugins/PCREPlugin) +endif() + +if(PAM_FOUND) + add_subdirectory(src/plugins/PamAuth) +endif() + +# Build full list of plugins to be built +set(ALL_PLUGINS ${DEFAULT_PLUGINS}) +if(OPENSSL_FOUND) + list(APPEND ALL_PLUGINS SSLPlugin) +endif() +if(PCRE2_FOUND) + list(APPEND ALL_PLUGINS PCREPlugin) +endif() +if(PAM_FOUND) + list(APPEND ALL_PLUGINS PamAuth) +endif() + +# Installation rules +install(TARGETS 3proxy mycrypt proxy socks pop3p smtpp ftppr tcppm udppm tlspr + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +# Install plugins +if(WIN32) + install(FILES + ${PLUGIN_OUTPUT_DIR}/utf8tocp1251${PLUGIN_SUFFIX} + ${PLUGIN_OUTPUT_DIR}/WindowsAuthentication${PLUGIN_SUFFIX} + ${PLUGIN_OUTPUT_DIR}/TrafficPlugin${PLUGIN_SUFFIX} + ${PLUGIN_OUTPUT_DIR}/StringsPlugin${PLUGIN_SUFFIX} + DESTINATION ${CMAKE_INSTALL_BINDIR} + ) +else() + install(FILES + ${PLUGIN_OUTPUT_DIR}/StringsPlugin${PLUGIN_SUFFIX} + ${PLUGIN_OUTPUT_DIR}/TrafficPlugin${PLUGIN_SUFFIX} + ${PLUGIN_OUTPUT_DIR}/TransparentPlugin${PLUGIN_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/3proxy + ) +endif() + +# Install configuration files +if(NOT WIN32) + install(FILES scripts/3proxy.cfg DESTINATION /etc/3proxy) + install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() + +# Install man pages +if(NOT WIN32) + file(GLOB MAN3_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.3") + file(GLOB MAN8_FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/*.8") + install(FILES ${MAN3_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) + install(FILES ${MAN8_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man8) +endif() + +# Summary +message(STATUS "") +message(STATUS "3proxy configuration summary:") +message(STATUS " Version: ${PROJECT_VERSION}") +message(STATUS " Platform: ${CMAKE_SYSTEM_NAME}") +message(STATUS " Compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") +message(STATUS " Build type: ${CMAKE_BUILD_TYPE}") +message(STATUS "") +message(STATUS " Options:") +message(STATUS " BUILD_SHARED: ${3PROXY_BUILD_SHARED}") +message(STATUS " USE_OPENSSL: ${3PROXY_USE_OPENSSL}") +message(STATUS " USE_PCRE2: ${3PROXY_USE_PCRE2}") +message(STATUS " USE_PAM: ${3PROXY_USE_PAM}") +message(STATUS " USE_ODBC: ${3PROXY_USE_ODBC}") +message(STATUS " USE_POLL: ${3PROXY_USE_POLL}") +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + message(STATUS " USE_SPLICE: ${3PROXY_USE_SPLICE}") + message(STATUS " USE_NETFILTER: ${3PROXY_USE_NETFILTER}") +endif() +if(WIN32) + message(STATUS " USE_WSAPOLL: ${3PROXY_USE_WSAPOLL}") +endif() +message(STATUS "") +message(STATUS " Libraries found:") +message(STATUS " OpenSSL: ${OPENSSL_FOUND}") +message(STATUS " PCRE2: ${PCRE2_FOUND}") +message(STATUS " PAM: ${PAM_FOUND}") +message(STATUS " ODBC: ${ODBC_FOUND}") +message(STATUS "") +message(STATUS " Plugins to build: ${ALL_PLUGINS}") +message(STATUS "") diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index 49c6bae..d6f701d 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -7,7 +7,7 @@ BUILDDIR = ../bin/ CC ?= cc -CFLAGS := -c -fno-strict-aliasing -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL $(CFLAGS) +CFLAGS := -c -fno-strict-aliasing -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL $(CFLAGS) COUT = -o LN ?= ${CC} LDFLAGS += -pthread -fno-strict-aliasing diff --git a/Makefile.Linux b/Makefile.Linux index 95866db..cdd838d 100644 --- a/Makefile.Linux +++ b/Makefile.Linux @@ -1,16 +1,13 @@ # # 3 proxy Makefile for GCC/Linux/Cygwin # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries -# # remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC # library support. Add -DSAFESQL for poorely written ODBC library / drivers. BUILDDIR = ../bin/ CC ?= gcc -CFLAGS := -g -fPIC -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER $(CFLAGS) +CFLAGS := -g -fPIC -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOURCE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER $(CFLAGS) COUT = -o LN ?= ${CC} DCFLAGS ?= diff --git a/Makefile.Solaris b/Makefile.Solaris index c8da233..812b4e2 100644 --- a/Makefile.Solaris +++ b/Makefile.Solaris @@ -1,15 +1,13 @@ # # 3 proxy Makefile for Solaris/SunCC # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC # library support. Add -DSAFESQL for poorely written ODBC library / drivers. BUILDDIR = ../bin/ CC = cc -CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL +CFLAGS = -xO3 -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL COUT = -o ./ LN = $(CC) LDFLAGS = -xO3 diff --git a/Makefile.Solaris-gcc b/Makefile.Solaris-gcc index db43d7e..db3f551 100644 --- a/Makefile.Solaris-gcc +++ b/Makefile.Solaris-gcc @@ -1,8 +1,6 @@ # # 3 proxy Makefile for Solaris/gcc # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC # library support. Add -DSAFESQL for poorely written ODBC library / drivers. @@ -10,7 +8,7 @@ BUILDDIR = ../bin/ CC = gcc -CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL +CFLAGS = -O2 -fno-strict-aliasing -c -D_SOLARIS -D_THREAD_SAFE -DGETHOSTBYNAME_R -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL COUT = -o ./ LN = $(CC) LDFLAGS = -O3 diff --git a/Makefile.debug b/Makefile.debug index f9aabc5..3021ff4 100644 --- a/Makefile.debug +++ b/Makefile.debug @@ -1,12 +1,10 @@ # # 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake) # -# You can try to add /D "WITH_STD_MALLOC" to CFLAGS to use standard malloc -# libraries BUILDDIR = ../bin/ CC = cl -CFLAGS = /FD /MDd /nologo /W3 /ZI /Wp64 /GS /Gs /RTCsu /EHs- /GA /GF /DEBUG /D "WITH_STD_MALLOC" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c +CFLAGS = /FD /MDd /nologo /W3 /ZI /Wp64 /GS /Gs /RTCsu /EHs- /GA /GF /DEBUG /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /c COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /machine:I386 /DEBUG diff --git a/Makefile.msvc b/Makefile.msvc index 5affb31..49cc45f 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -1,14 +1,12 @@ # # 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake) # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver BUILDDIR = ../bin/ CC = cl -CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE) +CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE) COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 diff --git a/Makefile.msvc64 b/Makefile.msvc64 index 3a2e8b2..1df0048 100644 --- a/Makefile.msvc64 +++ b/Makefile.msvc64 @@ -1,8 +1,6 @@ # # 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake) # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver @@ -10,7 +8,7 @@ MAKEFILE = Makefile.msvc64 BUILDDIR = ../bin64/ CC = cl -CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_SSL" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE) $(CFLAGS) +CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_SSL" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE) $(CFLAGS) COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64 diff --git a/Makefile.msvcARM64 b/Makefile.msvcARM64 index a892c0d..383212e 100644 --- a/Makefile.msvcARM64 +++ b/Makefile.msvcARM64 @@ -1,14 +1,12 @@ # # 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake) # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver BUILDDIR = ../bin64/ CC = cl -CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_STD_MALLOC" /D "WITH_WSAPOLL" /D "WITH_SSL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE) +CFLAGS = /nologo /MT /W3 /Ox /EHs- /GS /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "WITH_SSL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c $(VERSION) $(BUILDDATE) COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /incremental:no /machine:arm64 diff --git a/Makefile.msvcCE b/Makefile.msvcCE index b19be19..dbc855c 100644 --- a/Makefile.msvcCE +++ b/Makefile.msvcCE @@ -1,14 +1,12 @@ # # 3 proxy Makefile for Microsoft Visual C compiler (for both make and nmake) # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver BUILDDIR = ../bin/ CC = cl -CFLAGS = /DARM /D "NOODBC" /nologo /MT /W3 /Wp64 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "_WINCE" /D "WITH_STD_MALLOC" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c +CFLAGS = /DARM /D "NOODBC" /nologo /MT /W3 /Wp64 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "_WINCE" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /Fp"proxy.pch" /FD /c COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /incremental:no diff --git a/Makefile.openwrt-mips b/Makefile.openwrt-mips index 0cbe8f0..a2ad64c 100644 --- a/Makefile.openwrt-mips +++ b/Makefile.openwrt-mips @@ -1,8 +1,6 @@ # # 3 proxy Makefile for GCC/Linux/Cygwin # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC # library support. Add -DSAFESQL for poorely written ODBC library / drivers. @@ -10,7 +8,7 @@ BUILDDIR = ../bin/ CC = mips-openwrt-linux-gcc -CFLAGS ?= -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER +CFLAGS ?= -g -O2 -fno-strict-aliasing -c -pthread -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER COUT = -o LN = $(CC) DCFLAGS = -fPIC diff --git a/Makefile.unix b/Makefile.unix index 6082a79..9040d4d 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -1,8 +1,6 @@ # # 3 proxy Makefile for GCC/Unix # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC # library support. Add -DSAFESQL for poorely written ODBC library / drivers. @@ -11,7 +9,7 @@ BUILDDIR = ../bin/ CC ?= gcc # you may need -L/usr/pkg/lib for older NetBSD versions -CFLAGS := -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL $(CFLAGS) +CFLAGS := -g -O2 -fno-strict-aliasing -c -pthread -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DFD_SETSIZE=4096 -DWITH_POLL $(CFLAGS) COUT = -o LN ?= $(CC) LDFLAGS ?= -O2 -fno-strict-aliasing -pthread diff --git a/Makefile.watcom b/Makefile.watcom index d8f548f..d0f3380 100644 --- a/Makefile.watcom +++ b/Makefile.watcom @@ -1,14 +1,12 @@ # # 3 proxy Makefile for Open Watcom 2 # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # Add /DSAFESQL to CFLAGS if you are using poorely written/tested ODBC driver BUILDDIR = ../bin/ CC = cl -CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WITH_STD_MALLOC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /c $(VERSION) $(BUILDDATE) +CFLAGS = /nologo /Ox /MT /D "NOIPV6" /D "NODEBUG" /D "NOODBC" /D "NORADIUS" /D"WATCOM" /D "MSVC" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /D "PRINTF_INT64_MODIFIER=\"I64\"" /c $(VERSION) $(BUILDDATE) COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /incremental:no diff --git a/Makefile.win b/Makefile.win index 2980f8c..4a9c774 100644 --- a/Makefile.win +++ b/Makefile.win @@ -1,8 +1,6 @@ # # 3 proxy Makefile for GCC/windows # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC # library support @@ -10,7 +8,7 @@ BUILDDIR = ../bin/ CC ?= gcc -CFLAGS := -O2 -s -c -mthreads -DWITH_STD_MALLOC -DWITH_WSAPOLL $(CFLAGS) +CFLAGS := -O2 -s -c -mthreads -DWITH_WSAPOLL $(CFLAGS) COUT = -o LN ?= $(CC) LDFLAGS := -O2 -s -mthreads $(LDFLAGS) diff --git a/Makefile.winCE b/Makefile.winCE index de23e64..9a46630 100644 --- a/Makefile.winCE +++ b/Makefile.winCE @@ -1,8 +1,6 @@ # # 3 proxy Makefile for GCC/windows # -# You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc -# libraries # # remove -DNOODBC from CFLAGS and add -lodbc to LDFLAGS to compile with ODBC # library support @@ -10,7 +8,7 @@ BUILDDIR = ../bin/ CC = /opt/cegcc/arm-wince-cegcc/bin/gcc -CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOODBC -D_WINCE -D_WIN32 -DNORADIUS -D__USE_W32_SOCKETS +CFLAGS = -O2 -s -c -mthreads -DNOODBC -D_WINCE -D_WIN32 -DNORADIUS -D__USE_W32_SOCKETS COUT = -o LN = /opt/cegcc/arm-wince-cegcc/bin/gcc LDFLAGS = -O2 -s -mthreads diff --git a/cmake/FindODBC.cmake b/cmake/FindODBC.cmake new file mode 100644 index 0000000..822339a --- /dev/null +++ b/cmake/FindODBC.cmake @@ -0,0 +1,63 @@ +# FindODBC.cmake +# +# Find the ODBC library +# +# This module defines: +# ODBC_FOUND - whether the ODBC library was found +# ODBC_INCLUDE_DIRS - the ODBC include directories +# ODBC_LIBRARIES - the ODBC libraries + +# Try pkg-config first +find_package(PkgConfig QUIET) +if(PkgConfig_FOUND) + pkg_check_modules(PC_ODBC QUIET odbc) +endif() + +# Find include directory +find_path(ODBC_INCLUDE_DIR + NAMES sql.h + HINTS + ${PC_ODBC_INCLUDE_DIRS} + /usr/include + /usr/local/include +) + +# Find library +if(WIN32) + # On Windows, ODBC is typically available as odbc32 + find_library(ODBC_LIBRARY + NAMES odbc32 + HINTS + ${PC_ODBC_LIBRARY_DIRS} + ) +else() + # On Unix, look for odbc + find_library(ODBC_LIBRARY + NAMES odbc iodbc + HINTS + ${PC_ODBC_LIBRARY_DIRS} + /usr/lib + /usr/local/lib + /usr/lib/x86_64-linux-gnu + ) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ODBC + REQUIRED_VARS ODBC_LIBRARY ODBC_INCLUDE_DIR +) + +if(ODBC_FOUND) + set(ODBC_LIBRARIES ${ODBC_LIBRARY}) + set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR}) + + if(NOT TARGET ODBC::ODBC) + add_library(ODBC::ODBC UNKNOWN IMPORTED) + set_target_properties(ODBC::ODBC PROPERTIES + IMPORTED_LOCATION "${ODBC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}" + ) + endif() +endif() + +mark_as_advanced(ODBC_INCLUDE_DIR ODBC_LIBRARY) diff --git a/cmake/FindPAM.cmake b/cmake/FindPAM.cmake new file mode 100644 index 0000000..59cd8d4 --- /dev/null +++ b/cmake/FindPAM.cmake @@ -0,0 +1,45 @@ +# FindPAM.cmake +# +# Find the PAM library +# +# This module defines: +# PAM_FOUND - whether the PAM library was found +# PAM_INCLUDE_DIRS - the PAM include directories +# PAM_LIBRARIES - the PAM libraries + +# Find include directory +find_path(PAM_INCLUDE_DIR + NAMES security/pam_appl.h pam/pam_appl.h + HINTS + /usr/include + /usr/local/include +) + +# Find library +find_library(PAM_LIBRARY + NAMES pam + HINTS + /usr/lib + /usr/local/lib + /usr/lib/x86_64-linux-gnu +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PAM + REQUIRED_VARS PAM_LIBRARY PAM_INCLUDE_DIR +) + +if(PAM_FOUND) + set(PAM_LIBRARIES ${PAM_LIBRARY}) + set(PAM_INCLUDE_DIRS ${PAM_INCLUDE_DIR}) + + if(NOT TARGET PAM::PAM) + add_library(PAM::PAM UNKNOWN IMPORTED) + set_target_properties(PAM::PAM PROPERTIES + IMPORTED_LOCATION "${PAM_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PAM_INCLUDE_DIR}" + ) + endif() +endif() + +mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY) diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake new file mode 100644 index 0000000..008636e --- /dev/null +++ b/cmake/FindPCRE2.cmake @@ -0,0 +1,69 @@ +# FindPCRE2.cmake +# +# Find the PCRE2 library +# +# This module defines: +# PCRE2_FOUND - whether the PCRE2 library was found +# PCRE2_INCLUDE_DIRS - the PCRE2 include directories +# PCRE2_LIBRARIES - the PCRE2 libraries +# PCRE2_VERSION - the PCRE2 version + +# Try pkg-config first +find_package(PkgConfig QUIET) +if(PkgConfig_FOUND) + pkg_check_modules(PC_PCRE2 QUIET libpcre2-8) +endif() + +# Find include directory +find_path(PCRE2_INCLUDE_DIR + NAMES pcre2.h + HINTS + ${PC_PCRE2_INCLUDE_DIRS} + /usr/include + /usr/local/include + PATH_SUFFIXES + pcre2 +) + +# Find library +find_library(PCRE2_LIBRARY + NAMES pcre2-8 pcre2-8d pcre2 + HINTS + ${PC_PCRE2_LIBRARY_DIRS} + /usr/lib + /usr/local/lib +) + +# Extract version from header +if(PCRE2_INCLUDE_DIR AND EXISTS "${PCRE2_INCLUDE_DIR}/pcre2.h") + file(STRINGS "${PCRE2_INCLUDE_DIR}/pcre2.h" PCRE2_VERSION_MAJOR_LINE + REGEX "^#define[ \t]+PCRE2_MAJOR[ \t]+[0-9]+") + file(STRINGS "${PCRE2_INCLUDE_DIR}/pcre2.h" PCRE2_VERSION_MINOR_LINE + REGEX "^#define[ \t]+PCRE2_MINOR[ \t]+[0-9]+") + string(REGEX REPLACE "^#define[ \t]+PCRE2_MAJOR[ \t]+([0-9]+)" "\\1" + PCRE2_VERSION_MAJOR "${PCRE2_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+PCRE2_MINOR[ \t]+([0-9]+)" "\\1" + PCRE2_VERSION_MINOR "${PCRE2_VERSION_MINOR_LINE}") + set(PCRE2_VERSION "${PCRE2_VERSION_MAJOR}.${PCRE2_VERSION_MINOR}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCRE2 + REQUIRED_VARS PCRE2_LIBRARY PCRE2_INCLUDE_DIR + VERSION_VAR PCRE2_VERSION +) + +if(PCRE2_FOUND) + set(PCRE2_LIBRARIES ${PCRE2_LIBRARY}) + set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR}) + + if(NOT TARGET PCRE2::PCRE2) + add_library(PCRE2::PCRE2 UNKNOWN IMPORTED) + set_target_properties(PCRE2::PCRE2 PROPERTIES + IMPORTED_LOCATION "${PCRE2_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PCRE2_INCLUDE_DIR}" + ) + endif() +endif() + +mark_as_advanced(PCRE2_INCLUDE_DIR PCRE2_LIBRARY) diff --git a/cmake/plugins.cmake b/cmake/plugins.cmake new file mode 100644 index 0000000..643416e --- /dev/null +++ b/cmake/plugins.cmake @@ -0,0 +1,76 @@ +# +# 3proxy plugin definitions +# +# This file defines functions for building plugins +# + +# Function to add a simple plugin (single source file, no dependencies) +function(add_3proxy_plugin_simple PLUGIN_NAME SOURCE_FILE) + if(WIN32) + set(PLUGIN_SUFFIX ".dll") + else() + set(PLUGIN_SUFFIX ".ld.so") + endif() + + add_library(${PLUGIN_NAME} SHARED ${SOURCE_FILE}) + + set_target_properties(${PLUGIN_NAME} PROPERTIES + PREFIX "" + SUFFIX ${PLUGIN_SUFFIX} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + + target_link_libraries(${PLUGIN_NAME} PRIVATE Threads::Threads) + + target_include_directories(${PLUGIN_NAME} PRIVATE + ${CMAKE_SOURCE_DIR}/src + ) +endfunction() + +# Function to add a plugin with dependencies +function(add_3proxy_plugin PLUGIN_NAME) + set(options "") + set(oneValueArgs "") + set(multiValueArgs SOURCES LIBRARIES INCLUDE_DIRS COMPILE_DEFINITIONS LINK_OPTIONS) + + cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(WIN32) + set(PLUGIN_SUFFIX ".dll") + else() + set(PLUGIN_SUFFIX ".ld.so") + endif() + + add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SOURCES}) + + set_target_properties(${PLUGIN_NAME} PROPERTIES + PREFIX "" + SUFFIX ${PLUGIN_SUFFIX} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + + # Always link with Threads + target_link_libraries(${PLUGIN_NAME} PRIVATE Threads::Threads) + + if(PLUGIN_LIBRARIES) + target_link_libraries(${PLUGIN_NAME} PRIVATE ${PLUGIN_LIBRARIES}) + endif() + + if(PLUGIN_INCLUDE_DIRS) + target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDE_DIRS}) + endif() + + if(PLUGIN_COMPILE_DEFINITIONS) + target_compile_definitions(${PLUGIN_NAME} PRIVATE ${PLUGIN_COMPILE_DEFINITIONS}) + endif() + + if(PLUGIN_LINK_OPTIONS) + set_target_properties(${PLUGIN_NAME} PROPERTIES LINK_OPTIONS "${PLUGIN_LINK_OPTIONS}") + endif() + + target_include_directories(${PLUGIN_NAME} PRIVATE + ${CMAKE_SOURCE_DIR}/src + ) +endfunction() diff --git a/src/plugins/FilePlugin/CMakeLists.txt b/src/plugins/FilePlugin/CMakeLists.txt new file mode 100644 index 0000000..b81be48 --- /dev/null +++ b/src/plugins/FilePlugin/CMakeLists.txt @@ -0,0 +1,4 @@ +# FilePlugin +add_3proxy_plugin(FilePlugin + SOURCES FilePlugin.c +) diff --git a/src/plugins/PCREPlugin/CMakeLists.txt b/src/plugins/PCREPlugin/CMakeLists.txt new file mode 100644 index 0000000..f93725c --- /dev/null +++ b/src/plugins/PCREPlugin/CMakeLists.txt @@ -0,0 +1,20 @@ +# PCREPlugin - requires PCRE2 + +if(NOT PCRE2_FOUND) + message(STATUS "PCREPlugin requires PCRE2, skipping") + return() +endif() + +add_3proxy_plugin(PCREPlugin + SOURCES pcre_plugin.c + COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8 +) + +if(TARGET PCRE2::PCRE2) + target_link_libraries(PCREPlugin PRIVATE PCRE2::PCRE2) +else() + target_link_libraries(PCREPlugin PRIVATE ${PCRE2_LIBRARIES}) + if(PCRE2_INCLUDE_DIRS) + target_include_directories(PCREPlugin PRIVATE ${PCRE2_INCLUDE_DIRS}) + endif() +endif() diff --git a/src/plugins/PamAuth/CMakeLists.txt b/src/plugins/PamAuth/CMakeLists.txt new file mode 100644 index 0000000..6143bab --- /dev/null +++ b/src/plugins/PamAuth/CMakeLists.txt @@ -0,0 +1,19 @@ +# PamAuth - requires PAM + +if(NOT PAM_FOUND) + message(STATUS "PamAuth requires PAM, skipping") + return() +endif() + +add_3proxy_plugin(PamAuth + SOURCES pamauth.c +) + +if(TARGET PAM::PAM) + target_link_libraries(PamAuth PRIVATE PAM::PAM) +else() + target_link_libraries(PamAuth PRIVATE ${PAM_LIBRARIES}) + if(PAM_INCLUDE_DIRS) + target_include_directories(PamAuth PRIVATE ${PAM_INCLUDE_DIRS}) + endif() +endif() diff --git a/src/plugins/SSLPlugin/CMakeLists.txt b/src/plugins/SSLPlugin/CMakeLists.txt new file mode 100644 index 0000000..30b4e13 --- /dev/null +++ b/src/plugins/SSLPlugin/CMakeLists.txt @@ -0,0 +1,17 @@ +# SSLPlugin - requires OpenSSL + +if(NOT TARGET OpenSSL::SSL) + message(STATUS "SSLPlugin requires OpenSSL, skipping") + return() +endif() + +add_3proxy_plugin(SSLPlugin + SOURCES + ssl_plugin.c + my_ssl.c + LIBRARIES + OpenSSL::SSL + OpenSSL::Crypto + COMPILE_DEFINITIONS + WITH_SSL +) diff --git a/src/plugins/StringsPlugin/CMakeLists.txt b/src/plugins/StringsPlugin/CMakeLists.txt new file mode 100644 index 0000000..1a7becc --- /dev/null +++ b/src/plugins/StringsPlugin/CMakeLists.txt @@ -0,0 +1,4 @@ +# StringsPlugin +add_3proxy_plugin(StringsPlugin + SOURCES StringsPlugin.c +) diff --git a/src/plugins/TrafficPlugin/CMakeLists.txt b/src/plugins/TrafficPlugin/CMakeLists.txt new file mode 100644 index 0000000..b2342c1 --- /dev/null +++ b/src/plugins/TrafficPlugin/CMakeLists.txt @@ -0,0 +1,4 @@ +# TrafficPlugin +add_3proxy_plugin(TrafficPlugin + SOURCES TrafficPlugin.c +) diff --git a/src/plugins/TransparentPlugin/CMakeLists.txt b/src/plugins/TransparentPlugin/CMakeLists.txt new file mode 100644 index 0000000..2f78811 --- /dev/null +++ b/src/plugins/TransparentPlugin/CMakeLists.txt @@ -0,0 +1,6 @@ +# TransparentPlugin +# Works on Linux (with netfilter), BSD and macOS (without netfilter support) + +add_3proxy_plugin(TransparentPlugin + SOURCES transparent_plugin.c +) diff --git a/src/plugins/WindowsAuthentication/CMakeLists.txt b/src/plugins/WindowsAuthentication/CMakeLists.txt new file mode 100644 index 0000000..7c25f35 --- /dev/null +++ b/src/plugins/WindowsAuthentication/CMakeLists.txt @@ -0,0 +1,10 @@ +# WindowsAuthentication +if(NOT WIN32) + message(STATUS "WindowsAuthentication requires Windows, skipping") + return() +endif() + +add_3proxy_plugin(WindowsAuthentication + SOURCES WindowsAuthentication.c + LIBRARIES advapi32 +) diff --git a/src/plugins/utf8tocp1251/CMakeLists.txt b/src/plugins/utf8tocp1251/CMakeLists.txt new file mode 100644 index 0000000..41b4156 --- /dev/null +++ b/src/plugins/utf8tocp1251/CMakeLists.txt @@ -0,0 +1,4 @@ +# utf8tocp1251 +add_3proxy_plugin(utf8tocp1251 + SOURCES utf8tocp1251.c +)