The original PCRE is now end-of-life, and no longer actively maintained.
Implements #2013.
OPTION(ENABLE_LIBXML2 "Enable the use of the system libxml2 library if found" ON)
OPTION(ENABLE_EXPAT "Enable the use of the system EXPAT library if found" ON)
OPTION(ENABLE_PCREPOSIX "Enable the use of the system PCREPOSIX library if found" ON)
+OPTION(ENABLE_PCRE2POSIX "Enable the use of the system PCRE2POSIX library if found" ON)
OPTION(ENABLE_LIBGCC "Enable the use of the system LibGCC library if found" ON)
# CNG is used for encrypt/decrypt Zip archives on Windows.
OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON)
MARK_AS_ADVANCED(CLEAR LIBGCC_LIBRARIES)
ENDIF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$")
+IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCRE2POSIX)$")
+ #
+ # If requested, try finding library for PCRE2POSIX
+ #
+ IF(ENABLE_LIBGCC)
+ FIND_PACKAGE(LIBGCC)
+ ELSE()
+ MESSAGE(FATAL_ERROR "libgcc not found.")
+ SET(LIBGCC_FOUND FALSE) # Override cached value
+ ENDIF()
+ IF(ENABLE_PCRE2POSIX)
+ FIND_PACKAGE(PCRE2POSIX)
+ ELSE()
+ SET(PCRE2POSIX_FOUND FALSE) # Override cached value
+ ENDIF()
+ IF(PCRE2POSIX_FOUND)
+ INCLUDE_DIRECTORIES(${PCRE2_INCLUDE_DIR})
+ LIST(APPEND ADDITIONAL_LIBS ${PCRE2POSIX_LIBRARIES})
+ # Test if a macro is needed for the library.
+ TRY_MACRO_FOR_LIBRARY(
+ "${PCRE2_INCLUDE_DIR}" "${PCRE2POSIX_LIBRARIES}"
+ COMPILES
+ "#include <pcre2posix.h>\nint main() {regex_t r;return pcre2_regcomp(&r, \"\", 0);}"
+ "WITHOUT_PCRE2_STATIC;PCRE2_STATIC")
+ IF(NOT WITHOUT_PCRE2_STATIC AND PCRE2_STATIC)
+ ADD_DEFINITIONS(-DPCRE2_STATIC)
+ ELSEIF(NOT WITHOUT_PCRE2_STATIC AND NOT PCRE2_STATIC AND PCRE2_FOUND)
+ # Determine if pcre2 static libraries are to be used.
+ LIST(APPEND ADDITIONAL_LIBS ${PCRE2_LIBRARIES})
+ SET(TMP_LIBRARIES ${PCRE2POSIX_LIBRARIES} ${PCRE2_LIBRARIES})
+ MESSAGE(STATUS "trying again with -lpcre2-8 included")
+ TRY_MACRO_FOR_LIBRARY(
+ "${PCRE2_INCLUDE_DIR}" "${TMP_LIBRARIES}"
+ COMPILES
+ "#include <pcre2posix.h>\nint main() {regex_t r;return pcre2_regcomp(&r, \"\", 0);}"
+ "WITHOUT_PCRE2_STATIC;PCRE2_STATIC")
+ IF(NOT WITHOUT_PCRE2_STATIC AND PCRE2_STATIC)
+ ADD_DEFINITIONS(-DPCRE2_STATIC)
+ ELSEIF(NOT WITHOUT_PCRE2_STATIC AND NOT PCRE2_STATIC AND MSVC AND LIBGCC_FOUND)
+ # When doing a Visual Studio build using pcre2 static libraries
+ # built using the mingw toolchain, -lgcc is needed to resolve
+ # ___chkstk_ms.
+ MESSAGE(STATUS "Visual Studio build detected, trying again with -lgcc included")
+ LIST(APPEND ADDITIONAL_LIBS ${LIBGCC_LIBRARIES})
+ SET(TMP_LIBRARIES ${PCRE2POSIX_LIBRARIES} ${PCRE2_LIBRARIES} ${LIBGCC_LIBRARIES})
+ TRY_MACRO_FOR_LIBRARY(
+ "${PCRE2_INCLUDE_DIR}" "${TMP_LIBRARIES}"
+ COMPILES
+ "#include <pcre2posix.h>\nint main() {regex_t r;return pcre2_regcomp(&r, \"\", 0);}"
+ "WITHOUT_PCRE2_STATIC;PCRE2_STATIC")
+ IF(NOT WITHOUT_PCRE2_STATIC AND PCRE2_STATIC)
+ ADD_DEFINITIONS(-DPCRE2_STATIC)
+ ENDIF(NOT WITHOUT_PCRE2_STATIC AND PCRE2_STATIC)
+ ENDIF(NOT WITHOUT_PCRE2_STATIC AND PCRE2_STATIC)
+ ENDIF(NOT WITHOUT_PCRE2_STATIC AND PCRE2_STATIC)
+ ENDIF(PCRE2POSIX_FOUND)
+ MARK_AS_ADVANCED(CLEAR PCRE2_INCLUDE_DIR)
+ MARK_AS_ADVANCED(CLEAR PCRE2POSIX_LIBRARIES)
+ MARK_AS_ADVANCED(CLEAR PCRE2_LIBRARIES)
+ MARK_AS_ADVANCED(CLEAR LIBGCC_LIBRARIES)
+ENDIF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCRE2POSIX)$")
+
#
# Check functions
#
--- /dev/null
+# - Find pcre2posix\r
+# Find the native PCRE2-8 and PCRE2-POSIX include and libraries\r
+#\r
+# PCRE2_INCLUDE_DIR - where to find pcre2posix.h, etc.\r
+# PCRE2POSIX_LIBRARIES - List of libraries when using libpcre2-posix.\r
+# PCRE2_LIBRARIES - List of libraries when using libpcre2-8.\r
+# PCRE2POSIX_FOUND - True if libpcre2-posix found.\r
+# PCRE2_FOUND - True if libpcre2-8 found.\r
+\r
+IF (PCRE2_INCLUDE_DIR)\r
+ # Already in cache, be silent\r
+ SET(PCRE2_FIND_QUIETLY TRUE)\r
+ENDIF (PCRE2_INCLUDE_DIR)\r
+\r
+FIND_PATH(PCRE2_INCLUDE_DIR pcre2posix.h)\r
+FIND_LIBRARY(PCRE2POSIX_LIBRARY NAMES pcre2-posix libpcre2-posix pcre2-posix-static)\r
+FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8 libpcre2-8 pcre2-8-static)\r
+\r
+# handle the QUIETLY and REQUIRED arguments and set PCRE2POSIX_FOUND to TRUE if \r
+# all listed variables are TRUE\r
+INCLUDE(FindPackageHandleStandardArgs)\r
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2POSIX DEFAULT_MSG PCRE2POSIX_LIBRARY PCRE2_INCLUDE_DIR)\r
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY)\r
+\r
+IF(PCRE2POSIX_FOUND)\r
+ SET(PCRE2POSIX_LIBRARIES ${PCRE2POSIX_LIBRARY})\r
+ SET(HAVE_LIBPCRE2POSIX 1)\r
+ SET(HAVE_PCRE2POSIX_H 1)\r
+ENDIF(PCRE2POSIX_FOUND)\r
+\r
+IF(PCRE2_FOUND)\r
+ SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})\r
+ SET(HAVE_LIBPCRE2 1)\r
+ENDIF(PCRE2_FOUND)\r
/* Define to 1 if you have the `pcreposix' library (-lpcreposix). */
#cmakedefine HAVE_LIBPCREPOSIX 1
+/* Define to 1 if you have the `pcre2-8' library (-lpcre2-8). */
+#cmakedefine HAVE_LIBPCRE2 1
+
+/* Define to 1 if you have the `pcreposix' library (-lpcre2posix). */
+#cmakedefine HAVE_LIBPCRE2POSIX 1
+
/* Define to 1 if you have the `xml2' library (-lxml2). */
#cmakedefine HAVE_LIBXML2 1
/* Define to 1 if you have the <pcreposix.h> header file. */
#cmakedefine HAVE_PCREPOSIX_H 1
+/* Define to 1 if you have the <pcre2posix.h> header file. */
+#cmakedefine HAVE_PCRE2POSIX_H 1
+
/* Define to 1 if you have the `pipe' function. */
#cmakedefine HAVE_PIPE 1
AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
+ AS_HELP_STRING([--enable-posix-regex-lib=libpcre2posix], [use libpcre2-posix POSIX regular expression support])
AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
[], [enable_posix_regex_lib=auto])
posix_regex_lib_found=1
fi
fi
+if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcre2posix"); then
+ AC_CHECK_HEADERS([pcre2posix.h])
+ AC_CHECK_LIB(pcre2-posix,regcomp)
+ if test "x$ac_cv_lib_pcre2posix_regcomp" != xyes; then
+ AC_MSG_NOTICE(trying libpcre2posix check again with libpcre2-8)
+ unset ac_cv_lib_pcre2posix_regcomp
+ AC_CHECK_LIB(pcre2,pcre2_regexec)
+ AC_CHECK_LIB(pcre2-posix,pcre2_regcomp)
+ if test "x$ac_cv_lib_pcre2_pcre_exec" = xyes && test "x$ac_cv_lib_pcre2posix_regcomp" = xyes; then
+ AC_MSG_CHECKING(if PCRE2_STATIC needs to be defined)
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(#include <pcre2posix.h>
+ int main() { return pcre2_regcomp(NULL, NULL, 0); })],
+ [without_pcre2_static=yes],
+ [without_pcre2_static=no])
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(#define PCRE2_STATIC
+ #include <pcre2posix.h>
+ int main() { return pcre2_regcomp(NULL, NULL, 0); })],
+ [with_pcre2_static=yes],
+ [with_pcre2_static=no])
+ if test "x$without_pcre2_static" != xyes && test "x$with_pcre2_static" = xyes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([PCRE2_STATIC], [1], [Define to 1 if PCRE2_STATIC needs to be defined.])
+ elif test "x$without_pcre2_static" = xyes || test "x$with_pcre2_static" = xyes; then
+ AC_MSG_RESULT(no)
+ fi
+ posix_regex_lib_found=1
+ fi
+ else
+ posix_regex_lib_found=1
+ fi
+fi
# TODO: Give the user the option of using a pre-existing system
# libarchive. This will define HAVE_LIBARCHIVE which will cause
/* Define to 1 if you have the `pcreposix' library (-lpcreposix). */
/* #undef HAVE_LIBPCREPOSIX */
+/* Define to 1 if you have the `pcre2-8' library (-lpcre2-8). */
+/* #undef HAVE_LIBPCRE2 */
+
+/* Define to 1 if you have the `pcre2-posix' library (-lpcre2-posix). */
+/* #undef HAVE_LIBPCRE2POSIX */
+
/* Define to 1 if you have the `regex' library (-lregex). */
/* #undef HAVE_LIBREGEX */
/* Define to 1 if you have the <pcreposix.h> header file. */
/* #undef HAVE_PCREPOSIX_H */
+/* Define to 1 if you have the <pcre2posix.h> header file. */
+/* #undef HAVE_PCRE2POSIX_H */
+
/* Define to 1 if you have the `pipe' function. */
/* #undef HAVE_PIPE */
bsdtar->extract_flags |= ARCHIVE_EXTRACT_SPARSE;
break;
case 's': /* NetBSD pax-as-tar */
-#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
+#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) || defined(HAVE_PCRE2POSIX_H)
add_substitution(bsdtar, bsdtar->argument);
#else
lafe_warnc(0,
}
archive_match_free(bsdtar->matching);
-#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
+#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) || defined(HAVE_PCRE2POSIX_H)
cleanup_substitution(bsdtar);
#endif
cset_free(bsdtar->cset);
#include "bsdtar_platform.h"
-#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
+#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) || defined(HAVE_PCRE2POSIX_H)
#include "bsdtar.h"
#include <errno.h>
-#ifdef HAVE_PCREPOSIX_H
+#if defined(HAVE_PCREPOSIX_H)
#include <pcreposix.h>
+#elif defined(HAVE_PCRE2POSIX_H)
+#include <pcre2posix.h>
#else
#include <regex.h>
#endif
}
free(subst);
}
-#endif /* defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) */
+#endif /* defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) || defined(HAVE_PCRE2POSIX_H) */