File: find_pcre2.m4

package info (click to toggle)
modsecurity-apache 2.9.7-1%2Bdeb12u1
  • links: PTS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 10,440 kB
  • sloc: ansic: 51,935; sh: 4,516; perl: 2,340; cpp: 1,930; makefile: 620; xml: 6
file content (93 lines) | stat: -rw-r--r-- 2,867 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
dnl Check for PCRE2 Libraries
dnl CHECK_PCRE2(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
dnl Sets:
dnl  PCRE2_CFLAGS
dnl  PCRE2_LIBS

PCRE2_CONFIG=""
PCRE2_VERSION=""
PCRE2_CPPFLAGS=""
PCRE2_CFLAGS=""
PCRE2_LDFLAGS=""
PCRE2_LDADD=""
PCRE_LD_PATH=""

AC_DEFUN([CHECK_PCRE2],
[dnl

AC_ARG_WITH(
    pcre2,
    [AC_HELP_STRING([--with-pcre2=PATH],[Path to pcre2 prefix or config script])],
    , 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}"])

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

    AC_MSG_CHECKING([for libpcre2 config script])

    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

        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
        fi
    done

    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_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.])
        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
])