diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-09 11:26:16 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-09 11:26:16 +0000 |
commit | cbb129cba4aa367757fb0e0962ef6287b2ddd8c5 (patch) | |
tree | dae8a9e9aa4c29f450f266f5bb6e440272ea526f | |
parent | eff7d62249244bcb64ca89cd2e57538f640cb1e8 (diff) | |
download | rspamd-cbb129cba4aa367757fb0e0962ef6287b2ddd8c5.tar.gz rspamd-cbb129cba4aa367757fb0e0962ef6287b2ddd8c5.zip |
Add pcre2 detection
-rw-r--r-- | CMakeLists.txt | 45 | ||||
-rw-r--r-- | config.h.in | 1 |
2 files changed, 35 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 24f380560..ae950659d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ OPTION(ENABLE_SNOWBALL "Enable snowball stemmer [default: ON]" OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]" OFF) OPTION(ENABLE_HYPERSCAN "Enable hyperscan for fast regexp processing [default: OFF]" OFF) OPTION(ENABLE_FANN "Enable fann for neural network plugin [default: OFF]" OFF) +OPTION(ENABLE_PCRE2 "Enable pcre2 instead of pcre [default: OFF]" OFF) INCLUDE(FindArch.cmake) TARGET_ARCHITECTURE(ARCH) @@ -66,6 +67,12 @@ ELSE() MESSAGE(STATUS "Hyperscan support is possible only for x86_64 architecture") SET(ENABLE_HYPERSCAN "OFF") ENDIF() + +IF(ENABLE_PCRE2 MATCHES "ON") + SET(WITH_PCRE2 1) + # For utf8 API + LIST(APPEND CMAKE_REQUIRED_DEFINITIONS "-DPCRE2_CODE_UNIT_WIDTH=8") +ENDIF() # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") @@ -623,8 +630,14 @@ ENDIF(ENABLE_LUAJIT MATCHES "ON") ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h INCLUDE_SUFFIXES include/glib ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28) -ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre - ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3) + +IF(ENABLE_PCRE2 MATCHES "ON") + ProcessPackage(PCRE LIBRARY pcre2 INCLUDE pcre2.h INCLUDE_SUFFIXES include/pcre2 + ROOT ${PCRE_ROOT_DIR} MODULES pcre2 libpcre2 libpcre2-8) +ELSE() + ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre + ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3) +ENDIF() ProcessPackage(GMIME LIBRARY gmime-2.6 gmime-2.4 gmime-2.2 gmime-2 INCLUDE gmime.h INCLUDE_SUFFIXES include/gmime ROOT ${GMIME_ROOT_DIR} MODULES gmime-2.6 gmime-2.4 gmime-2.0) ProcessPackage(LIBEVENT LIBRARY event INCLUDE event.h INCLUDE_SUFFIXES include/event @@ -660,13 +673,6 @@ IF(GMIME2_VERSION VERSION_GREATER "2.4.0" OR NOT GMIME2_VERSION) SET(GMIME24 1) ENDIF() -LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") -IF(PCRE_LIBRARY_PATH) - SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${PCRE_LIBRARY_PATH};-lpcre") -ELSE(PCRE_LIBRARY_PATH) - SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre") -ENDIF(PCRE_LIBRARY_PATH) - IF(ENABLE_HIREDIS MATCHES "ON") ADD_SUBDIRECTORY(contrib/hiredis) SET(WITH_HIREDIS 1) @@ -872,12 +878,29 @@ CHECK_SYMBOL_EXISTS(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRI CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD) CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID) CHECK_SYMBOL_EXISTS(nftw "sys/types.h;ftw.h" HAVE_NFTW) -CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT) +IF(ENABLE_PCRE2 MATCHES "ON") + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") + CHECK_SYMBOL_EXISTS(PCRE2_CONFIG_JIT "pcre2.h" HAVE_PCRE_JIT) +ELSE() + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") + CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT) +ENDIF() CHECK_SYMBOL_EXISTS(SOCK_SEQPACKET "sys/types.h;sys/socket.h" HAVE_SOCK_SEQPACKET) CHECK_SYMBOL_EXISTS(I_SETSIG "sys/types.h;sys/ioctl.h" HAVE_SETSIG) CHECK_SYMBOL_EXISTS(O_ASYNC "sys/types.h;sys/fcntl.h" HAVE_OASYNC) CHECK_SYMBOL_EXISTS(O_NOFOLLOW "sys/types.h;sys/fcntl.h" HAVE_ONOFOLLOW) +IF(ENABLE_PCRE2 MATCHES "ON") + IF(HAVE_PCRE_JIT) + SET(HAVE_PCRE_JIT_FAST 1) + ENDIF() +ELSE() + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}") + IF(PCRE_LIBRARY_PATH) + SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${PCRE_LIBRARY_PATH};${PCRE_LIBRARY}") + ELSE(PCRE_LIBRARY_PATH) + SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre") + ENDIF(PCRE_LIBRARY_PATH) # Some PCRE implementations are lacking of pcre_jit_exec fast path SET(_PCRE_FAST_TEST " #include \"pcre.h\" @@ -898,13 +921,13 @@ int main (void) return rc; } ") - CHECK_C_SOURCE_COMPILES("${_PCRE_FAST_TEST}" HAVE_PCRE_JIT_FAST) IF(HAVE_PCRE_JIT_FAST) MESSAGE(STATUS "pcre_jit_exec is supported") ELSE(HAVE_PCRE_JIT_FAST) MESSAGE(STATUS "pcre_jit_exec is -NOT- supported") ENDIF(HAVE_PCRE_JIT_FAST) +ENDIF() FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c " #include <pthread.h> diff --git a/config.h.in b/config.h.in index fbe3bb37b..bae4efdb9 100644 --- a/config.h.in +++ b/config.h.in @@ -124,6 +124,7 @@ #cmakedefine WITH_HYPERSCAN 1 #cmakedefine WITH_JUDY 1 #cmakedefine WITH_LUA 1 +#cmakedefine WITH_PCRE2 1 #cmakedefine WITH_PROFILER 1 #cmakedefine WITH_SNOWBALL 1 #cmakedefine WITH_SQLITE 1 |