conf revision e18a033b
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) Nginx, Inc.
4
5
6if [ $PCRE != NONE ]; then
7    CORE_INCS="$CORE_INCS $PCRE"
8
9    case "$NGX_CC_NAME" in
10
11        msvc | owc | bcc)
12            have=NGX_PCRE . auto/have
13            have=PCRE_STATIC . auto/have
14            CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
15            LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
16            CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
17        ;;
18
19        icc)
20            have=NGX_PCRE . auto/have
21            CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
22
23            LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
24
25            echo $ngx_n "checking for PCRE library ...$ngx_c"
26
27            if [ -f $PCRE/pcre.h ]; then
28                ngx_pcre_ver=`grep PCRE_MAJOR $PCRE/pcre.h \
29                              | sed -e 's/^.*PCRE_MAJOR.* \(.*\)$/\1/'`
30
31            else if [ -f $PCRE/configure.in ]; then
32                ngx_pcre_ver=`grep PCRE_MAJOR= $PCRE/configure.in \
33                              | sed -e 's/^.*=\(.*\)$/\1/'`
34
35            else
36                ngx_pcre_ver=`grep pcre_major, $PCRE/configure.ac \
37                              | sed -e 's/^.*pcre_major,.*\[\(.*\)\].*$/\1/'`
38            fi
39            fi
40
41            echo " $ngx_pcre_ver major version found"
42
43            # to allow -ipo optimization we link with the *.o but not library
44
45            case "$ngx_pcre_ver" in
46                4|5)
47                    CORE_LIBS="$CORE_LIBS $PCRE/pcre.o"
48                ;;
49
50                6)
51                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_chartables.o"
52                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_compile.o"
53                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_exec.o"
54                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_fullinfo.o"
55                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_globals.o"
56                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_tables.o"
57                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_try_flipped.o"
58                ;;
59
60                *)
61                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_chartables.o"
62                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_compile.o"
63                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_exec.o"
64                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_fullinfo.o"
65                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_globals.o"
66                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_tables.o"
67                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_try_flipped.o"
68                    CORE_LIBS="$CORE_LIBS $PCRE/pcre_newline.o"
69                ;;
70
71            esac
72        ;;
73
74        *)
75            have=NGX_PCRE . auto/have
76
77            if [ "$NGX_PLATFORM" = win32 ]; then
78                have=PCRE_STATIC . auto/have
79            fi
80
81            CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
82            LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
83            CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a"
84        ;;
85
86    esac
87
88
89    if [ $PCRE_JIT = YES ]; then
90        have=NGX_HAVE_PCRE_JIT . auto/have
91        PCRE_CONF_OPT="$PCRE_CONF_OPT --enable-jit"
92    fi
93
94else
95
96    if [ "$NGX_PLATFORM" != win32 ]; then
97
98        PCRE=NO
99
100        ngx_feature="PCRE library"
101        ngx_feature_name="NGX_PCRE"
102        ngx_feature_run=no
103        ngx_feature_incs="#include <pcre.h>"
104        ngx_feature_path=
105        ngx_feature_libs="-lpcre"
106        ngx_feature_test="pcre *re;
107                          re = pcre_compile(NULL, 0, NULL, 0, NULL);
108                          if (re == NULL) return 1"
109        . auto/feature
110
111        if [ $ngx_found = no ]; then
112
113            # FreeBSD port
114
115            ngx_feature="PCRE library in /usr/local/"
116            ngx_feature_path="/usr/local/include"
117
118            if [ $NGX_RPATH = YES ]; then
119                ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpcre"
120            else
121                ngx_feature_libs="-L/usr/local/lib -lpcre"
122            fi
123
124            . auto/feature
125        fi
126
127        if [ $ngx_found = no ]; then
128
129            # RedHat RPM, Solaris package
130
131            ngx_feature="PCRE library in /usr/include/pcre/"
132            ngx_feature_path="/usr/include/pcre"
133            ngx_feature_libs="-lpcre"
134
135            . auto/feature
136        fi
137
138        if [ $ngx_found = no ]; then
139
140            # NetBSD port
141
142            ngx_feature="PCRE library in /usr/pkg/"
143            ngx_feature_path="/usr/pkg/include"
144
145            if [ $NGX_RPATH = YES ]; then
146                ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lpcre"
147            else
148                ngx_feature_libs="-L/usr/pkg/lib -lpcre"
149            fi
150
151            . auto/feature
152        fi
153
154        if [ $ngx_found = no ]; then
155
156            # MacPorts
157
158            ngx_feature="PCRE library in /opt/local/"
159            ngx_feature_path="/opt/local/include"
160
161            if [ $NGX_RPATH = YES ]; then
162                ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lpcre"
163            else
164                ngx_feature_libs="-L/opt/local/lib -lpcre"
165            fi
166
167            . auto/feature
168        fi
169
170        if [ $ngx_found = yes ]; then
171            CORE_INCS="$CORE_INCS $ngx_feature_path"
172            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
173            PCRE=YES
174        fi
175
176        if [ $PCRE = YES ]; then
177            ngx_feature="PCRE JIT support"
178            ngx_feature_name="NGX_HAVE_PCRE_JIT"
179            ngx_feature_test="int jit = 0;
180                              pcre_free_study(NULL);
181                              pcre_config(PCRE_CONFIG_JIT, &jit);
182                              if (jit != 1) return 1;"
183            . auto/feature
184
185            if [ $ngx_found = yes ]; then
186                PCRE_JIT=YES
187            fi
188        fi
189    fi
190
191    if [ $PCRE != YES ]; then
192cat << END
193
194$0: error: the HTTP rewrite module requires the PCRE library.
195You can either disable the module by using --without-http_rewrite_module
196option, or install the PCRE library into the system, or build the PCRE library
197statically from the source with nginx by using --with-pcre=<path> option.
198
199END
200        exit 1
201    fi
202
203fi
204