[njs] Improved discovery of PCRE libraries.
Dmitry Volyntsev
xeioex at nginx.com
Fri Dec 24 16:58:49 UTC 2021
details: https://hg.nginx.org/njs/rev/9e2e4d04dfc4
branches:
changeset: 1786:9e2e4d04dfc4
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri Dec 24 16:54:12 2021 +0000
description:
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.
diffstat:
auto/pcre | 132 +++++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 93 insertions(+), 39 deletions(-)
diffs (160 lines):
diff -r d493f47f2734 -r 9e2e4d04dfc4 auto/pcre
--- a/auto/pcre Fri Dec 24 15:48:12 2021 +0000
+++ b/auto/pcre Fri Dec 24 16:54:12 2021 +0000
@@ -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_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 <pcre2.h>
- NJS_PCRE_CFLAGS=`pcre2-config --cflags`
- NJS_PCRE_LIB=`pcre2-config --libs8`
+ 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
- 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 <pcre2.h>
+ # 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
+
+ . 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 <pcre2.h>
+ #include <stdio.h>
int main(void) {
- pcre2_code *re;
-
- re = pcre2_compile((PCRE2_SPTR)\"\",
- PCRE2_ZERO_TERMINATED, 0,
- NULL, NULL, NULL);
- return (re == NULL);
+ 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_feature="PCRE library"
+ njs_feature_name=NJS_HAVE_PCRE
+ njs_feature_run=no
+ njs_feature_incs=
+ njs_feature_libs=
+ njs_feature_test="#include <pcre.h>
+
+ int main(void) {
+ pcre *re;
- NJS_PCRE_CFLAGS=`pcre-config --cflags`
- NJS_PCRE_LIB=`pcre-config --libs`
+ 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`
- 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
- njs_feature_test="#include <pcre.h>
+ 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
- int main(void) {
- pcre *re;
+ if [ $njs_found = yes ]; then
+ njs_feature="PCRE version"
+ njs_feature_name=NJS_PCRE_VERSION
+ njs_feature_run=value
+ njs_feature_test="#include <pcre.h>
+ #include <stdio.h>
- re = pcre_compile(NULL, 0, NULL, 0, NULL);
- if (re == NULL)
- return 1;
- return 0;
- }"
+ int main(void) {
+ printf(\"%d.%d\", PCRE_MAJOR, PCRE_MINOR);
+ 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
More information about the nginx-devel
mailing list