From: Dmitry Volyntsev Date: Fri, 24 Dec 2021 16:54:12 +0000 (+0000) Subject: Improved discovery of PCRE libraries. X-Git-Tag: 0.7.1~4 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=61c91f55b925083246157ded44d54583025d115e;p=njs.git Improved discovery of PCRE libraries. Trying to link again the library using --cc-opt and --ld-opt before attempting to use pcre-config or pcre2-config. --- diff --git a/auto/pcre b/auto/pcre index 8d51cf8c..b8f515e2 100644 --- a/auto/pcre +++ b/auto/pcre @@ -12,63 +12,117 @@ if [ $NJS_PCRE = YES ]; then njs_found=no if [ $NJS_TRY_PCRE2 = YES ]; then - if /bin/sh -c "(pcre2-config --version)" >> $NJS_AUTOCONF_ERR 2>&1; then - NJS_PCRE_CFLAGS=`pcre2-config --cflags` - NJS_PCRE_LIB=`pcre2-config --libs8` + njs_feature="PCRE2 library" + njs_feature_name=NJS_HAVE_PCRE2 + njs_feature_run=no + njs_feature_incs= + njs_feature_libs= + njs_feature_test="#define PCRE2_CODE_UNIT_WIDTH 8 + #include - njs_feature="PCRE2 library" - njs_feature_name=NJS_HAVE_PCRE2 - njs_feature_run=no - njs_feature_incs="-DPCRE2_CODE_UNIT_WIDTH=8 $NJS_PCRE_CFLAGS" - njs_feature_libs=$NJS_PCRE_LIB - njs_feature_test="#include + int main(void) { + pcre2_code *re; - int main(void) { - pcre2_code *re; + re = pcre2_compile((PCRE2_SPTR)\"\", + PCRE2_ZERO_TERMINATED, 0, + NULL, NULL, NULL); + return (re == NULL); + }" + + . auto/feature + + if [ $njs_found = no ]; then + + # pcre2-config + + if /bin/sh -c "(pcre2-config --version)" >> $NJS_AUTOCONF_ERR 2>&1; then + + NJS_PCRE_CFLAGS=`pcre2-config --cflags` + NJS_PCRE_LIB=`pcre2-config --libs8` + + njs_feature="PCRE2 library in `pcre2-config --prefix 2>/dev/null`" + njs_feature_incs=$NJS_PCRE_CFLAGS + njs_feature_libs=$NJS_PCRE_LIB - re = pcre2_compile((PCRE2_SPTR)\"\", - PCRE2_ZERO_TERMINATED, 0, - NULL, NULL, NULL); - return (re == NULL); + . auto/feature + fi + + fi + + if [ $njs_found = yes ]; then + njs_feature="PCRE2 version" + njs_feature_name=NJS_PCRE2_VERSION + njs_feature_run=value + njs_feature_test="#define PCRE2_CODE_UNIT_WIDTH 8 + #include + #include + + int main(void) { + printf(\"%d.%d\", PCRE2_MAJOR, PCRE2_MINOR); + return 0; }" . auto/feature - if [ $njs_found = yes ]; then - NJS_HAVE_PCRE=YES - echo " + PCRE2 version: `pcre2-config --version`" - fi + NJS_HAVE_PCRE=YES fi fi if [ $njs_found = no ]; then - if /bin/sh -c "(pcre-config --version)" >> $NJS_AUTOCONF_ERR 2>&1; then - NJS_PCRE_CFLAGS=`pcre-config --cflags` - NJS_PCRE_LIB=`pcre-config --libs` + njs_feature="PCRE library" + njs_feature_name=NJS_HAVE_PCRE + njs_feature_run=no + njs_feature_incs= + njs_feature_libs= + njs_feature_test="#include + + int main(void) { + pcre *re; - njs_feature="PCRE library" - njs_feature_name=NJS_HAVE_PCRE - njs_feature_run=no - njs_feature_incs=$NJS_PCRE_CFLAGS - njs_feature_libs=$NJS_PCRE_LIB + re = pcre_compile(NULL, 0, NULL, 0, NULL); + if (re == NULL) + return 1; + return 0; + }" + + . auto/feature + + if [ $njs_found = no ]; then + + # pcre-config + + njs_pcre_prefix=`pcre-config --prefix 2>/dev/null` + + if [ -n "$njs_pcre_prefix" ]; then + + NJS_PCRE_CFLAGS=`pcre-config --cflags` + NJS_PCRE_LIB=`pcre-config --libs` + + njs_feature="PCRE library in $njs_pcre_prefix" + njs_feature_incs="$NJS_PCRE_CFLAGS" + njs_feature_libs=$NJS_PCRE_LIB + + . auto/feature + fi + fi + + if [ $njs_found = yes ]; then + njs_feature="PCRE version" + njs_feature_name=NJS_PCRE_VERSION + njs_feature_run=value njs_feature_test="#include + #include - int main(void) { - pcre *re; + int main(void) { + printf(\"%d.%d\", PCRE_MAJOR, PCRE_MINOR); + return 0; + }" - re = pcre_compile(NULL, 0, NULL, 0, NULL); - if (re == NULL) - return 1; - return 0; - }" . auto/feature - if [ $njs_found = yes ]; then - NJS_HAVE_PCRE=YES - echo " + PCRE version: `pcre-config --version`" - fi + NJS_HAVE_PCRE=YES fi fi