Skip to content

Only check for pcre2 install if required #2833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
DD mmm YYYY - 2.9.x (to be released)
-------------------

* Only check for pcre2 install if required
[Issue #2833 - @martinhsv]
* Adjustment of previous fix for log messages
[Issue #2832 - @marcstern, @erkia]
* Mark apache error log messages as from mod_security2
Expand Down
106 changes: 56 additions & 50 deletions build/find_pcre2.m4
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,76 @@ AC_DEFUN([CHECK_PCRE2],
AC_ARG_WITH(
pcre2,
[AC_HELP_STRING([--with-pcre2=PATH],[Path to pcre2 prefix or config script])],
, with_pcre2=yes)
, with_pcre2=no)

AS_CASE(["${with_pcre2}"],
[no], [test_paths=],
[yes], [test_paths="/usr/local/libpcre2 /usr/local/pcre2 /usr/local /opt/libpcre2 /opt/pcre2 /opt /usr"],
[test_paths="${with_pcre2}"])

AC_MSG_CHECKING([for libpcre2 config script])
if test "x${with_pcre2}" == "x" || test "x${with_pcre2}" == "xno"; then
AC_MSG_NOTICE([pcre2 not specified; omitting check])
else

for x in ${test_paths}; do
dnl # Determine if the script was specified and use it directly
if test ! -d "$x" -a -e "$x"; then
PCRE2_CONFIG=$x
pcre2_path="no"
break
fi
AC_MSG_CHECKING([for libpcre2 config script])

dnl # Try known config script names/locations
for PCRE2_CONFIG in pcre2-config; do
if test -e "${x}/bin/${PCRE2_CONFIG}"; then
pcre2_path="${x}/bin"
for x in ${test_paths}; do
dnl # Determine if the script was specified and use it directly
if test ! -d "$x" -a -e "$x"; then
PCRE2_CONFIG=$x
pcre2_path="no"
break
elif test -e "${x}/${PCRE2_CONFIG}"; then
pcre2_path="${x}"
fi

dnl # Try known config script names/locations
for PCRE2_CONFIG in pcre2-config; do
if test -e "${x}/bin/${PCRE2_CONFIG}"; then
pcre2_path="${x}/bin"
break
elif test -e "${x}/${PCRE2_CONFIG}"; then
pcre2_path="${x}"
break
else
pcre2_path=""
fi
done
if test -n "$pcre2_path"; then
break
else
pcre2_path=""
fi
done
if test -n "$pcre2_path"; then
break
fi
done

if test -n "${pcre2_path}"; then
if test "${pcre2_path}" != "no"; then
PCRE2_CONFIG="${pcre2_path}/${PCRE2_CONFIG}"
if test -n "${pcre2_path}"; then
if test "${pcre2_path}" != "no"; then
PCRE2_CONFIG="${pcre2_path}/${PCRE2_CONFIG}"
fi
AC_MSG_RESULT([${PCRE2_CONFIG}])
PCRE2_VERSION="`${PCRE2_CONFIG} --version`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 VERSION: $PCRE2_VERSION); fi
PCRE2_CFLAGS="`${PCRE2_CONFIG} --cflags`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 CFLAGS: $PCRE2_CFLAGS); fi
PCRE2_LDADD="`${PCRE2_CONFIG} --libs8`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 LDADD: $PCRE2_LDADD); fi
PCRE_LD_PATH="/`${PCRE2_CONFIG} --libs8 | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 PCRE_LD_PATH: $PCRE_LD_PATH); fi
else
AC_MSG_RESULT([no])
fi
AC_MSG_RESULT([${PCRE2_CONFIG}])
PCRE2_VERSION="`${PCRE2_CONFIG} --version`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 VERSION: $PCRE2_VERSION); fi
PCRE2_CFLAGS="`${PCRE2_CONFIG} --cflags`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 CFLAGS: $PCRE2_CFLAGS); fi
PCRE2_LDADD="`${PCRE2_CONFIG} --libs8`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 LDADD: $PCRE2_LDADD); fi
PCRE_LD_PATH="/`${PCRE2_CONFIG} --libs8 | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre2 PCRE_LD_PATH: $PCRE_LD_PATH); fi
else
AC_MSG_RESULT([no])
fi

AC_SUBST(PCRE2_CONFIG)
AC_SUBST(PCRE2_VERSION)
AC_SUBST(PCRE2_CPPFLAGS)
AC_SUBST(PCRE2_CFLAGS)
AC_SUBST(PCRE2_LDFLAGS)
AC_SUBST(PCRE2_LDADD)
AC_SUBST(PCRE_LD_PATH)
AC_SUBST(PCRE2_CONFIG)
AC_SUBST(PCRE2_VERSION)
AC_SUBST(PCRE2_CPPFLAGS)
AC_SUBST(PCRE2_CFLAGS)
AC_SUBST(PCRE2_LDFLAGS)
AC_SUBST(PCRE2_LDADD)
AC_SUBST(PCRE_LD_PATH)

if test -z "${PCRE2_VERSION}"; then
AC_MSG_NOTICE([*** pcre2 library not found.])
else
AC_MSG_NOTICE([using pcre2 v${PCRE2_VERSION}])
PCRE2_CFLAGS="-DWITH_PCRE2 ${PCRE2_CFLAGS}"
ifelse([$1], , , $1)
fi
if test -z "${PCRE2_VERSION}"; then
AC_MSG_NOTICE([*** pcre2 library not found.])
ifelse([$2], , AC_MSG_ERROR([pcre2 library is required]), $2)
else
AC_MSG_NOTICE([using pcre2 v${PCRE2_VERSION}])
PCRE2_CFLAGS="-DWITH_PCRE2 ${PCRE2_CFLAGS}"
ifelse([$1], , , $1)
fi
fi
])