Source
21
21
const char* error = NULL;
22
22
int error_offset = -1;
23
23
pcre *regexp = pcre_compile("test", PCRE_UTF8, &error, &error_offset, NULL);
24
24
pcre_free(regexp);
25
25
],
26
26
found_libpcre="yes")
27
27
])dnl
28
28
29
29
AC_DEFUN([LIBPCRE_CHECK_CONFIG],
30
30
[
31
+
want_libpcre=no
32
+
found_libpcre=no
33
+
libpcre_dir=""
34
+
libpcre_include_dir=""
35
+
libpcre_lib_dir=""
36
+
37
+
#
38
+
# process --with-* flags
39
+
#
40
+
31
41
AC_ARG_WITH([libpcre],[
32
42
If you want to specify libpcre installation directories:
33
43
AC_HELP_STRING([--with-libpcre@<:@=DIR@:>@], [use libpcre from given base install directory (DIR), default is to search through a number of common places for the libpcre files.])],
34
-
[
35
-
if test "$withval" = "yes"; then
36
-
want_libpcre=yes
37
-
if test -f /usr/local/include/pcre.h; then
38
-
withval="/usr/local"
39
-
else
40
-
withval="/usr"
41
-
fi
42
-
else
43
-
want_libpcre=no
44
-
_libpcre_dir_lib="$withval/lib"
44
+
[
45
+
if test "$withval" != "no"; then
46
+
want_libpcre=yes
47
+
if test "$withval" != "yes"; then
48
+
libpcre_dir="$withval"
45
49
fi
46
-
_libpcre_dir="$withval"
47
-
test "x$withval" = "xyes" && withval=/usr
48
-
LIBPCRE_CFLAGS="-I$withval/include"
49
-
LIBPCRE_LDFLAGS="-L$withval/lib"
50
-
_libpcre_dir_set="yes"
51
-
]
52
-
)
53
-
54
-
AC_ARG_WITH([libpcre-include],
55
-
AC_HELP_STRING([--with-libpcre-include@<:@=DIR@:>@],
56
-
[use libpcre include headers from given path.]
57
-
),
58
-
[
59
-
LIBPCRE_CFLAGS="-I$withval"
60
-
_libpcre_dir_set="yes"
61
-
]
62
-
)
63
-
64
-
AC_ARG_WITH([libpcre-lib],
65
-
AC_HELP_STRING([--with-libpcre-lib@<:@=DIR@:>@],
66
-
[use libpcre libraries from given path.]
67
-
),
68
-
[
69
-
_libpcre_dir="$withval"
70
-
_libpcre_dir_lib="$withval"
71
-
LIBPCRE_LDFLAGS="-L$withval"
72
-
_libpcre_dir_set="yes"
73
-
]
74
-
)
75
-
76
-
if test "x$enable_static_libs" = "xyes"; then
50
+
fi
51
+
])
52
+
53
+
AC_ARG_WITH([libpcre-include], AC_HELP_STRING([--with-libpcre-include@<:@=DIR@:>@], [use libpcre include headers from given path.]), [
54
+
want_libpcre="yes"
55
+
libpcre_include_dir="$withval"
56
+
if ! test -d "$libpcre_include_dir"; then
57
+
AC_MSG_ERROR([cannot find $libpcre_include_dir directory])
58
+
fi
59
+
if ! test -f "$libpcre_include_dir/pcre.h"; then
60
+
AC_MSG_ERROR([cannot find $libpcre_include_dir/pcre.h])
61
+
fi
62
+
])
63
+
64
+
AC_ARG_WITH([libpcre-lib], AC_HELP_STRING([--with-libpcre-lib@<:@=DIR@:>@], [use libpcre libraries from given path.]), [
65
+
want_libpcre="yes"
66
+
libpcre_lib_dir="$withval"
67
+
if ! test -d "$libpcre_lib_dir"; then
68
+
AC_MSG_ERROR([cannot find $libpcre_lib_dir directory])
69
+
fi
70
+
])
71
+
72
+
73
+
#
74
+
# find actual compiler flags and include paths
75
+
#
76
+
77
+
if test "$1" != "flags-only"; then
77
78
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
78
-
PKG_PROG_PKG_CONFIG()
79
-
test -z "$PKG_CONFIG" -a -z "$_libpcre_dir_lib" && AC_MSG_ERROR([Not found pkg-config library])
80
-
m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
81
-
fi
79
+
m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
82
80
83
-
AC_MSG_CHECKING(for libpcre support)
81
+
if test -n "$PKG_CONFIG"; then
82
+
#
83
+
# got pkg-config, use that
84
+
#
84
85
85
-
LIBPCRE_LIBS="-lpcre"
86
+
m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
86
87
87
-
if test "x$enable_static" = "xyes"; then
88
-
LIBPCRE_LIBS=" $LIBPCRE_LIBS -lpthread"
89
-
elif test "x$enable_static_libs" = "xyes" -a -z "$PKG_CONFIG"; then
90
-
LIBPCRE_LIBS="$_libpcre_dir_lib/libpcre.a"
91
-
elif test "x$enable_static_libs" = "xyes"; then
88
+
if test -n "$libpcre_lib_dir"; then
89
+
export PKG_CONFIG_LIBDIR="$libpcre_lib_dir/pkgconfig"
90
+
elif test -n "$libpcre_dir"; then
91
+
export PKG_CONFIG_LIBDIR="$libpcre_dir/lib/pkgconfig"
92
+
fi
92
93
93
-
test "x$static_linking_support" = "xno" -a -z "$_libpcre_dir_lib" && AC_MSG_ERROR(["Compiler not support statically linked libs from default folders"])
94
+
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors libpcre]) || {
95
+
AC_MSG_ERROR([cannot find pkg-config package for libpcre])
96
+
}
94
97
95
-
if test -z "$_libpcre_dir_lib"; then
96
-
PKG_CHECK_EXISTS(libpcre,[
97
-
LIBPCRE_LIBS=`$PKG_CONFIG --static --libs libpcre`
98
-
],[
99
-
AC_MSG_ERROR([Not found libpcre package])
100
-
])
101
-
else
102
-
AC_RUN_LOG([PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --exists --print-errors libpcre]) || AC_MSG_ERROR(["Not found libpcre package in $_libpcre_dir/lib/pkgconfig"])
103
-
LIBPCRE_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --static --libs libpcre`
104
-
test -z "$LIBPCRE_LIBS" && LIBPCRE_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --libs libpcre`
105
-
fi
98
+
if test -n "$libpcre_include_dir"; then
99
+
LIBPCRE_CFLAGS="-I$libpcre_include_dir"
100
+
else
101
+
LIBPCRE_CFLAGS=`$PKG_CONFIG --cflags libpcre`
102
+
fi
103
+
104
+
LIBPCRE_LDFLAGS=`$PKG_CONFIG --libs-only-L libpcre`
105
+
LIBPCRE_LIBS=`$PKG_CONFIG --libs-only-l libpcre`
106
+
107
+
unset PKG_CONFIG_LIBDIR
106
108
107
-
if test "x$static_linking_support" = "xno"; then
108
-
LIBPCRE_LIBS=`echo "$LIBPCRE_LIBS"|sed "s|-lpcre|$_libpcre_dir_lib/libpcre.a|g"`
109
+
found_libpcre="yes"
109
110
else
110
-
LIBPCRE_LIBS=`echo "$LIBPCRE_LIBS"|sed "s/-lpcre/${static_linking_support}static -lpcre ${static_linking_support}dynamic/g"`
111
+
#
112
+
# no pkg-config, trying to guess
113
+
#
114
+
115
+
AC_MSG_WARN([proceeding without pkg-config])
116
+
117
+
LIBPCRE_LIBS="-lpcre"
118
+
119
+
if test -n "$libpcre_dir"; then
120
+
#
121
+
# directories are given explicitly
122
+
#
123
+
124
+
if test -n "$libpcre_include_dir"; then
125
+
LIBPCRE_CFLAGS="-I$libpcre_include_dir"
126
+
else
127
+
if test -f "$libpcre_dir/include/pcre.h"; then
128
+
LIBPCRE_CFLAGS="-I$libpcre_dir/include"
129
+
else
130
+
AC_MSG_ERROR([cannot find $libpcre_dir/include/pcre.h])
131
+
fi
132
+
fi
133
+
134
+
if test -n "$libpcre_lib_dir"; then
135
+
LIBPCRE_LDFLAGS="-L$libpcre_lib_dir"
136
+
else
137
+
if test -d "$libpcre_dir/lib"; then
138
+
LIBPCRE_LDFLAGS="-L$libpcre_dir/lib"
139
+
else
140
+
AC_MSG_ERROR([cannot find $libpcre_dir/lib])
141
+
fi
142
+
fi
143
+
144
+
found_libpcre="yes"
145
+
elif test -n "$libpcre_include_dir"; then
146
+
LIBPCRE_CFLAGS="-I$libpcre_include_dir"
147
+
148
+
if test -n "$libpcre_lib_dir"; then
149
+
LIBPCRE_LDFLAGS="-L$libpcre_lib_dir"
150
+
fi
151
+
152
+
found_libpcre="yes"
153
+
elif test -n "$libpcre_lib_dir"; then
154
+
LIBPCRE_LDFLAGS="-L$libpcre_lib_dir"
155
+
156
+
found_libpcre="yes"
157
+
else
158
+
#
159
+
# search default directories
160
+
#
161
+
162
+
if test -f /usr/include/pcre.h; then
163
+
found_libpcre="yes"
164
+
elif test -f /usr/local/include/pcre.h; then
165
+
LIBPCRE_CFLAGS="-I/usr/local/include"
166
+
LIBPCRE_LDFLAGS="-L/usr/local/lib"
167
+
168
+
found_libpcre="yes"
169
+
elif test -f /usr/pkg/include/pcre.h; then
170
+
LIBPCRE_CFLAGS="-I/usr/pkg/include"
171
+
LIBPCRE_LDFLAGS="-L/usr/pkg/lib"
172
+
LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/usr/pkg/lib"
173
+
174
+
found_libpcre="yes"
175
+
elif test -f /opt/csw/include/pcre.h; then
176
+
LIBPCRE_CFLAGS="-I/opt/csw/include"
177
+
LIBPCRE_LDFLAGS="-L/opt/csw/lib"
178
+
179
+
if $(echo "$CFLAGS"|grep -q -- "-m64") ; then
180
+
LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS/64 -Wl,-R/opt/csw/lib/64"
181
+
else
182
+
LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/opt/csw/lib"
183
+
fi
184
+
185
+
found_libpcre="yes"
186
+
else
187
+
found_libpcre="no"
188
+
fi
189
+
fi
111
190
fi
112
-
fi
113
191
114
-
if test -n "$_libpcre_dir_set" -o -f /usr/include/pcre.h; then
115
-
found_libpcre="yes"
116
-
elif test -f /usr/local/include/pcre.h; then
117
-
LIBPCRE_CFLAGS="-I/usr/local/include"
118
-
LIBPCRE_LDFLAGS="-L/usr/local/lib"
119
-
found_libpcre="yes"
120
-
elif test -f /usr/pkg/include/pcre.h; then
121
-
LIBPCRE_CFLAGS="-I/usr/pkg/include"
122
-
LIBPCRE_LDFLAGS="-L/usr/pkg/lib"
123
-
LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/usr/pkg/lib"
124
-
found_libpcre="yes"
125
-
elif test -f /opt/csw/include/pcre.h; then
126
-
LIBPCRE_CFLAGS="-I/opt/csw/include"
127
-
LIBPCRE_LDFLAGS="-L/opt/csw/lib"
128
-
if $(echo "$CFLAGS"|grep -q -- "-m64") ; then
129
-
LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS/64 -Wl,-R/opt/csw/lib/64"
130
-
else
131
-
LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/opt/csw/lib"
192
+
193
+
#
194
+
# process --enable-static and --enable_static-libs flags
195
+
#
196
+
197
+
if test "x$enable_static" = "xyes"; then
198
+
LIBPCRE_LIBS=" $LIBPCRE_LIBS -lpthread"
199
+
elif test "x$enable_static_libs" = "xyes"; then
200
+
if test "x$static_linking_support" == "xno"; then
201
+
AC_MSG_WARN([compiler has no direct suppor for static linkage])
202
+
203
+
if test -n "$libpcre_lib_dir"; then
204
+
if test -f "$libpcre_lib_dir/libpcre.a"; then
205
+
LIBPCRE_LIBS="$libpcre_lib_dir/libpcre.a"
206
+
else
207
+
AC_MSG_ERROR([cannot find $libpcre_lib_dir/libpcre.a])
208
+
fi
209
+
elif test -n "$libpcre_dir"; then
210
+
if test -f "$libpcre_dir/lib/libpcre.a"; then
211
+
LIBPCRE_LIBS="$libpcre_dir/lib/libpcre.a"
212
+
else
213
+
AC_MSG_ERROR([cannot find $libpcre_dir/lib/libpcre.a])
214
+
fi
215
+
else
216
+
AC_MSG_ERROR([libpcre directory must be given explicitly in this case])
217
+
fi
218
+
else
219
+
LIBPCRE_LIBS="$LIBPCRE_LDFLAGS ${static_linking_support}static $LIBPCRE_LIBS ${static_linking_support}dynamic"
220
+
LIBPCRE_LDFLAGS=""
221
+
fi
132
222
fi
133
-
found_libpcre="yes"
134
-
else
135
-
found_libpcre="no"
136
-
AC_MSG_RESULT(no)
137
-
fi
138
223
139
-
if test "x$found_libpcre" = "xyes"; then
140
-
am_save_CFLAGS="$CFLAGS"
141
-
am_save_LDFLAGS="$LDFLAGS"
142
-
am_save_LIBS="$LIBS"
143
224
144
-
CFLAGS="$CFLAGS $LIBPCRE_CFLAGS"
145
-
LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS"
146
-
LIBS="$LIBS $LIBPCRE_LIBS"
225
+
#
226
+
# try building with pcre
227
+
#
147
228
148
-
found_libpcre="no"
149
-
LIBPCRE_TRY_LINK([no])
229
+
AC_MSG_CHECKING([for libpcre support])
150
230
151
-
CFLAGS="$am_save_CFLAGS"
152
-
LDFLAGS="$am_save_LDFLAGS"
153
-
LIBS="$am_save_LIBS"
154
-
fi
231
+
if test "x$found_libpcre" = "xyes"; then
232
+
am_save_CFLAGS="$CFLAGS"
233
+
am_save_LDFLAGS="$LDFLAGS"
234
+
am_save_LIBS="$LIBS"
155
235
156
-
if test "x$found_libpcre" = "xyes"; then
157
-
AC_MSG_RESULT(yes)
158
-
else
159
-
LIBPCRE_CFLAGS=""
160
-
LIBPCRE_LDFLAGS=""
161
-
LIBPCRE_LIBS=""
162
-
fi
236
+
CFLAGS="$CFLAGS $LIBPCRE_CFLAGS"
237
+
LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS"
238
+
LIBS="$LIBS $LIBPCRE_LIBS"
239
+
240
+
found_libpcre="no"
241
+
LIBPCRE_TRY_LINK([no])
242
+
243
+
if test "x$found_libpcre" = "xyes"; then
244
+
AC_MSG_RESULT(yes)
245
+
else
246
+
AC_MSG_RESULT(no)
247
+
if test "$1" = "mandatory"; then
248
+
AC_MSG_NOTICE([CFLAGS: $CFLAGS])
249
+
AC_MSG_NOTICE([LDFLAGS: $LDFLAGS])
250
+
AC_MSG_NOTICE([LIBS: $LIBS])
251
+
AC_MSG_ERROR([cannot build with libpcre])
252
+
else
253
+
LIBPCRE_CFLAGS=""
254
+
LIBPCRE_LDFLAGS=""
255
+
LIBPCRE_LIBS=""
256
+
fi
257
+
fi
163
258
164
-
AC_SUBST(LIBPCRE_CFLAGS)
165
-
AC_SUBST(LIBPCRE_LDFLAGS)
166
-
AC_SUBST(LIBPCRE_LIBS)
259
+
CFLAGS="$am_save_CFLAGS"
260
+
LDFLAGS="$am_save_LDFLAGS"
261
+
LIBS="$am_save_LIBS"
262
+
else
263
+
AC_MSG_RESULT(no)
264
+
fi
265
+
266
+
AC_SUBST(LIBPCRE_CFLAGS)
267
+
AC_SUBST(LIBPCRE_LDFLAGS)
268
+
AC_SUBST(LIBPCRE_LIBS)
269
+
fi
167
270
])dnl