xref: /unit/auto/pcre (revision 1721:53b6ab9b324b)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6nxt_found=no
7NXT_HAVE_PCRE2=NO
8
9if [ $NXT_TRY_PCRE2 = YES ]; then
10    if /bin/sh -c "(pcre2-config --version)" >> $NXT_AUTOCONF_ERR 2>&1; then
11
12        NXT_PCRE_CFLAGS=`pcre2-config --cflags`
13        NXT_PCRE_LIB=`pcre2-config --libs8`
14
15        nxt_feature="PCRE2 library"
16        nxt_feature_name=NXT_HAVE_PCRE2
17        nxt_feature_run=no
18        nxt_feature_incs="-DPCRE2_CODE_UNIT_WIDTH=8 $NXT_PCRE_CFLAGS"
19        nxt_feature_libs=$NXT_PCRE_LIB
20        nxt_feature_test="#include <pcre2.h>
21
22                          int main(void) {
23                              pcre2_code  *re;
24
25                              re = pcre2_compile((PCRE2_SPTR)\"\",
26                                                 PCRE2_ZERO_TERMINATED, 0,
27                                                 NULL, NULL, NULL);
28                              return (re == NULL);
29                          }"
30
31        . auto/feature
32
33        if [ $nxt_found = yes ]; then
34            NXT_HAVE_PCRE2=YES
35            $echo " + PCRE2 version: `pcre2-config --version`"
36        fi
37    fi
38fi
39
40if [ $nxt_found = no ]; then
41    if /bin/sh -c "(pcre-config --version)" >> $NXT_AUTOCONF_ERR 2>&1; then
42
43        NXT_PCRE_CFLAGS=`pcre-config --cflags`
44        NXT_PCRE_LIB=`pcre-config --libs`
45
46        nxt_feature="PCRE library"
47        nxt_feature_name=NXT_HAVE_PCRE
48        nxt_feature_run=no
49        nxt_feature_incs=$NXT_PCRE_CFLAGS
50        nxt_feature_libs=$NXT_PCRE_LIB
51        nxt_feature_test="#include <pcre.h>
52
53                          int main() {
54                              pcre  *re;
55
56                              re = pcre_compile(NULL, 0, NULL, 0, NULL);
57                              if (re == NULL)
58                                  return 1;
59                              return 0;
60                          }"
61        . auto/feature
62
63        if [ $nxt_found = yes ]; then
64            $echo " + PCRE version: `pcre-config --version`"
65        fi
66    fi
67fi
68
69if [ $nxt_found = yes ]; then
70    nxt_have=NXT_HAVE_REGEX . auto/have
71
72else
73    $echo
74    $echo $0: error: no PCRE library found.
75    $echo
76    exit 1;
77fi
78