aboutsummaryrefslogtreecommitdiff
path: root/auto/pcre
blob: 714ca2955253f78658117f032e7d71fcb36c245b (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.

NJS_PCRE_CFLAGS=
NJS_PCRE_LIB=

NJS_HAVE_PCRE=NO

if [ $NJS_PCRE = YES ]; then

    njs_found=no

    if [ $NJS_TRY_PCRE2 = YES ]; 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>

                          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

                . 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) {
                                  printf(\"%d.%d\", PCRE2_MAJOR, PCRE2_MINOR);
                                  return 0;
                              }"

            . auto/feature

            NJS_HAVE_PCRE=YES
        fi
    fi

    if [ $njs_found = no ]; 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;

                              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 <pcre.h>
                              #include <stdio.h>

                              int main(void) {
                                  printf(\"%d.%d\", PCRE_MAJOR, PCRE_MINOR);
                                  return 0;
                              }"

            . auto/feature

            NJS_HAVE_PCRE=YES
        fi
    fi

    if [ $njs_found = no ]; then
        echo
        echo $0: error: no PCRE library found.
        echo
        exit 1;
    fi

fi

NJS_LIB_AUX_CFLAGS="$NJS_LIB_AUX_CFLAGS $NJS_PCRE_CFLAGS"
NJS_LIB_AUX_LIBS="$NJS_LIB_AUX_LIBS $NJS_PCRE_LIB"