diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 19aa691..163630d 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -50,12 +50,15 @@ jobs: - name: make clean MacOS if: ${{ startsWith(matrix.target, 'macos') }} run: make -f Makefile.FreeBSD clean + - name: install Windows libraries + if: ${{ startsWith(matrix.target, 'windows') }} + run: vcpkg install pcre2:x64-windows && c:\msys64\usr\bin\pacman.exe -S --noconfirm mingw-w64-x86_64-pcre2 mingw-w64-x86_64-openssl - name: make Windows if: ${{ startsWith(matrix.target, 'windows') }} run: make -f Makefile.win env: - LIBS: '-L "c:/program files/openssl/lib/VC/x64/MT"' - CFLAGS: '-I "c:/program files/openssl/include"' + LDFLAGS: '-L "c:/msys64/mingw64/lib"' + CFLAGS: '-I "c:/msys64/mingw64/include"' - name: make clean Windows if: ${{ startsWith(matrix.target, 'windows') }} run: make -f Makefile.win clean @@ -69,11 +72,8 @@ jobs: call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" D: cd "D:/a/3proxy/3proxy" - vcpkg install pcre2:x64-windows mkdir bin64 set "LIB=%LIB%;c:/program files/openssl/lib/VC/x64/MT;c:/vcpkg/installed/x64-windows/lib" + set "INCLUDE=%INCLUDE%;c:/program files/openssl/include;c:/vcpkg/installed/x64-windows/include" nmake /F Makefile.msvc64 nmake /F Makefile.msvc64 clean - env: - CFLAGS: '-I "c:/program files/openssl/include" -I "c:/vcpkg/installed/x64-windows/include"' - diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index 3854b3a..49c6bae 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -15,8 +15,8 @@ LDFLAGS += -pthread -fno-strict-aliasing # -ldl or -lld may be required for some platforms DCFLAGS ?= -fPIC DLFLAGS ?= -shared -LIBS ?= DLSUFFICS = .so +LIBS ?= LIBSPREFIX = -l LIBSSUFFIX = LNOUT = -o @@ -32,6 +32,7 @@ MAKEFILE = Makefile.FreeBSD PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin OPENSSL_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l crypto -l ssl -o testssl - 2>/dev/null && rm testssl && echo true||echo false) ifeq ($(OPENSSL_CHECK), true) + LIBS += -l crypto -l ssl PLUGINS += SSLPlugin endif PAM_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l pam -o testpam - 2>/dev/null && rm testpam && echo true||echo false) diff --git a/Makefile.Linux b/Makefile.Linux index 7681b4f..95866db 100644 --- a/Makefile.Linux +++ b/Makefile.Linux @@ -14,7 +14,7 @@ CFLAGS := -g -fPIC -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -D_GNU_SOU COUT = -o LN ?= ${CC} DCFLAGS ?= -LDFLAGS ?= -fPIC -O2 -fno-strict-aliasing -pthread +LDFLAGS := -fPIC -O2 -fno-strict-aliasing -pthread $(LDFLAGS) DLFLAGS ?= -shared DLSUFFICS = .ld.so # -lpthreads may be reuqired on some platforms instead of -pthreads @@ -38,6 +38,7 @@ LIBS ?= -ldl PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin OPENSSL_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l crypto -l ssl -o testssl - 2>/dev/null && rm testssl && echo true||echo false) ifeq ($(OPENSSL_CHECK), true) + LIBS += -l crypto -l ssl PLUGINS += SSLPlugin endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l pcre2-8 -o testpcre - 2>/dev/null && rm testpcre && echo true||echo false) diff --git a/Makefile.msvc b/Makefile.msvc index 7d8a63e..5affb31 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -14,7 +14,8 @@ LN = link LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 DLFLAGS = /DLL DLSUFFICS = .dll -LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib Crypt32.lib +LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib Crypt32.lib libcrypto.lib libssl.lib +LIBSOLD = libeay32MT.lib ssleay32MT.lib LIBSPREFIX = LIBSSUFFIX = .lib LIBEXT = .lib diff --git a/Makefile.msvc64 b/Makefile.msvc64 index dc8a00a..3a2e8b2 100644 --- a/Makefile.msvc64 +++ b/Makefile.msvc64 @@ -16,7 +16,8 @@ LN = link LDFLAGS = /nologo /subsystem:console /incremental:no /machine:x64 DLFLAGS = /DLL DLSUFFICS = .dll -LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib Crypt32.lib $(LIBS) +LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib Crypt32.lib libcrypto.lib libssl.lib $(LIBS) +LIBSOLD = libeay32.lib ssleay32.lib LIBSPREFIX = LIBSSUFFIX = .lib LIBEXT = .lib diff --git a/Makefile.msvcARM64 b/Makefile.msvcARM64 index bda64bc..a892c0d 100644 --- a/Makefile.msvcARM64 +++ b/Makefile.msvcARM64 @@ -14,7 +14,7 @@ LN = link LDFLAGS = /nologo /subsystem:console /incremental:no /machine:arm64 DLFLAGS = /DLL DLSUFFICS = .dll -LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib +LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib libcrypto.lib libssl.lib LIBSOLD = LIBSPREFIX = LIBSSUFFIX = .lib diff --git a/Makefile.openwrt-mips b/Makefile.openwrt-mips index 2181bb2..0cbe8f0 100644 --- a/Makefile.openwrt-mips +++ b/Makefile.openwrt-mips @@ -31,11 +31,14 @@ TYPECOMMAND = cat COMPATLIBS = MAKEFILE = Makefile.openwrt-mips # PamAuth requires libpam, you may require pam-devel package to be installed +# SSLPlugin requires -lcrypto -lssl +#LIBS = -lcrypto -lssl -ldl LIBS ?= -ldl #PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin OPENSSL_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l crypto -l ssl -o testssl - 2>/dev/null && rm testssl && echo true||echo false) ifeq ($(OPENSSL_CHECK), true) + LIBS += -l crypto -l ssl PLUGINS += SSLPlugin endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l pcre2-8 -o testpcre - 2>/dev/null && rm testpcre && echo true||echo false) diff --git a/Makefile.unix b/Makefile.unix index 7b2415b..6082a79 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -36,6 +36,7 @@ MAKEFILE = Makefile.unix PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin OPENSSL_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l crypto -l ssl -o testssl - 2>/dev/null && rm testssl && echo true||echo false) ifeq ($(OPENSSL_CHECK), true) + LIBS += -l crypto -l ssl PLUGINS += SSLPlugin endif PAM_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | cc -x c $(CFLAGS) $(LDFLAGS) -l pam -o testpam - 2>/dev/null && rm testpam && echo true||echo false) diff --git a/Makefile.win b/Makefile.win index a7fa6b5..2980f8c 100644 --- a/Makefile.win +++ b/Makefile.win @@ -13,12 +13,12 @@ CC ?= gcc CFLAGS := -O2 -s -c -mthreads -DWITH_STD_MALLOC -DWITH_WSAPOLL $(CFLAGS) COUT = -o LN ?= $(CC) -LDFLAGS ?= -O2 -s -mthreads +LDFLAGS := -O2 -s -mthreads $(LDFLAGS) DLFLAGS ?= -shared DLSUFFICS = .dll LIBS := -lws2_32 -lodbc32 -ladvapi32 -luser32 $(LIBS) LIBSPREFIX = -l -LIBSSUFFIX = +LIBSSUFFIX = LNOUT = -o EXESUFFICS = .exe OBJSUFFICS = .o @@ -38,13 +38,14 @@ AFTERCLEAN = (find . -type f -name "*.o" -delete && find . -type f -name "*.res" ifndef OPENSSL_CHECK OPENSSL_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d '\\\\' | cc -x c $(CFLAGS) $(LDFLAGS) -l crypto -l ssl -o testssl - 2>/dev/null && rm testssl && echo true||echo false) ifeq ($(OPENSSL_CHECK), true) + LIBS += -l crypto -l ssl PLUGINS += SSLPlugin endif PAM_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d '\\\\' | cc -x c $(CFLAGS) $(LDFLAGS) -l pam -o testpam - 2>/dev/null && rm testpam && echo true||echo false) ifeq ($(PAM_CHECK), true) PLUGINS += PamAuth endif -PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n#include \\n int main(){return 0;}" | tr -d '\\\\' | cc -x c $(CFLAGS) $(LDFLAGS) -l pcre2-8 -o testpcre - 2>/dev/null && rm testpcre && echo true||echo false) +PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n#include \\n int main(){return 0;}" | tr -d '\\\\' | cc -x c $(CFLAGS) $(LDFLAGS) -lpcre2-8 -o testpcre - 2>/dev/null && rm testpcre && echo true||echo false) ifeq ($(PCRE_CHECK), true) PLUGINS += PCREPlugin endif diff --git a/src/plugins/PCREPlugin/pcre_plugin.c b/src/plugins/PCREPlugin/pcre_plugin.c index 346aa77..1d09203 100644 --- a/src/plugins/PCREPlugin/pcre_plugin.c +++ b/src/plugins/PCREPlugin/pcre_plugin.c @@ -8,6 +8,7 @@ #include "../../structures.h" #include #define PCRE2_CODE_UNIT_WIDTH 8 +#define PCRE2_STATIC #include #ifdef __cplusplus diff --git a/src/plugins/SSLPlugin/Makefile.inc b/src/plugins/SSLPlugin/Makefile.inc index 5f2717e..1afc984 100644 --- a/src/plugins/SSLPlugin/Makefile.inc +++ b/src/plugins/SSLPlugin/Makefile.inc @@ -10,5 +10,5 @@ my_ssl$(OBJSUFFICS): my_ssl.c $(BUILDDIR)SSLPlugin$(DLSUFFICS): ssl_plugin$(OBJSUFFICS) my_ssl$(OBJSUFFICS) - $(LN) $(LNOUT)../../$(BUILDDIR)SSLPlugin$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) ssl_plugin$(OBJSUFFICS) my_ssl$(OBJSUFFICS) $(LIBSPREFIX)crypto$(LIBSSUFFIX) $(LIBSPREFIX)ssl$(LIBSSUFFIX) + $(LN) $(LNOUT)../../$(BUILDDIR)SSLPlugin$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) ssl_plugin$(OBJSUFFICS) my_ssl$(OBJSUFFICS) $(LIBS) \ No newline at end of file