@@ -18,70 +18,76 @@ AC_DEFUN([CHECK_PCRE2],
1818AC_ARG_WITH (
1919 pcre2 ,
2020 [ AC_HELP_STRING ([ --with-pcre2=PATH] ,[ Path to pcre2 prefix or config script] )] ,
21- , with_pcre2=yes )
21+ , with_pcre2=no )
2222
2323AS_CASE ( [ "${with_pcre2}"] ,
2424 [ no] , [ test_paths=] ,
2525 [ yes] , [ test_paths="/usr/local/libpcre2 /usr/local/pcre2 /usr/local /opt/libpcre2 /opt/pcre2 /opt /usr"] ,
2626 [ test_paths="${with_pcre2}"] )
2727
28- AC_MSG_CHECKING ( [ for libpcre2 config script] )
28+ if test "x${with_pcre2}" == "x" || test "x${with_pcre2}" == "xno"; then
29+ AC_MSG_NOTICE ( [ pcre2 not specified; omitting check] )
30+ else
2931
30- for x in ${test_paths}; do
31- dnl # Determine if the script was specified and use it directly
32- if test ! -d "$x" -a -e "$x"; then
33- PCRE2_CONFIG=$x
34- pcre2_path="no"
35- break
36- fi
32+ AC_MSG_CHECKING ( [ for libpcre2 config script] )
3733
38- dnl # Try known config script names/locations
39- for PCRE2_CONFIG in pcre2-config; do
40- if test -e "${x}/bin/${PCRE2_CONFIG}"; then
41- pcre2_path="${x}/bin"
34+ for x in ${test_paths}; do
35+ dnl # Determine if the script was specified and use it directly
36+ if test ! -d "$x" -a -e "$x"; then
37+ PCRE2_CONFIG=$x
38+ pcre2_path="no"
4239 break
43- elif test -e "${x}/${PCRE2_CONFIG}"; then
44- pcre2_path="${x}"
40+ fi
41+
42+ dnl # Try known config script names/locations
43+ for PCRE2_CONFIG in pcre2-config; do
44+ if test -e "${x}/bin/${PCRE2_CONFIG}"; then
45+ pcre2_path="${x}/bin"
46+ break
47+ elif test -e "${x}/${PCRE2_CONFIG}"; then
48+ pcre2_path="${x}"
49+ break
50+ else
51+ pcre2_path=""
52+ fi
53+ done
54+ if test -n "$pcre2_path"; then
4555 break
46- else
47- pcre2_path=""
4856 fi
4957 done
50- if test -n "$pcre2_path"; then
51- break
52- fi
53- done
5458
55- if test -n "${pcre2_path}"; then
56- if test "${pcre2_path}" != "no"; then
57- PCRE2_CONFIG="${pcre2_path}/${PCRE2_CONFIG}"
59+ if test -n "${pcre2_path}"; then
60+ if test "${pcre2_path}" != "no"; then
61+ PCRE2_CONFIG="${pcre2_path}/${PCRE2_CONFIG}"
62+ fi
63+ AC_MSG_RESULT ( [ ${PCRE2_CONFIG}] )
64+ PCRE2_VERSION="`${PCRE2_CONFIG} --version`"
65+ if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 VERSION: $PCRE2_VERSION ) ; fi
66+ PCRE2_CFLAGS="`${PCRE2_CONFIG} --cflags`"
67+ if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 CFLAGS: $PCRE2_CFLAGS ) ; fi
68+ PCRE2_LDADD="`${PCRE2_CONFIG} --libs8`"
69+ if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 LDADD: $PCRE2_LDADD ) ; fi
70+ PCRE_LD_PATH="/`${PCRE2_CONFIG} --libs8 | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`"
71+ if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 PCRE_LD_PATH: $PCRE_LD_PATH ) ; fi
72+ else
73+ AC_MSG_RESULT ( [ no] )
5874 fi
59- AC_MSG_RESULT ( [ ${PCRE2_CONFIG}] )
60- PCRE2_VERSION="`${PCRE2_CONFIG} --version`"
61- if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 VERSION: $PCRE2_VERSION ) ; fi
62- PCRE2_CFLAGS="`${PCRE2_CONFIG} --cflags`"
63- if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 CFLAGS: $PCRE2_CFLAGS ) ; fi
64- PCRE2_LDADD="`${PCRE2_CONFIG} --libs8`"
65- if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 LDADD: $PCRE2_LDADD ) ; fi
66- PCRE_LD_PATH="/`${PCRE2_CONFIG} --libs8 | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`"
67- if test "$verbose_output" -eq 1; then AC_MSG_NOTICE ( pcre2 PCRE_LD_PATH: $PCRE_LD_PATH ) ; fi
68- else
69- AC_MSG_RESULT ( [ no] )
70- fi
7175
72- AC_SUBST ( PCRE2_CONFIG )
73- AC_SUBST ( PCRE2_VERSION )
74- AC_SUBST ( PCRE2_CPPFLAGS )
75- AC_SUBST ( PCRE2_CFLAGS )
76- AC_SUBST ( PCRE2_LDFLAGS )
77- AC_SUBST ( PCRE2_LDADD )
78- AC_SUBST ( PCRE_LD_PATH )
76+ AC_SUBST ( PCRE2_CONFIG )
77+ AC_SUBST ( PCRE2_VERSION )
78+ AC_SUBST ( PCRE2_CPPFLAGS )
79+ AC_SUBST ( PCRE2_CFLAGS )
80+ AC_SUBST ( PCRE2_LDFLAGS )
81+ AC_SUBST ( PCRE2_LDADD )
82+ AC_SUBST ( PCRE_LD_PATH )
7983
80- if test -z "${PCRE2_VERSION}"; then
81- AC_MSG_NOTICE ( [ *** pcre2 library not found.] )
82- else
83- AC_MSG_NOTICE ( [ using pcre2 v${PCRE2_VERSION}] )
84- PCRE2_CFLAGS="-DWITH_PCRE2 ${PCRE2_CFLAGS}"
85- ifelse ( [ $1 ] , , , $1 )
86- fi
84+ if test -z "${PCRE2_VERSION}"; then
85+ AC_MSG_NOTICE ( [ *** pcre2 library not found.] )
86+ ifelse ( [ $2 ] , , AC_MSG_ERROR ( [ pcre2 library is required] ) , $2 )
87+ else
88+ AC_MSG_NOTICE ( [ using pcre2 v${PCRE2_VERSION}] )
89+ PCRE2_CFLAGS="-DWITH_PCRE2 ${PCRE2_CFLAGS}"
90+ ifelse ( [ $1 ] , , , $1 )
91+ fi
92+ fi
8793] )
0 commit comments