test PCRE in FreeBSD, Linux, and NetBSD
diff --git a/auto/cc/conf b/auto/cc/conf
index 82854d8..4823900 100644
--- a/auto/cc/conf
+++ b/auto/cc/conf
@@ -113,6 +113,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test=
. auto/feature
@@ -129,6 +130,7 @@
ngx_feature_run=yes
ngx_feature_incs="#include <stdio.h>
#define var(dummy, args...) sprintf(args)"
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[30]; buf[0] = '0';
var(0, buf, \"%d\", 1);
@@ -144,6 +146,7 @@
ngx_feature_run=yes
ngx_feature_incs="#include <stdio.h>
#define var(dummy, ...) sprintf(__VA_ARGS__)"
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[30]; buf[0] = '0';
var(0, buf, \"%d\", 1);
@@ -156,6 +159,7 @@
# ngx_feature_name=
# ngx_feature_run=no
# ngx_feature_incs="int inline f(void) { return 1 }"
+# ngx_feature_path=
# ngx_feature_libs=
# ngx_feature_test=
# . auto/feature
diff --git a/auto/cc/gcc b/auto/cc/gcc
index ea51560..e377fce 100644
--- a/auto/cc/gcc
+++ b/auto/cc/gcc
@@ -23,6 +23,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test=
. auto/feature
diff --git a/auto/cc/sunc b/auto/cc/sunc
index 00c0674..9edc0d0 100644
--- a/auto/cc/sunc
+++ b/auto/cc/sunc
@@ -20,6 +20,7 @@
ngx_feature_name=
ngx_feature_run=bug
ngx_feature_incs=
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='__asm ("pause")'
diff --git a/auto/feature b/auto/feature
index 0cf1f1e..e71b6e5 100644
--- a/auto/feature
+++ b/auto/feature
@@ -18,6 +18,10 @@
| tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
fi
+if test -n "$ngx_feature_path"; then
+ ngx_feature_inc_path="-I $ngx_feature_path"
+fi
+
cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
@@ -32,9 +36,11 @@
END
-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
+ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
+ngx_feature_inc_path=
+
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
diff --git a/auto/lib/md5/conf b/auto/lib/md5/conf
index 799d075..0c80fd5 100644
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -53,6 +53,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <md5.h>"
+ ngx_feature_path=
ngx_feature_libs="-lmd5"
ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
. auto/feature
@@ -70,6 +71,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <md5.h>"
+ ngx_feature_path=
ngx_feature_libs="-lmd"
ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
. auto/feature
@@ -85,15 +87,16 @@
else
if [ $MD5 = NO ]; then
- # OpenSSL crypto library
+ # OpenSSL crypto library
- ngx_feature="OpenSSL md5 crypto library"
- ngx_feature_name="NGX_OPENSSL_MD5"
- ngx_feature_run=no
- ngx_feature_incs="#include <openssl/md5.h>"
- ngx_feature_libs="-lcrypto"
- ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
- . auto/feature
+ ngx_feature="OpenSSL md5 crypto library"
+ ngx_feature_name="NGX_OPENSSL_MD5"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <openssl/md5.h>"
+ ngx_feature_path=
+ ngx_feature_libs="-lcrypto"
+ ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
+ . auto/feature
fi
fi
diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf
index 32f82ca..02e9e61 100644
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -47,6 +47,7 @@
ngx_feature_name="NGX_OPENSSL"
ngx_feature_run=no
ngx_feature_incs="#include <openssl/ssl.h>"
+ ngx_feature_path=
ngx_feature_libs="-lssl -lcrypto"
ngx_feature_test="SSL_library_init()"
. auto/feature
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 460325c..6ad9164 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -64,13 +64,11 @@
if [ "$NGX_PLATFORM" != win32 ]; then
PCRE=NO
- # FreeBSD PCRE port requires --with-cc-opt="-I /usr/local/include"
- # --with-ld-opt="-L /usr/local/lib"
-
ngx_feature="PCRE library"
ngx_feature_name="NGX_PCRE"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
+ ngx_feature_path=
ngx_feature_libs="-lpcre"
ngx_feature_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
. auto/feature
@@ -81,6 +79,73 @@
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
+
+ else
+ # FreeBSD port
+
+ ngx_feature="PCRE library in /usr/local/"
+ ngx_feature_name="NGX_PCRE"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <pcre.h>"
+ ngx_feature_path="/usr/local/include"
+ ngx_feature_libs="-L /usr/local/lib -lpcre"
+ ngx_feature_test="pcre *re;
+ re = pcre_compile(NULL, 0, NULL, 0, NULL)"
+ . auto/feature
fi
+
+ if [ $ngx_found = yes ]; then
+ CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
+ CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+ PCRE=YES
+ ngx_found=no
+
+ else
+ # Linux package
+
+ ngx_feature="PCRE library in /usr/include/pcre/"
+ ngx_feature_name="NGX_PCRE"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <pcre.h>"
+ ngx_feature_path="/usr/include/pcre"
+ ngx_feature_libs="-lpcre"
+ ngx_feature_test="pcre *re;
+ re = pcre_compile(NULL, 0, NULL, 0, NULL)"
+ . auto/feature
+ fi
+
+ if [ $ngx_found = yes ]; then
+ CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
+ CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+ PCRE=YES
+ ngx_found=no
+
+ else
+ # NetBSD port
+
+ ngx_feature="PCRE library in /usr/pkg/"
+ ngx_feature_name="NGX_PCRE"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <pcre.h>"
+ ngx_feature_path="/usr/pkg/include"
+ ngx_feature_libs="-L /usr/pkg/lib -lpcre"
+ ngx_feature_test="pcre *re;
+ re = pcre_compile(NULL, 0, NULL, 0, NULL)"
+ . auto/feature
+ fi
+
+ if [ $ngx_found = yes ]; then
+ CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
+ CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+ PCRE=YES
+ ngx_found=no
+ fi
+
fi
fi
diff --git a/auto/lib/sha1/conf b/auto/lib/sha1/conf
index a1e20c9..52ca97f 100644
--- a/auto/lib/sha1/conf
+++ b/auto/lib/sha1/conf
@@ -43,6 +43,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <sha.h>"
+ ngx_feature_path=
ngx_feature_libs="-lmd"
ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
. auto/feature
@@ -57,15 +58,16 @@
else
if [ $SHA1 = NO ]; then
- # OpenSSL crypto library
+ # OpenSSL crypto library
- ngx_feature="OpenSSL sha1 crypto library"
- ngx_feature_name=
- ngx_feature_run=no
- ngx_feature_incs="#include <openssl/sha.h>"
- ngx_feature_libs="-lcrypto"
- ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
- . auto/feature
+ ngx_feature="OpenSSL sha1 crypto library"
+ ngx_feature_name=
+ ngx_feature_run=no
+ ngx_feature_incs="#include <openssl/sha.h>"
+ ngx_feature_path=
+ ngx_feature_libs="-lcrypto"
+ ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
+ . auto/feature
fi
fi
diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf
index 3123c66..f033354 100644
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -47,6 +47,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <zlib.h>"
+ ngx_feature_path=
ngx_feature_libs="-lz"
ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
. auto/feature
diff --git a/auto/os/features b/auto/os/features
index 670de98..1e54f9d 100644
--- a/auto/os/features
+++ b/auto/os/features
@@ -30,6 +30,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <poll.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n, dp; struct pollfd pl;
dp = 0;
@@ -48,6 +49,7 @@
ngx_feature_name="NGX_HAVE_DEVPOLL"
ngx_feature_run=no
ngx_feature_incs="#include <sys/devpoll.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n, dp; struct dvpoll dvp;
dp = 0;
@@ -69,6 +71,7 @@
ngx_feature_name="NGX_HAVE_KQUEUE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq; kq = kqueue()"
. auto/feature
@@ -84,6 +87,7 @@
ngx_feature_name="NGX_HAVE_LOWAT_EVENT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct kevent kev;
kev.fflags = NOTE_LOWAT;"
@@ -95,6 +99,7 @@
ngx_feature_run=yes
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
@@ -126,6 +131,7 @@
ngx_feature_run=bug
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
+ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
@@ -174,6 +180,7 @@
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="crypt(\"test\", \"salt\");"
. auto/feature
@@ -182,6 +189,10 @@
if [ $ngx_found = no ]; then
ngx_feature="crypt() in libcrypt"
+ ngx_feature_name=
+ ngx_feature_run=no
+ ngx_feature_incs=
+ ngx_feature_path=
ngx_feature_libs=-lcrypt
. auto/feature
diff --git a/auto/os/linux b/auto/os/linux
index 4136486..abf61f1 100644
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -40,6 +40,7 @@
ngx_feature_name="NGX_HAVE_EPOLL"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/epoll.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int efd = 0, fd = 1, n;
struct epoll_event ee;
@@ -65,6 +66,7 @@
ngx_feature_run=yes
ngx_feature_incs="#include <sys/sendfile.h>
#include <errno.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
ssize_t n; off_t off = 0;
@@ -85,6 +87,7 @@
ngx_feature_run=yes
ngx_feature_incs="#include <sys/sendfile.h>
#include <errno.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
ssize_t n; off_t off = 0;
@@ -101,6 +104,7 @@
ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/prctl.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
. auto/feature
@@ -112,6 +116,7 @@
ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="long mask = 0;
sched_setaffinity(0, 32, (cpu_set_t *) &mask)"
diff --git a/auto/os/solaris b/auto/os/solaris
index 757013d..5a46ee6 100644
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -28,6 +28,7 @@
ngx_feature_name="NGX_HAVE_SENDFILE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/sendfile.h>"
+ngx_feature_path=
ngx_feature_libs="-lsendfile"
ngx_feature_test="int fd = 1; sendfilevec_t vec[1];
size_t sent; ssize_t n;
@@ -45,6 +46,7 @@
ngx_feature_name="NGX_HAVE_EVENTPORT"
ngx_feature_run=no
ngx_feature_incs="#include <port.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n = port_create()"
. auto/feature
diff --git a/auto/unix b/auto/unix
index 1cf0dc3..7c02ecc 100755
--- a/auto/unix
+++ b/auto/unix
@@ -68,6 +68,7 @@
ngx_feature_name="NGX_HAVE_SETPROCTITLE"
ngx_feature_run=no
ngx_feature_incs=
+ngx_feature_path=
ngx_feature_libs=$NGX_SETPROCTITLE_LIB
ngx_feature_test="setproctitle(\"test\");"
. auto/feature
@@ -77,6 +78,7 @@
ngx_feature_name="NGX_HAVE_PREAD"
ngx_feature_run=no
ngx_feature_incs=
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)"
. auto/feature
@@ -86,6 +88,7 @@
ngx_feature_name="NGX_HAVE_PWRITE"
ngx_feature_run=no
ngx_feature_incs=
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)"
. auto/feature
@@ -95,6 +98,7 @@
ngx_feature_name="NGX_HAVE_STRERROR_R"
ngx_feature_run=yes
ngx_feature_incs="#include <string.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024);
if (n < 0 || n > 1024) return 1;"
@@ -107,6 +111,7 @@
ngx_feature_name="NGX_HAVE_GNU_STRERROR_R"
ngx_feature_run=yes
ngx_feature_incs="#include <string.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024);
if (n >= 0 && n < 1024) return 1;"
@@ -117,6 +122,7 @@
ngx_feature_name="NGX_HAVE_LOCALTIME_R"
ngx_feature_run=no
ngx_feature_incs="#include <time.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
. auto/feature
@@ -126,6 +132,7 @@
ngx_feature_name="NGX_HAVE_POSIX_MEMALIGN"
ngx_feature_run=no
ngx_feature_incs="#include <stdlib.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)"
. auto/feature
@@ -135,6 +142,7 @@
ngx_feature_name="NGX_HAVE_MEMALIGN"
ngx_feature_run=no
ngx_feature_incs="#include <stdlib.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="void *p; p = memalign(4096, 4096)"
. auto/feature
@@ -144,6 +152,7 @@
ngx_feature_name="NGX_HAVE_SCHED_YIELD"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sched_yield()"
. auto/feature
@@ -153,6 +162,7 @@
ngx_feature_name="NGX_HAVE_MAP_ANON"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/mman.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="void *p;
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
@@ -167,6 +177,7 @@
ngx_feature_incs="#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='void *p; int fd;
fd = open("/dev/zero", O_RDWR);
@@ -180,6 +191,7 @@
ngx_feature_run=yes
ngx_feature_incs="#include <sys/ipc.h>
#include <sys/shm.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int id;
id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
@@ -192,6 +204,7 @@
ngx_feature_name="NGX_HAVE_MSGHDR_MSG_CONTROL"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct msghdr msg; msg.msg_control = NULL"
. auto/feature
@@ -202,6 +215,7 @@
ngx_feature_run=no
ngx_feature_incs="#include <sys/ioctl.h>
$NGX_INCLUDE_SYS_FILIO_H"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int i; i = FIONBIO"
. auto/feature
@@ -211,6 +225,7 @@
ngx_feature_name="NGX_HAVE_GMTOFF"
ngx_feature_run=no
ngx_feature_incs="#include <time.h>"
+ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0"
. auto/feature