comparison auto/lib/pcre/make @ 7981:0b5f12d5c531

PCRE2 library support. The PCRE2 library is now used by default if found, instead of the original PCRE library. If needed for some reason, this can be disabled with the --without-pcre2 configure option. To make it possible to specify paths to the library and include files via --with-cc-opt / --with-ld-opt, the library is first tested without any additional paths and options. If this fails, the pcre2-config script is used. Similarly to the original PCRE library, it is now possible to build PCRE2 from sources with nginx configure, by using the --with-pcre= option. It automatically detects if PCRE or PCRE2 sources are provided. Note that compiling PCRE2 10.33 and later requires inttypes.h. When compiling on Windows with MSVC, inttypes.h is only available starting with MSVC 2013. In older versions some replacement needs to be provided ("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough for MSVC 2010). The interface on nginx side remains unchanged.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 25 Dec 2021 01:07:15 +0300
parents 78f8ac479735
children
comparison
equal deleted inserted replaced
7980:8007ea138d6a 7981:0b5f12d5c531
1 1
2 # Copyright (C) Igor Sysoev 2 # Copyright (C) Igor Sysoev
3 # Copyright (C) Nginx, Inc. 3 # Copyright (C) Nginx, Inc.
4 4
5 5
6 case "$NGX_CC_NAME" in 6 if [ $PCRE_LIBRARY = PCRE2 ]; then
7 7
8 msvc) 8 # PCRE2
9 ngx_makefile=makefile.msvc
10 ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC"
11 ngx_pcre="PCRE=\"$PCRE\""
12 ;;
13 9
14 owc) 10 if [ $NGX_CC_NAME = msvc ]; then
15 ngx_makefile=makefile.owc
16 ngx_opt="CPU_OPT=\"$CPU_OPT\""
17 ngx_pcre=`echo PCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"`
18 ;;
19 11
20 bcc) 12 # With PCRE2, it is not possible to compile all sources.
21 ngx_makefile=makefile.bcc 13 # Since list of source files changes between versions, we
22 ngx_opt="-DCPU_OPT=\"$CPU_OPT\"" 14 # test files which might not be present.
23 ngx_pcre=`echo \-DPCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"`
24 ;;
25 15
26 *) 16 ngx_pcre_srcs="pcre2_auto_possess.c \
27 ngx_makefile= 17 pcre2_chartables.c \
28 ;; 18 pcre2_compile.c \
19 pcre2_config.c \
20 pcre2_context.c \
21 pcre2_dfa_match.c \
22 pcre2_error.c \
23 pcre2_jit_compile.c \
24 pcre2_maketables.c \
25 pcre2_match.c \
26 pcre2_match_data.c \
27 pcre2_newline.c \
28 pcre2_ord2utf.c \
29 pcre2_pattern_info.c \
30 pcre2_string_utils.c \
31 pcre2_study.c \
32 pcre2_substitute.c \
33 pcre2_substring.c \
34 pcre2_tables.c \
35 pcre2_ucd.c \
36 pcre2_valid_utf.c \
37 pcre2_xclass.c"
29 38
30 esac 39 ngx_pcre_test="pcre2_convert.c \
40 pcre2_extuni.c \
41 pcre2_find_bracket.c \
42 pcre2_script_run.c \
43 pcre2_serialize.c"
44
45 for ngx_src in $ngx_pcre_test
46 do
47 if [ -f $PCRE/src/$ngx_src ]; then
48 ngx_pcre_srcs="$ngx_pcre_srcs $ngx_src"
49 fi
50 done
51
52 ngx_pcre_objs=`echo $ngx_pcre_srcs \
53 | sed -e "s#\([^ ]*\.\)c#\1$ngx_objext#g"`
54
55 ngx_pcre_srcs=`echo $ngx_pcre_srcs \
56 | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g"`
57 ngx_pcre_objs=`echo $ngx_pcre_objs \
58 | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g"`
59
60 cat << END >> $NGX_MAKEFILE
61
62 PCRE_CFLAGS = -O2 -Ob1 -Oi -Gs $LIBC $CPU_OPT
63 PCRE_FLAGS = -DHAVE_CONFIG_H -DPCRE2_STATIC -DPCRE2_CODE_UNIT_WIDTH=8 \\
64 -DHAVE_MEMMOVE
65
66 PCRE_SRCS = $ngx_pcre_srcs
67 PCRE_OBJS = $ngx_pcre_objs
68
69 $PCRE/src/pcre2.h:
70 cd $PCRE/src \\
71 && copy /y config.h.generic config.h \\
72 && copy /y pcre2.h.generic pcre2.h \\
73 && copy /y pcre2_chartables.c.dist pcre2_chartables.c
74
75 $PCRE/src/pcre2-8.lib: $PCRE/src/pcre2.h $NGX_MAKEFILE
76 cd $PCRE/src \\
77 && cl -nologo -c \$(PCRE_CFLAGS) -I . \$(PCRE_FLAGS) \$(PCRE_SRCS) \\
78 && link -lib -out:pcre2-8.lib -verbose:lib \$(PCRE_OBJS)
79
80 END
81
82 else
83
84 cat << END >> $NGX_MAKEFILE
85
86 $PCRE/src/pcre2.h: $PCRE/Makefile
87
88 $PCRE/Makefile: $NGX_MAKEFILE
89 cd $PCRE \\
90 && if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
91 && CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
92 ./configure --disable-shared $PCRE_CONF_OPT
93
94 $PCRE/.libs/libpcre2-8.a: $PCRE/Makefile
95 cd $PCRE \\
96 && \$(MAKE) libpcre2-8.la
97
98 END
99
100 fi
31 101
32 102
33 if [ -n "$ngx_makefile" ]; then 103 else
34 104
35 cat << END >> $NGX_MAKEFILE 105 # PCRE
106
107 case "$NGX_CC_NAME" in
108
109 msvc)
110 ngx_makefile=makefile.msvc
111 ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC"
112 ngx_pcre="PCRE=\"$PCRE\""
113 ;;
114
115 owc)
116 ngx_makefile=makefile.owc
117 ngx_opt="CPU_OPT=\"$CPU_OPT\""
118 ngx_pcre=`echo PCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"`
119 ;;
120
121 bcc)
122 ngx_makefile=makefile.bcc
123 ngx_opt="-DCPU_OPT=\"$CPU_OPT\""
124 ngx_pcre=`echo \-DPCRE=\"$PCRE\" \
125 | sed -e "s/\//$ngx_regex_dirsep/g"`
126 ;;
127
128 *)
129 ngx_makefile=
130 ;;
131
132 esac
133
134
135 if [ -n "$ngx_makefile" ]; then
136
137 cat << END >> $NGX_MAKEFILE
36 138
37 `echo "$PCRE/pcre.lib: $PCRE/pcre.h $NGX_MAKEFILE" \ 139 `echo "$PCRE/pcre.lib: $PCRE/pcre.h $NGX_MAKEFILE" \
38 | sed -e "s/\//$ngx_regex_dirsep/g"` 140 | sed -e "s/\//$ngx_regex_dirsep/g"`
39 \$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre $ngx_opt 141 \$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre $ngx_opt
40 142
41 `echo "$PCRE/pcre.h:" | sed -e "s/\//$ngx_regex_dirsep/g"` 143 `echo "$PCRE/pcre.h:" | sed -e "s/\//$ngx_regex_dirsep/g"`
42 \$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre pcre.h 144 \$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre pcre.h
43 145
44 END 146 END
45 147
46 else 148 else
47 149
48 cat << END >> $NGX_MAKEFILE 150 cat << END >> $NGX_MAKEFILE
49 151
50 $PCRE/pcre.h: $PCRE/Makefile 152 $PCRE/pcre.h: $PCRE/Makefile
51 153
52 $PCRE/Makefile: $NGX_MAKEFILE 154 $PCRE/Makefile: $NGX_MAKEFILE
53 cd $PCRE \\ 155 cd $PCRE \\
59 cd $PCRE \\ 161 cd $PCRE \\
60 && \$(MAKE) libpcre.la 162 && \$(MAKE) libpcre.la
61 163
62 END 164 END
63 165
166 fi
167
64 fi 168 fi