diff options
Diffstat (limited to '')
-rw-r--r-- | auto/atomic | 114 | ||||
-rw-r--r-- | auto/cc/test | 209 | ||||
-rw-r--r-- | auto/clang | 135 | ||||
-rw-r--r-- | auto/echo/Makefile | 3 | ||||
-rw-r--r-- | auto/echo/build | 26 | ||||
-rw-r--r-- | auto/echo/echo.c | 43 | ||||
-rw-r--r-- | auto/events | 196 | ||||
-rw-r--r-- | auto/feature | 112 | ||||
-rw-r--r-- | auto/files | 51 | ||||
-rw-r--r-- | auto/have | 12 | ||||
-rw-r--r-- | auto/make | 255 | ||||
-rw-r--r-- | auto/malloc | 159 | ||||
-rw-r--r-- | auto/mmap | 87 | ||||
-rw-r--r-- | auto/modules/conf | 50 | ||||
-rw-r--r-- | auto/modules/python/conf | 54 | ||||
-rw-r--r-- | auto/modules/python/make | 24 | ||||
-rw-r--r-- | auto/options | 108 | ||||
-rw-r--r-- | auto/os/conf | 243 | ||||
-rw-r--r-- | auto/os/test | 93 | ||||
-rw-r--r-- | auto/pcre | 49 | ||||
-rw-r--r-- | auto/sendfile | 158 | ||||
-rw-r--r-- | auto/sockets | 233 | ||||
-rw-r--r-- | auto/sources | 326 | ||||
-rw-r--r-- | auto/ssltls | 184 | ||||
-rw-r--r-- | auto/test_build | 76 | ||||
-rw-r--r-- | auto/threads | 282 | ||||
-rw-r--r-- | auto/time | 226 | ||||
-rw-r--r-- | auto/types | 118 | ||||
-rw-r--r-- | auto/unix | 153 |
29 files changed, 3779 insertions, 0 deletions
diff --git a/auto/atomic b/auto/atomic new file mode 100644 index 00000000..6535bf74 --- /dev/null +++ b/auto/atomic @@ -0,0 +1,114 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# GCC 4.1+ builtin atomic operations. + +nxt_feature="GCC builtin atomic operations" +nxt_feature_name=NXT_HAVE_GCC_ATOMIC +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="int main() { + long n = 0; + + if (!__sync_bool_compare_and_swap(&n, 0, 3)) + return 1; + if (__sync_fetch_and_add(&n, 1) != 3) + return 1; + if (__sync_lock_test_and_set(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + __sync_lock_release(&n); + if (n != 0) + return 1; + return 0; + }" +. auto/feature + + +# Solaris 10 builtin atomic operations. + +if [ $nxt_found = no ]; then + + nxt_feature="Solaris builtin atomic operations" + nxt_feature_name=NXT_HAVE_SOLARIS_ATOMIC + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <atomic.h> + + int main() { + ulong_t n = 0; + + if (atomic_cas_ulong(&n, 0, 3) != 0) + return 1; + if (atomic_add_long_nv(&n, 1) != 4) + return 1; + if (atomic_swap_ulong(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + return 0; + }" + . auto/feature +fi + + +# AIX xlC builtin atomic operations. + +if [ $nxt_found = no ]; then + + if [ $NXT_64BIT = 1 ]; then + nxt_feature_test="int main() { + long n = 0; + long o = 0; + + if (!__compare_and_swaplp(&n, &o, 3)) + return 1; + if (__fetch_and_addlp(&n, 1) != 3) + return 1; + if (__fetch_and_swaplp(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + __isync(); + __lwsync(); + return 0; + }" + else + nxt_feature_test="int main() { + int n = 0; + int o = 0; + + if (!__compare_and_swap(&n, &o, 3)) + return 1; + if (__fetch_and_add(&n, 1) != 3) + return 1; + if (__fetch_and_swap(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + __isync(); + __lwsync(); + return 0; + }" + fi + + nxt_feature="xlC builtin atomic operations" + nxt_feature_name=NXT_HAVE_XLC_ATOMIC + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + . auto/feature +fi + + +if [ $nxt_found = no ]; then + $echo + $echo $0: error: no atomic operations found. + $echo + exit 1; +fi diff --git a/auto/cc/test b/auto/cc/test new file mode 100644 index 00000000..9c9602db --- /dev/null +++ b/auto/cc/test @@ -0,0 +1,209 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +$echo checking for C compiler: $CC +cat << END >> $NXT_AUTOCONF_ERR +---------------------------------------- +checking for C compiler: $CC +END + + +# Allow error exit status. +set +e + +if [ -z `which $CC` ]; then + $echo + $echo $0: error: $CC not found. + $echo + exit 1; +fi + + +if `/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=gcc + $echo " + using GNU C compiler" + NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" 2>&1` + $echo " + $NXT_CC_VERSION" + +else +if `/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=clang + $echo " + using Clang C compiler" + NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" 2>&1` + $echo " + $NXT_CC_VERSION" + +else +if `/bin/sh -c "($CC -v)" 2>&1 \ + | grep "Apple LLVM version" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=clang + $echo " + using Clang C compiler" + NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "Apple LLVM version" 2>&1` + $echo " + $NXT_CC_VERSION" + +else +if `/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=SunC + $echo " + using Sun C compiler" + NXT_CC_VERSION=`/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" 2>&1` + $echo " + $NXT_CC_VERSION" + +else +if `/bin/sh -c "($CC -qversion)" 2>&1 \ + | grep "^IBM XL" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=xlC + $echo " + using AIX xlC compiler" + NXT_CC_VERSION=`/bin/sh -c "($CC -qversion)" 2>&1 | grep "IBM XL" 2>&1` + $echo " + $NXT_CC_VERSION" + +else +if `/bin/sh -c "($CC -V)" 2>&1 | grep "Intel(R) C" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=ICC + $echo " + using Intel C++ compiler" + NXT_CC_VERSION=ICC + +else +if `/bin/sh -c "($CC -v)" 2>&1 \ + | grep "Microsoft (R) 32-bit C/C" >> $NXT_AUTOCONF_ERR 2>&1` +then + NXT_CC_NAME=MSVC + $echo " + using MS Visual C++ compiler" + NXT_CC_VERSION=MSVC + +else + NXT_CC_NAME=cc + NXT_CC_VERSION=cc + +fi # MSVC +fi # ICC +fi # xlC +fi # SunC +fi # Apple LLVM clang +fi # clang +fi # gcc + + +case $NXT_CC_NAME in + + gcc) + nxt_have=NXT_GCC . auto/have + + NXT_CFLAGS="$NXT_CFLAGS -pipe" + NXT_CFLAGS="$NXT_CFLAGS -fPIC" + + # Do not export symbols except explicitly marked with NXT_EXPORT. + NXT_CFLAGS="$NXT_CFLAGS -fvisibility=hidden" + + # c99/gnu99 conflict with Solaris XOPEN. + #NXT_CFLAGS="$NXT_CFLAGS -std=gnu99" + + NXT_CFLAGS="$NXT_CFLAGS -O" + #NXT_CFLAGS="$NXT_CFLAGS -O0" + NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra" + + #NXT_CFLAGS="$NXT_CFLAGS -Wunused-result" + NXT_CFLAGS="$NXT_CFLAGS -Wno-unused-parameter" + #NXT_CFLAGS="$NXT_CFLAGS -Wshorten-64-to-32" + NXT_CFLAGS="$NXT_CFLAGS -Wwrite-strings" + + # -O2 enables -fstrict-aliasing and -fstrict-overflow. + #NXT_CFLAGS="$NXT_CFLAGS -O2" + #NXT_CFLAGS="$NXT_CFLAGS -Wno-strict-aliasing" + + #NXT_CFLAGS="$NXT_CFLAGS -fomit-frame-pointer" + #NXT_CFLAGS="$NXT_CFLAGS -momit-leaf-frame-pointer" + + # -Wstrict-overflow is supported by GCC 4.2+. + #NXT_CFLAGS="$NXT_CFLAGS -Wstrict-overflow=5" + + NXT_CFLAGS="$NXT_CFLAGS -Wmissing-prototypes" + + # Stop on warning. + NXT_CFLAGS="$NXT_CFLAGS -Werror" + + # Debug. + NXT_CFLAGS="$NXT_CFLAGS -g" + ;; + + clang) + nxt_have=NXT_CLANG . auto/have + + NXT_CFLAGS="$NXT_CFLAGS -pipe" + NXT_CFLAGS="$NXT_CFLAGS -fPIC" + + # Do not export symbols except explicitly marked with NXT_EXPORT. + NXT_CFLAGS="$NXT_CFLAGS -fvisibility=hidden" + + NXT_CFLAGS="$NXT_CFLAGS -O" + #NXT_CFLAGS="$NXT_CFLAGS -O0" + NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra" + + #NXT_CFLAGS="$NXT_CFLAGS -Wunused-result" + NXT_CFLAGS="$NXT_CFLAGS -Wno-unused-parameter" + #NXT_CFLAGS="$NXT_CFLAGS -Wshorten-64-to-32" + NXT_CFLAGS="$NXT_CFLAGS -Wwrite-strings" + #NXT_CFLAGS="$NXT_CFLAGS -O2" + #NXT_CFLAGS="$NXT_CFLAGS -fomit-frame-pointer" + NXT_CFLAGS="$NXT_CFLAGS -fstrict-aliasing" + NXT_CFLAGS="$NXT_CFLAGS -Wstrict-overflow=5" + + NXT_CFLAGS="$NXT_CFLAGS -Wmissing-prototypes" + + # Stop on warning. + NXT_CFLAGS="$NXT_CFLAGS -Werror" + + # Debug. + + if [ "$NXT_SYSTEM_PLATFORM" != "powerpc" ]; then + # "-g" flag causes the "unknown pseudo-op: `.cfi_sections'" + # error on PowerPC Clang. + NXT_CFLAGS="$NXT_CFLAGS -g" + fi + ;; + + SunC) + nxt_have=NXT_SUNC . auto/have + + NXT_CFLAGS="$NXT_CFLAGS -fPIC" + # Optimization. + NXT_CFLAGS="$NXT_CFLAGS -O -fast" + # Stop on warning. + NXT_CFLAGS="$NXT_CFLAGS -errwarn=%all" + # Debug. + NXT_CFLAGS="$NXT_CFLAGS -g" + ;; + + xlC) + nxt_have=NXT_XLC . auto/have + + #NXT_CFLAGS="$NXT_CFLAGS -qalloca" + # alloca support. + NXT_CFLAGS="$NXT_CFLAGS -qlanglvl=extc99" + # __thread support. + NXT_CFLAGS="$NXT_CFLAGS -qtls" + # Suppress warning + # 1506-159 (E) Bit field type specified for XXX is not valid. + # Type unsigned assumed. + NXT_CFLAGS="$NXT_CFLAGS -qsuppress=1506-159" + ;; + + ICC) + ;; + + MSVC) + ;; + + *) + ;; + +esac + +# Stop on error exit status again. +set -e diff --git a/auto/clang b/auto/clang new file mode 100644 index 00000000..fc69bf6f --- /dev/null +++ b/auto/clang @@ -0,0 +1,135 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# C language features. + + +nxt_feature="C99 variadic macro" +nxt_feature_name=NXT_HAVE_C99_VARIADIC_MACRO +nxt_feature_run=yes +nxt_feature_path= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #define set(dummy, ...) sprintf(__VA_ARGS__) + + int main() { + char buf[4]; + + buf[0] = '0'; + set(0, buf, \"%d\", 1); + + if (buf[0] == '1') + return 0; + return 1; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + nxt_feature="GCC variadic macro" + nxt_feature_name=NXT_HAVE_GCC_VARIADIC_MACRO + nxt_feature_run=yes + nxt_feature_path= + nxt_feature_libs= + nxt_feature_test="#include <stdio.h> + #define set(dummy, args...) sprintf(args) + + int main() { + char buf[4]; + + buf[0] = '0'; + set(0, buf, \"%d\", 1); + + if (buf[0] == '1') + return 0; + return 1; + }" + . auto/feature +fi + + +nxt_feature="GCC __builtin_expect()" +nxt_feature_name=NXT_HAVE_BUILTIN_EXPECT +nxt_feature_run=no +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="int main(int argc, char *const *argv) { + if ((__typeof__(argc == 0)) + __builtin_expect((argc == 0), 0)) + return 0; + return 1; + }" +. auto/feature + + +nxt_feature="GCC __builtin_unreachable()" +nxt_feature_name=NXT_HAVE_BUILTIN_UNREACHABLE +nxt_feature_run=no +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="int main() { + __builtin_unreachable(); + }" +. auto/feature + + +nxt_feature="GCC __builtin_prefetch()" +nxt_feature_name=NXT_HAVE_BUILTIN_PREFETCH +nxt_feature_run=no +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="int main() { + __builtin_prefetch(0); + }" +. auto/feature + + +nxt_feature="GCC __attribute__ visibility" +nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_VISIBILITY +nxt_feature_run= +nxt_feature_path= +nxt_feature_libs= +nxt_feature_test="int n __attribute__ ((visibility(\"default\"))); + + int main() { + return 1; + }" +. auto/feature + + +nxt_feature="GCC __attribute__ aligned" +nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_ALIGNED +nxt_feature_run= +nxt_feature_path= +nxt_feature_libs= +nxt_feature_test="int n __attribute__ ((aligned(64))); + + int main() { + return 1; + }" +. auto/feature + + +nxt_feature="GCC __attribute__ malloc" +nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_MALLOC +nxt_feature_run= +nxt_feature_path= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + + void *f(void) __attribute__ ((__malloc__)); + + void *f(void) { + return malloc(1); + } + + int main() { + if (f() != NULL) { + return 1; + } + return 0; + }" +. auto/feature diff --git a/auto/echo/Makefile b/auto/echo/Makefile new file mode 100644 index 00000000..28a519c3 --- /dev/null +++ b/auto/echo/Makefile @@ -0,0 +1,3 @@ + +echo.exe: echo.c + mingw32-gcc -o echo.exe -O2 echo.c diff --git a/auto/echo/build b/auto/echo/build new file mode 100644 index 00000000..10670f74 --- /dev/null +++ b/auto/echo/build @@ -0,0 +1,26 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +$echo 'building an "echo" program' + +rm -f $NXT_BUILD_DIR/echo + +nxt_echo_test="$CC -o $NXT_BUILD_DIR/echo -O $NXT_CC_OPT + auto/echo/echo.c $NXT_LD_OPT" + +nxt_echo_err=`$nxt_echo_test 2>&1` + +if [ ! -x $NXT_BUILD_DIR/echo ]; then + $echo + $echo $0: error: cannot build an \"echo\" program: + $echo + $echo $nxt_echo_test + $echo + $echo $nxt_echo_err + $echo + exit 1 +fi + +echo=$NXT_BUILD_DIR/echo diff --git a/auto/echo/echo.c b/auto/echo/echo.c new file mode 100644 index 00000000..937483af --- /dev/null +++ b/auto/echo/echo.c @@ -0,0 +1,43 @@ + +/* + * Copyright (C) Igor Sysoev + * Copyright (C) NGINX, Inc. + * + * A portable "echo" program that supports "-n" option: + * echo Hello world! + * echo "Hello world!" + * echo -n Hello world! + * echo + * + * It also passes "\c" characters as is. + */ + + +#include <stdio.h> +#include <string.h> + + +int +main(int argc, char *const *argv) +{ + int i = 1; + int nl = 1; + + if (argc > 1) { + if (strcmp(argv[1], "-n") == 0) { + nl = 0; + i++; + } + + while (i < argc) { + printf("%s%s", argv[i], (i == argc - 1) ? "" : " "); + i++; + } + } + + if (nl) { + printf("\n"); + } + + return 0; +} diff --git a/auto/events b/auto/events new file mode 100644 index 00000000..700dc20c --- /dev/null +++ b/auto/events @@ -0,0 +1,196 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Linux epoll. + +nxt_feature="Linux epoll" +nxt_feature_name=NXT_HAVE_EPOLL +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <sys/epoll.h> + #include <unistd.h> + + int main() { + int n; + + n = epoll_create(1); + close(n); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_HAVE_EPOLL=YES + + nxt_feature="Linux signalfd()" + nxt_feature_name=NXT_HAVE_SIGNALFD + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <signal.h> + #include <sys/signalfd.h> + #include <unistd.h> + + int main() { + int n; + sigset_t mask; + + sigemptyset(&mask); + n = signalfd(-1, &mask, 0); + close(n); + return 0; + }" + . auto/feature + + + nxt_feature="Linux eventfd()" + nxt_feature_name=NXT_HAVE_EVENTFD + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <sys/eventfd.h> + #include <unistd.h> + + int main() { + int n; + + n = eventfd(0, 0); + close(n); + return 0; + }" + . auto/feature + +else + NXT_HAVE_EPOLL=NO +fi + + +# FreeBSD, MacOSX, NetBSD, OpenBSD kqueue. + +nxt_feature="kqueue" +nxt_feature_name=NXT_HAVE_KQUEUE +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <sys/types.h> + #include <sys/event.h> + #include <unistd.h> + + int main() { + int n; + + n = kqueue(); + close(n); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_HAVE_KQUEUE=YES + + nxt_feature="kqueue EVFILT_USER" + nxt_feature_name=NXT_HAVE_EVFILT_USER + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <stdlib.h> + #include <sys/types.h> + #include <sys/event.h> + + int main() { + struct kevent kev; + + kev.filter = EVFILT_USER; + kevent(0, &kev, 1, NULL, 0, NULL); + return 0; + }" + . auto/feature + +else + NXT_HAVE_KQUEUE=NO +fi + + +# Solaris event port. + +nxt_feature="Solaris event port" +nxt_feature_name=NXT_HAVE_EVENTPORT +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <port.h> + #include <unistd.h> + + int main() { + int n; + + n = port_create(); + close(n); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_HAVE_EVENTPORT=YES +else + NXT_HAVE_EVENTPORT=NO +fi + + +# Solaris, HP-UX, IRIX, Tru64 UNIX /dev/poll. + +nxt_feature="/dev/poll" +nxt_feature_name=NXT_HAVE_DEVPOLL +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <fcntl.h> + #include <sys/ioctl.h> + #include <sys/devpoll.h> + #include <unistd.h> + + int main() { + int n; + + n = open(\"/dev/poll\", O_RDWR); + close(n); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_HAVE_DEVPOLL=YES +else + NXT_HAVE_DEVPOLL=NO +fi + + +# AIX pollset. + +nxt_feature="AIX pollset" +nxt_feature_name=NXT_HAVE_POLLSET +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <fcntl.h> + #include <sys/poll.h> + #include <sys/pollset.h> + #include <unistd.h> + + int main() { + pollset_t n; + + n = pollset_create(-1); + pollset_destroy(n); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_HAVE_POLLSET=YES +else + NXT_HAVE_POLLSET=NO +fi diff --git a/auto/feature b/auto/feature new file mode 100644 index 00000000..f7e7f25d --- /dev/null +++ b/auto/feature @@ -0,0 +1,112 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +$echo -n "checking for $nxt_feature ..." + +cat << END >> $NXT_AUTOCONF_ERR +---------------------------------------- +checking for $nxt_feature +END + + +nxt_found=no +nxt_feature_value= +nxt_feature_inc_path= + +if test -n "$nxt_feature_incs"; then + case "$nxt_feature_incs" in + -*) + nxt_feature_inc_path="$nxt_feature_incs" + ;; + + *) + for nxt_temp in $nxt_feature_incs; do + nxt_feature_inc_path="$nxt_feature_inc_path -I $nxt_temp" + done + ;; + esac +fi + + +cat << END > $NXT_AUTOTEST.c +$nxt_feature_test +END + + +nxt_test="$CC $CFLAGS $NXT_CFLAGS $NXT_CC_OPT $NXT_TEST_CFLAGS \ + $nxt_feature_inc_path -o $NXT_AUTOTEST $NXT_AUTOTEST.c \ + $NXT_LD_OPT $NXT_TEST_LIBS $nxt_feature_libs" + +# /bin/sh -c "(...)" is to intercept "Killed", "Abort trap", +# "Segmentation fault", or other shell messages. +# "|| true" is to bypass "set -e" setting. + +/bin/sh -c "($nxt_test || true)" >> $NXT_AUTOCONF_ERR 2>&1 + + +if [ -x $NXT_AUTOTEST ]; then + + case "$nxt_feature_run" in + + value) + if /bin/sh -c "($NXT_AUTOTEST)" >> $NXT_AUTOCONF_ERR 2>&1; then + $echo >> $NXT_AUTOCONF_ERR + nxt_found=yes + nxt_feature_value=`$NXT_AUTOTEST` + $echo " $nxt_feature_value" + if [ -n "$nxt_feature_name" ]; then + cat << END >> $NXT_AUTO_CONFIG_H + +#ifndef $nxt_feature_name +#define $nxt_feature_name $nxt_feature_value +#endif + +END + fi + else + $echo " not found" + fi + ;; + + yes) + if /bin/sh -c "($NXT_AUTOTEST)" >> $NXT_AUTOCONF_ERR 2>&1; then + $echo " found" + nxt_found=yes + cat << END >> $NXT_AUTO_CONFIG_H + +#ifndef $nxt_feature_name +#define $nxt_feature_name 1 +#endif + +END + else + $echo " found but is not working" + fi + ;; + + *) + $echo " found" + nxt_found=yes + cat << END >> $NXT_AUTO_CONFIG_H + +#ifndef $nxt_feature_name +#define $nxt_feature_name 1 +#endif + +END + ;; + esac + +else + $echo " not found" + + $echo "----------" >> $NXT_AUTOCONF_ERR + cat $NXT_AUTOTEST.c >> $NXT_AUTOCONF_ERR + $echo "----------" >> $NXT_AUTOCONF_ERR + $echo $nxt_test >> $NXT_AUTOCONF_ERR + $echo "----------" >> $NXT_AUTOCONF_ERR +fi + +rm -rf $NXT_AUTOTEST* diff --git a/auto/files b/auto/files new file mode 100644 index 00000000..d99e93d7 --- /dev/null +++ b/auto/files @@ -0,0 +1,51 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Linux 2.6, FreeBSD 8.2, 9.1, Solaris 11. + +nxt_feature="posix_fadvise()" +nxt_feature_name=NXT_HAVE_POSIX_FADVISE +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <fcntl.h> + + int main() { + (void) posix_fadvise(0, 0, 0, POSIX_FADV_WILLNEED); + return 0; + }" +. auto/feature + + +# FreeBSD 8.0. + +nxt_feature="fcntl(F_READAHEAD)" +nxt_feature_name=NXT_HAVE_READAHEAD +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <fcntl.h> + + int main() { + (void) fcntl(0, F_READAHEAD, 1024); + return 0; + }" +. auto/feature + + +# MacOSX, FreeBSD 8.0. + +nxt_feature="fcntl(F_RDAHEAD)" +nxt_feature_name=NXT_HAVE_RDAHEAD +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <fcntl.h> + + int main() { + (void) fcntl(0, F_RDAHEAD, 1); + return 0; + }" +. auto/feature diff --git a/auto/have b/auto/have new file mode 100644 index 00000000..b10b8394 --- /dev/null +++ b/auto/have @@ -0,0 +1,12 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +cat << END >> $NXT_AUTO_CONFIG_H + +#ifndef $nxt_have +#define $nxt_have 1 +#endif + +END diff --git a/auto/make b/auto/make new file mode 100644 index 00000000..6fe76d2f --- /dev/null +++ b/auto/make @@ -0,0 +1,255 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) Valentin V. Bartenev +# Copyright (C) NGINX, Inc. + + +$echo "creating $NXT_MAKEFILE" + +mkdir -p $NXT_BUILD_DIR/src \ + $NXT_BUILD_DIR/test + + +cat << END > $NXT_MAKEFILE + +CC = $CC + +CFLAGS = $CFLAGS $NXT_CFLAGS $NXT_CC_OPT + +NXT_EXEC_LINK = $NXT_EXEC_LINK $NXT_LD_OPT +NXT_SHARED_LOCAL_LINK = $NXT_SHARED_LOCAL_LINK $NXT_LD_OPT +NXT_MODULE_LINK = $NXT_MODULE_LINK $NXT_LD_OPT + +END + + +# The include paths list. + +$echo -n "NXT_LIB_INCS =" >> $NXT_MAKEFILE + +for nxt_inc in src $NXT_BUILD_DIR +do + $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE +done + +$echo >> $NXT_MAKEFILE +$echo >> $NXT_MAKEFILE + + +# The include files dependences list. + +$echo "NXT_LIB_DEPS = \\" >> $NXT_MAKEFILE + +for nxt_dep in $NXT_LIB_DEPS $NXT_LIB_UNIT_TEST_DEPS $NXT_AUTO_CONFIG_H +do + $echo " $nxt_dep \\" >> $NXT_MAKEFILE +done + +$echo >> $NXT_MAKEFILE +$echo >> $NXT_MAKEFILE + + +# Library object files list. + +$echo "NXT_LIB_OBJS = \\" >> $NXT_MAKEFILE + +for nxt_src in $NXT_LIB_SRCS +do + nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"` + $echo " $NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE +done + +$echo >> $NXT_MAKEFILE + + +# Shared and static library. + +cat << END >> $NXT_MAKEFILE + +libnxt: $NXT_BUILD_DIR/$NXT_LIB_SHARED $NXT_BUILD_DIR/$NXT_LIB_STATIC + +$NXT_BUILD_DIR/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS) + \$(NXT_SHARED_LOCAL_LINK) -o $NXT_BUILD_DIR/$NXT_LIB_SHARED \\ + \$(NXT_LIB_OBJS) \\ + $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS + +$NXT_BUILD_DIR/$NXT_LIB_STATIC: \$(NXT_LIB_OBJS) + $NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + \$(NXT_LIB_OBJS) + +END + + +# Object files. + +for nxt_src in $NXT_LIB_SRCS $NXT_LIB_UNIT_TEST_SRCS +do + nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"` + cat << END >> $NXT_MAKEFILE + +$NXT_BUILD_DIR/$nxt_obj: $nxt_src \$(NXT_LIB_DEPS) + \$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\ + -o $NXT_BUILD_DIR/$nxt_obj \\ + $nxt_src +END + +done + +$echo >> $NXT_MAKEFILE + + +# Unit test object files list. + +$echo "NXT_LIB_UNIT_TEST_OBJS = \\" >> $NXT_MAKEFILE + +for nxt_src in $NXT_LIB_UNIT_TEST_SRCS +do + nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"` + $echo " $NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE +done + + +# Unit test and utf8 test executables. + +cat << END >> $NXT_MAKEFILE + +$NXT_BUILD_DIR/lib_unit_test: \$(NXT_LIB_UNIT_TEST_OBJS) \\ + $NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS) + \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/lib_unit_test \\ + \$(NXT_LIB_UNIT_TEST_OBJS) \\ + $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS + +$NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\ + $NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS) + \$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\ + -o $NXT_BUILD_DIR/utf8_file_name_test \\ + $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\ + $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_LD_OPT $NXT_LIBM $NXT_LIBS + +END + + +if [ $NXT_LIB_UNIT_TEST = YES ]; then + NXT_UNIT_TEST_TARGETS="$NXT_UNIT_TEST_TARGETS lib_test" +fi + + +NXT_MAKE_INCS="src $NXT_BUILD_DIR" +NXT_MAKE_DEPS="\$(NXT_LIB_DEPS) $NXT_DEPS" +NXT_MAKE_SRCS="$NXT_SRCS" + + +# The include pathes list. + +$echo -n "NXT_INCS =" >> $NXT_MAKEFILE + +for nxt_inc in $NXT_MAKE_INCS +do + $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE +done + +$echo >> $NXT_MAKEFILE +$echo >> $NXT_MAKEFILE + + +# The include files dependences list. + +$echo "NXT_DEPS = \\" >> $NXT_MAKEFILE + +for nxt_dep in $NXT_MAKE_DEPS +do + $echo " $nxt_dep \\" >> $NXT_MAKEFILE +done + +$echo >> $NXT_MAKEFILE +$echo >> $NXT_MAKEFILE + + +# Object files list. + +nxt_modules_obj=`$echo $NXT_MODULES_SRC | sed -e "s/\.c$/\.o/"` + +$echo "NXT_OBJS = \\" >> $NXT_MAKEFILE + +for nxt_src in $NXT_MAKE_SRCS $NXT_MODULES_SRCS +do + nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"` + $echo " $NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE +done + +$echo " $nxt_modules_obj" >> $NXT_MAKEFILE +$echo >> $NXT_MAKEFILE + + +# nginext executable. + +NXT_BIN=nginext + +cat << END >> $NXT_MAKEFILE + +$NXT_BUILD_DIR/$NXT_BIN: $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + \$(NXT_OBJS) + \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/$NXT_BIN \\ + \$(NXT_OBJS) $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS + +END + + +# nginext object files. + +for nxt_src in $NXT_MAKE_SRCS +do + nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"` + cat << END >> $NXT_MAKEFILE + +$NXT_BUILD_DIR/$nxt_obj: $nxt_src \$(NXT_DEPS) + \$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\ + $NXT_LIB_AUX_CFLAGS \\ + -o $NXT_BUILD_DIR/$nxt_obj \\ + $nxt_src +END + +done + + +# nxt_modules.c. + +cat << END >> $NXT_MAKEFILE + +$nxt_modules_obj: $NXT_MODULES_SRC \$(NXT_DEPS) + \$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\ + $NXT_LIB_AUX_CFLAGS \\ + -o $nxt_modules_obj \\ + $NXT_MODULES_SRC +END + + +if [ $NXT_PYTHON_MODULE != NO ]; then + . auto/modules/python/make +fi + + +# Makefile. +# *.dSYM is MacOSX Clang debug information. + +cat << END > Makefile + +all: libnxt $NXT_BIN + +libnxt: + make -f $NXT_MAKEFILE libnxt + +lib_test: + make -f $NXT_MAKEFILE $NXT_BUILD_DIR/lib_unit_test + make -f $NXT_MAKEFILE $NXT_BUILD_DIR/utf8_file_name_test + +clean: + rm -rf $NXT_BUILD_DIR *.dSYM Makefile + +$NXT_BIN: + make -f $NXT_MAKEFILE $NXT_BUILD_DIR/$NXT_BIN + +END diff --git a/auto/malloc b/auto/malloc new file mode 100644 index 00000000..c3372cfe --- /dev/null +++ b/auto/malloc @@ -0,0 +1,159 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Linux glibc 2.1.91, FreeBSD 7.0, Solaris 11, +# MacOSX 10.6 (Snow Leopard), NetBSD 5.0. + +nxt_feature="posix_memalign()" +nxt_feature_name=NXT_HAVE_POSIX_MEMALIGN +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + + int main() { + void *p; + + if (posix_memalign(&p, 4096, 4096) != 0) + return 1; + + free(p); + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # Solaris, HP-UX. + + nxt_feature="memalign()" + nxt_feature_name=NXT_HAVE_MEMALIGN + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <stdlib.h> + + int main() { + void *p; + + p = memalign(4096, 4096); + if (p == NULL) + return 1; + + free(p); + return 0; + }" + . auto/feature +fi + + +# Linux malloc_usable_size(). + +nxt_feature="Linux malloc_usable_size()" +nxt_feature_name=NXT_HAVE_MALLOC_USABLE_SIZE +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <malloc.h> + + int main() { + void *p; + + p = malloc(4096); + if (malloc_usable_size(p) < 4096) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # FreeBSD malloc_usable_size(). + + nxt_feature="FreeBSD malloc_usable_size()" + nxt_feature_name=NXT_HAVE_MALLOC_USABLE_SIZE + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <stdlib.h> + #include <malloc_np.h> + + int main() { + void *p; + + p = malloc(4096); + if (malloc_usable_size(p) < 4096) + return 1; + return 0; + }" + . auto/feature +fi + + +if [ $nxt_found = no ]; then + + # MacOSX malloc_good_size(). + + nxt_feature="MacOSX malloc_good_size()" + nxt_feature_name=NXT_HAVE_MALLOC_GOOD_SIZE + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <malloc/malloc.h> + + int main() { + if (malloc_good_size(4096) < 4096) + return 1; + return 0; + }" + . auto/feature +fi + + +# alloca(). + +# Linux, FreeBSD, MacOSX. + +nxt_feature="alloca()" +nxt_feature_name=NXT_HAVE_ALLOCA +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + + int main() { + void *p; + + p = alloca(256); + if (p == 0) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # Linux, Solaris, MacOSX. + + nxt_feature="alloca() in alloca.h" + nxt_feature_name=NXT_HAVE_ALLOCA_H + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <alloca.h> + + int main() { + void *p; + + p = alloca(256); + if (p == 0) + return 1; + return 0; + }" + . auto/feature +fi diff --git a/auto/mmap b/auto/mmap new file mode 100644 index 00000000..8ecdf670 --- /dev/null +++ b/auto/mmap @@ -0,0 +1,87 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Linux, FreeBSD, Solaris, MacOSX. + +nxt_feature="MAP_ANON" +nxt_feature_name=NXT_HAVE_MAP_ANON +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + #include <sys/mman.h> + + int main() { + if (mmap(NULL, 4096, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0) + == MAP_FAILED) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # Linux, Solaris, HP-UX. + + nxt_feature="MAP_ANONYMOUS" + nxt_feature_name=NXT_HAVE_MAP_ANONYMOUS + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <stdlib.h> + #include <sys/mman.h> + + int main() { + if (mmap(NULL, 4096, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) + == MAP_FAILED) + return 1; + return 0; + }" + . auto/feature +fi + + +# Linux. + +nxt_feature="MAP_POPULATE" +nxt_feature_name=NXT_HAVE_MAP_POPULATE +nxt_feature_run=no +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + #include <sys/mman.h> + + int main() { + if (mmap(NULL, 4096, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_POPULATE, -1, 0) + == MAP_FAILED) + return 1; + return 0; + }" +. auto/feature + + +# FreeBSD. + +nxt_feature="MAP_PREFAULT_READ" +nxt_feature_name=NXT_HAVE_MAP_PREFAULT_READ +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + #include <sys/mman.h> + + int main() { + if (mmap(NULL, 4096, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON | MAP_PREFAULT_READ, + -1, 0) + == MAP_FAILED) + return 1; + return 0; + }" +. auto/feature diff --git a/auto/modules/conf b/auto/modules/conf new file mode 100644 index 00000000..141bd098 --- /dev/null +++ b/auto/modules/conf @@ -0,0 +1,50 @@ + +# Copyright (C) NGINX, Inc. +# Copyright (C) Valentin V. Bartenev + + +NXT_MODULES_INIT= +NXT_MODULES_SRCS= + + +if [ $NXT_PYTHON_MODULE != NO ]; then + . auto/modules/python/conf +fi + + +NXT_MODULES_SRC=$NXT_BUILD_DIR/nxt_modules.c + + +cat << END > $NXT_MODULES_SRC + +#include <nxt_main.h> +#include <nxt_cycle.h> + + +END + + +for nxt_init in $NXT_MODULES_INIT +do + $echo "extern nxt_int_t $nxt_init(nxt_thread_t *thr, nxt_cycle_t *cycle);" \ + >> $NXT_MODULES_SRC +done + + +cat << END >> $NXT_MODULES_SRC + + +nxt_module_init_t nxt_init_modules[] = { +END + +for nxt_init in $NXT_MODULES_INIT +do + $echo " $nxt_init," >> $NXT_MODULES_SRC +done + +cat << END >> $NXT_MODULES_SRC +}; + + +nxt_uint_t nxt_init_modules_n = nxt_nitems(nxt_init_modules); +END diff --git a/auto/modules/python/conf b/auto/modules/python/conf new file mode 100644 index 00000000..1c298a2d --- /dev/null +++ b/auto/modules/python/conf @@ -0,0 +1,54 @@ + +# Copyright (C) NGINX, Inc. +# Copyright (C) Valentin V. Bartenev + + +NXT_PYTHON_VERSION=`${NXT_PYTHON} -c \ + 'import sysconfig, sys; \ + sys.stdout.write(sysconfig.get_python_version())'` + +NXT_PYTHON_INCLUDE=`${NXT_PYTHON} -c \ + 'import sysconfig, sys; \ + sys.stdout.write(sysconfig.get_path("platinclude"))'` + +NXT_PYTHON_LIB="-lpython${NXT_PYTHON_VERSION}" + +NXT_PYTHON_LIBS=`${NXT_PYTHON} -c \ + 'import sysconfig, sys; \ + sys.stdout.write(sysconfig.get_config_var("SYSLIBS") \ + + " " + sysconfig.get_config_var("LIBS"))'` + + +nxt_feature="Python" +nxt_feature_name=NXT_HAVE_PYTHON +nxt_feature_run=no +nxt_feature_incs="-I${NXT_PYTHON_INCLUDE}" +nxt_feature_libs="$NXT_PYTHON_LIB $NXT_PYTHON_LIBS" +nxt_feature_test="#include <Python.h> + + int main() { + Py_Initialize(); + }" + +. auto/feature + +if [ $nxt_found = no ]; then + $echo + $echo $0: error: no Python found. + $echo + exit 1; +fi + + +$echo " + Python version: ${NXT_PYTHON_VERSION}" + + +NXT_PYTHON_MODULE_SRCS=" \ + src/nxt_python_wsgi.c \ +" + + +NXT_MODULES_INIT="$NXT_MODULES_INIT nxt_python_wsgi_init" +NXT_MODULES_SRCS="$NXT_MODULES_SRCS $NXT_PYTHON_MODULE_SRCS" + +NXT_LIB_AUX_LIBS="$NXT_LIB_AUX_LIBS $NXT_PYTHON_LIB $NXT_PYTHON_LIBS" diff --git a/auto/modules/python/make b/auto/modules/python/make new file mode 100644 index 00000000..edb8f0c0 --- /dev/null +++ b/auto/modules/python/make @@ -0,0 +1,24 @@ + +# Copyright (C) NGINX, Inc. +# Copyright (C) Valentin V. Bartenev + + +$echo >> $NXT_MAKEFILE +$echo >> $NXT_MAKEFILE + + +# The python module object files. + +for nxt_src in $NXT_PYTHON_MODULE_SRCS +do + nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"` + cat << END >> $NXT_MAKEFILE + +$NXT_BUILD_DIR/$nxt_obj: $nxt_src + \$(CC) -c \$(CFLAGS) \$(NXT_INCS) -I $NXT_PYTHON_INCLUDE \\ + $NXT_LIB_AUX_CFLAGS \\ + -o $NXT_BUILD_DIR/$nxt_obj \\ + $nxt_src +END + +done diff --git a/auto/options b/auto/options new file mode 100644 index 00000000..e4b4d72d --- /dev/null +++ b/auto/options @@ -0,0 +1,108 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) Valentin V. Bartenev +# Copyright (C) NGINX, Inc. + + +CC=${CC:-cc} + +NXT_BUILD_DIR=build +NXT_CONFIGURE_OPTIONS= +NXT_CFLAGS= +NXT_CC_OPT= +NXT_LD_OPT= + +NXT_DEBUG=NO +NXT_THREADS=YES + +NXT_INET6=NO +NXT_UNIX_DOMAIN=YES + +NXT_REGEX=NO +NXT_PCRE=NO + +NXT_SSLTLS=NO +NXT_OPENSSL=NO +NXT_GNUTLS=NO +NXT_CYASSL=NO +NXT_POLARSSL=NO + +NXT_TEST_BUILD_EPOLL=NO +NXT_TEST_BUILD_EVENTPORT=NO +NXT_TEST_BUILD_DEVPOLL=NO +NXT_TEST_BUILD_POLLSET=NO + +NXT_TEST_BUILD_FREEBSD_SENDFILE=NO +NXT_TEST_BUILD_LINUX_SENDFILE=NO +NXT_TEST_BUILD_MACOSX_SENDFILE=NO +NXT_TEST_BUILD_SOLARIS_SENDFILEV=NO +NXT_TEST_BUILD_AIX_SEND_FILE=NO +NXT_TEST_BUILD_HPUX_SENDFILE=NO + +NXT_LIB_UNIT_TEST=NO + +NXT_PYTHON=python +NXT_PYTHON_MODULE=NO + + +for nxt_option +do + case "$nxt_option" in + -*=*) value=`$echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) value="" ;; + esac + + case "$nxt_option" in + --with-cc=*) CC="$value" ;; + --with-cc-opt=*) NXT_CC_OPT="$value" ;; + --with-ld-opt=*) NXT_LD_OPT="$value" ;; + + --build-dir=*) NXT_BUILD_DIR="$value" ;; + + --with-debug) NXT_DEBUG=YES ;; + + --with-threads) NXT_THREADS=YES ;; + --without-threads) NXT_THREADS=NO ;; + + --with-ipv6) NXT_INET6=YES ;; + --with-inet6) NXT_INET6=YES ;; + --without-unix-domain) NXT_UNIX_DOMAIN=NO ;; + + --with-pcre) NXT_PCRE=YES ;; + + --with-ssltls) NXT_SSLTLS=YES ;; + --with-openssl) NXT_OPENSSL=YES ;; + --with-gnutls) NXT_GNUTLS=YES ;; + --with-cyassl) NXT_CYASSL=YES ;; + --with-polarssl) NXT_POLARSSL=YES ;; + + --test-build-epoll) NXT_TEST_BUILD_EPOLL=YES ;; + --test-build-eventport) NXT_TEST_BUILD_EVENTPORT=YES ;; + --test-build-devpoll) NXT_TEST_BUILD_DEVPOLL=YES ;; + --test-build-pollset) NXT_TEST_BUILD_POLLSET=YES ;; + + --test-build-freebsd-sendfile) NXT_TEST_BUILD_FREEBSD_SENDFILE=YES ;; + --test-build-linux-sendfile) NXT_TEST_BUILD_LINUX_SENDFILE=YES ;; + --test-build-solaris-sendfilev) NXT_TEST_BUILD_SOLARIS_SENDFILEV=YES ;; + --test-build-macosx-sendfile) NXT_TEST_BUILD_MACOSX_SENDFILE=YES ;; + --test-build-aix-send_file) NXT_TEST_BUILD_AIX_SEND_FILE=YES ;; + --test-build-hpux-sendfile) NXT_TEST_BUILD_HPUX_SENDFILE=YES ;; + + --with-lib-unit-tests) NXT_LIB_UNIT_TEST=YES ;; + + --with-python=*) NXT_PYTHON="$value" ;; + --with-python_module) NXT_PYTHON_MODULE=YES ;; + + *) + $echo + $echo "$0: error: invalid option \"$nxt_option\"". + $echo + exit 1 + ;; + esac + + nxt_opt=`$echo $nxt_option | sed -e "s/\(--[^=]*=\)\(.* .*\)/\1'\2'/"` + + NXT_CONFIGURE_OPTIONS="$NXT_CONFIGURE_OPTIONS $nxt_opt" + +done diff --git a/auto/os/conf b/auto/os/conf new file mode 100644 index 00000000..3db382c6 --- /dev/null +++ b/auto/os/conf @@ -0,0 +1,243 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# To support dynamically loaded modules libnxt library must be a shared +# object itself because an application linked with static libnxt library +# may lack code required by the modules. Dynamic linkers allow to specify +# relative path in SONAME library entry or in RPATH executable entry. +# +# Solaris 7, Linux 2.2, and FreeBSD 7.3 support $ORIGIN variable. +# MacOSX supports @executable_path variable. +# NetBSD does not support $ORIGIN variable. +# +# "ar -r" is enough to create a static library, ranlib is surplus. +# "ar -c" disables the "creating archive" warning. + + +case "$NXT_SYSTEM" in + + Linux) + nxt_have=NXT_LINUX . auto/have + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared -Wl,-soname,libnxt.so" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared \ + -Wl,-soname,\\\$\$ORIGIN/libnxt.so" + NXT_MODULE_LINK="\$(CC) -shared" + NXT_MODULE_LINK="\$(CC) -shared" + + # "-Wl,-E" exports symbols of executable file. + NXT_EXEC_LINK="\$(CC) -Wl,-E" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_LIBRT $NXT_LIBDL $NXT_PTHREAD" + ;; + + FreeBSD) + nxt_have=NXT_FREEBSD . auto/have + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared -Wl,-soname,libnxt.so" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared \ + -Wl,-soname,\\\$\$ORIGIN/libnxt.so" + NXT_MODULE_LINK="\$(CC) -shared" + + # "-Wl,-E" exports symbols of executable file. + NXT_EXEC_LINK="\$(CC) -Wl,-E" + # "-Wl,-z,origin" enables $ORIGIN processing. + NXT_SHARED_LOCAL_EXEC_LINK="-Wl,-z,origin" + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_PTHREAD" + ;; + + SunOS) + nxt_have=NXT_SOLARIS . auto/have + + case "$NXT_CC_NAME" in + + SunC): + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -G -h libnxt.so" + NXT_SHARED_LOCAL_LINK="\$(CC) -G -h \\\$\$ORIGIN/libnxt.so" + NXT_MODULE_LINK="\$(CC) -G" + ;; + + *) + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared -Wl,-soname,libnxt.so" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared \ + -Wl,-soname,\\\$\$ORIGIN/libnxt.so" + NXT_MODULE_LINK="\$(CC) -shared" + ;; + esac + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIBM="-lm" + NXT_LIBS="-lsocket $NXT_LIBSENDFILE" + NXT_LIBS="$NXT_LIBS $NXT_LIBRT $NXT_LIBDL $NXT_PTHREAD" + ;; + + Darwin) + nxt_have=NXT_MACOSX . auto/have + + # HFS+ volumes are caseless by default. + nxt_have=NXT_HAVE_CASELESS_FILESYSTEM . auto/have + + # MacOSX 10.6 (Snow Leopard) has deprecated ucontext(3). + # MacOSX 10.7 (Lion) has deprecated system OpenSSL. + # MAC_OS_X_VERSION_MIN_REQUIRED macro does not help. + # The minimum version allowed for i386 is 10.4 (Tiger). + NXT_CFLAGS="$NXT_CFLAGS -mmacosx-version-min=10.4" + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -dynamiclib" + NXT_SHARED_LOCAL_LINK="\$(CC) -dynamiclib \ + -install_name @executable_path/libnxt.dylib" + + # Prior to MacOSX 10.5 (Leopard) only bundles could be unloaded. + NXT_MODULE_LINK="\$(CC) -bundle -undefined dynamic_lookup" + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.dylib" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.dylib" + + # MacOSX libm.dylib is a symlink to libSystem.dylib. + NXT_LIBM= + NXT_LIBS= + + ;; + + NetBSD) + nxt_have=NXT_NETBSD . auto/have + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared" + NXT_MODULE_LINK="\$(CC) -shared" + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_PTHREAD" + ;; + + OpenBSD) + nxt_have=NXT_OPENBSD . auto/have + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared" + NXT_MODULE_LINK="\$(CC) -shared" + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_PTHREAD" + ;; + + AIX) + nxt_have=NXT_AIX . auto/have + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -G" + NXT_SHARED_LOCAL_LINK="\$(CC) -G" + NXT_MODULE_LINK="\$(CC) -G" + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_PTHREAD" + ;; + + HP-UX) + nxt_have=NXT_HPUX . auto/have + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared" + NXT_MODULE_LINK="\$(CC) -shared" + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_PTHREAD $NXT_LIBHG" + ;; + + QNX) + nxt_have=NXT_QNX . auto/have + + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared" + NXT_MODULE_LINK="\$(CC) -shared" + + NXT_EXEC_LINK="\$(CC)" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_PTHREAD" + ;; + + *) + NXT_STATIC_LINK="ar -r -c" + NXT_SHARED_LINK="\$(CC) -shared" + NXT_SHARED_LOCAL_LINK="\$(CC) -shared" + NXT_MODULE_LINK="\$(CC) -shared" + + # "-Wl,-E" exports symbols of executable file. + NXT_EXEC_LINK="\$(CC) -Wl,-E" + NXT_SHARED_LOCAL_EXEC_LINK= + + NXT_LIB_STATIC="libnxt.a" + NXT_LIB_SHARED="libnxt.so" + NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so" + + NXT_LIBM="-lm" + NXT_LIBS="$NXT_LIBRT $NXT_LIBDL $NXT_PTHREAD" + ;; +esac diff --git a/auto/os/test b/auto/os/test new file mode 100644 index 00000000..36ce50ae --- /dev/null +++ b/auto/os/test @@ -0,0 +1,93 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +NXT_SYSTEM=`uname -s 2>/dev/null` + + +case "$NXT_SYSTEM" in + + Linux) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + # Linux uname -p can return "unknown". + NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null` + echo=echo + CC=${CC:-cc} + ;; + + FreeBSD | NetBSD | OpenBSD) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null` + echo=echo + CC=${CC:-cc} + ;; + + SunOS) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -p 2>/dev/null` + echo=echo + CC=${CC:-gcc} + + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -D_XOPEN_SOURCE" + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -D_XOPEN_SOURCE_EXTENDED=1" + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -D__EXTENSIONS__" + NXT_TEST_LIBS="-lsocket" + ;; + + Darwin) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null` + echo=echo + CC=${CC:-cc} + + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -mmacosx-version-min=10.4" + ;; + + AIX) + NXT_SYSTEM_VERSION="`uname -v 2>/dev/null`.`uname -r 2>/dev/null`" + NXT_SYSTEM_PLATFORM=`uname -p 2>/dev/null` + echo=echo + CC=${CC:-gcc} + ;; + + HP-UX) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null` + echo=echo + CC=${CC:-gcc} + + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -D_XOPEN_SOURCE" + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -D_XOPEN_SOURCE_EXTENDED" + NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -D_HPUX_ALT_XOPEN_SOCKET_API" + ;; + + QNX) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -p 2>/dev/null` + echo=echo + CC=${CC:-gcc} + ;; + + MINGW*) + # MinGW /bin/sh builtin "echo" omits newline under Wine + # for some reason, so use a portable echo.c program built + # using MinGW GCC with only msvcrt.dll dependence. + + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null` + echo=auto/echo/echo.exe + CC=${CC:-cl} + NXT_WINDOWS=YES + ;; + + *) + NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` + NXT_SYSTEM_PLATFORM=`uname -p 2>/dev/null` + echo=echo + CC=${CC:-gcc} + ;; + +esac + +$echo configuring for $NXT_SYSTEM $NXT_SYSTEM_VERSION $NXT_SYSTEM_PLATFORM diff --git a/auto/pcre b/auto/pcre new file mode 100644 index 00000000..e8765cef --- /dev/null +++ b/auto/pcre @@ -0,0 +1,49 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +NXT_REGEX=NO +NXT_PCRE_CFLAGS= +NXT_PCRE_LIB= + + +if [ $NXT_PCRE = YES ]; then + + nxt_found=no + + if /bin/sh -c "(pcre-config --version)" >> $NXT_AUTOCONF_ERR 2>&1; then + + NXT_PCRE_CFLAGS=`pcre-config --cflags` + NXT_PCRE_LIB=`pcre-config --libs` + + nxt_feature="PCRE library" + nxt_feature_name=NXT_HAVE_PCRE + nxt_feature_run=no + nxt_feature_incs=$NXT_PCRE_CFLAGS + nxt_feature_libs=$NXT_PCRE_LIB + nxt_feature_test="#include <pcre.h> + + int main() { + pcre *re; + + re = pcre_compile(NULL, 0, NULL, 0, NULL); + if (re == NULL) + return 1; + return 0; + }" + . auto/feature + fi + + if [ $nxt_found = no ]; then + $echo + $echo $0: error: no PCRE library found. + $echo + exit 1; + fi + + NXT_REGEX=YES + nxt_have=NXT_REGEX . auto/have + + $echo " + PCRE version: `pcre-config --version`" +fi diff --git a/auto/sendfile b/auto/sendfile new file mode 100644 index 00000000..e5bf3b79 --- /dev/null +++ b/auto/sendfile @@ -0,0 +1,158 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +NXT_HAVE_LINUX_SENDFILE=NO +NXT_HAVE_FREEBSD_SENDFILE=NO +NXT_HAVE_MACOSX_SENDFILE=NO +NXT_HAVE_SOLARIS_SENDFILEV=NO +NXT_HAVE_AIX_SEND_FILE=NO +NXT_HAVE_HPUX_SENDFILE=NO + + +# Linux sendfile(). + +nxt_feature="Linux sendfile()" +nxt_feature_name=NXT_HAVE_LINUX_SENDFILE +nxt_feature_test="#include <sys/sendfile.h> + + int main() { + off_t offset; + + sendfile(-1, -1, &offset, 0); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_HAVE_LINUX_SENDFILE=YES +fi + + +if [ $nxt_found = no ]; then + # FreeBSD sendfile(). + + nxt_feature="FreeBSD sendfile()" + nxt_feature_name=NXT_HAVE_FREEBSD_SENDFILE + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <sys/types.h> + #include <sys/socket.h> + #include <sys/uio.h> + #include <stdlib.h> + + int main() { + off_t sent; + + sendfile(-1, -1, 0, 0, NULL, &sent, SF_NODISKIO); + return 0; + }" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_HAVE_FREEBSD_SENDFILE=YES + fi +fi + + +NXT_LIBSENDFILE= + +if [ $nxt_found = no ]; then + + # Solaris 8 sendfilev(). + + nxt_feature="Solaris sendfilev()" + nxt_feature_name=NXT_HAVE_SOLARIS_SENDFILEV + nxt_feature_libs="-lsendfile" + nxt_feature_test="#include <sys/sendfile.h> + + int main() { + size_t sent; + struct sendfilevec vec; + + sendfilev(-1, &vec, 0, &sent); + return 0; + }" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_HAVE_SOLARIS_SENDFILEV=YES + NXT_LIBSENDFILE=$nxt_feature_libs + fi +fi + + +if [ $nxt_found = no ]; then + + # MacOSX sendfile(). + + nxt_feature="MacOSX sendfile()" + nxt_feature_name=NXT_HAVE_MACOSX_SENDFILE + nxt_feature_libs= + nxt_feature_test="#include <sys/types.h> + #include <sys/socket.h> + #include <sys/uio.h> + #include <stdlib.h> + + int main() { + off_t sent; + + sendfile(-1, -1, 0, &sent, NULL, 0); + return 0; + }" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_HAVE_MACOSX_SENDFILE=YES + fi +fi + + +if [ $nxt_found = no ]; then + + # AIX send_file(). + + nxt_feature="AIX send_file()" + nxt_feature_name=NXT_HAVE_AIX_SEND_FILE + nxt_feature_test="#include <sys/socket.h> + + int main() { + int s; + struct sf_parms sf_iobuf; + + send_file(&s, &sf_iobuf, 0); + return 0; + }" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_HAVE_AIX_SEND_FILE=YES + fi +fi + + +if [ $nxt_found = no ]; then + + # HP-UX sendfile(). + + nxt_feature="HP-UX sendfile()" + nxt_feature_name=NXT_HAVE_HPUX_SENDFILE + nxt_feature_libs= + nxt_feature_test="#include <sys/socket.h> + #include <stdlib.h> + + sbsize_t sendfile(int s, int fd, off_t offset, + bsize_t nbytes, const struct iovec *hdtrl, int flags); + + int main() { + sendfile(-1, -1, 0, 0, NULL, 0); + return 0; + }" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_HAVE_HPUX_SENDFILE=YES + fi +fi diff --git a/auto/sockets b/auto/sockets new file mode 100644 index 00000000..c8d1173e --- /dev/null +++ b/auto/sockets @@ -0,0 +1,233 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +if [ $NXT_INET6 = YES ]; then + + nxt_feature="AF_INET6" + nxt_feature_name=NXT_INET6 + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <stdio.h> + #include <sys/socket.h> + #include <sys/types.h> + #include <netinet/in.h> + + int main() { + struct sockaddr_in6 sin6; + + sin6.sin6_family = AF_INET6; + printf(\"%d\", sin6.sin6_family); + return 0; + }" + . auto/feature +fi + + +# FreeBSD, MacOSX, NetBSD, OpenBSD. + +nxt_feature="sockaddr.sa_len" +nxt_feature_name=NXT_SOCKADDR_SA_LEN +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/socket.h> + + int main() { + struct sockaddr sa; + + sa.sa_len = 0; + printf(\"%d\", sa.sa_len); + return 0; + }" +. auto/feature + + +nxt_feature="struct sockaddr size" +nxt_feature_name=NXT_HAVE_SOCKADDR +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/socket.h> + + int main() { + printf(\"%d\", (int) sizeof(struct sockaddr)); + return 0; + }" +. auto/feature + + +nxt_feature="struct sockaddr_in size" +nxt_feature_name=NXT_HAVE_SOCKADDR_IN +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/types.h> + #include <netinet/in.h> + + int main() { + printf(\"%d\", (int) sizeof(struct sockaddr_in)); + return 0; + }" +. auto/feature + + +nxt_feature="struct sockaddr_in6 size" +nxt_feature_name=NXT_HAVE_SOCKADDR_IN6 +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/types.h> + #include <netinet/in.h> + + int main() { + printf(\"%d\", (int) sizeof(struct sockaddr_in6)); + return 0; + }" +. auto/feature + + +nxt_feature="struct sockaddr_un size" +nxt_feature_name=NXT_HAVE_SOCKADDR_UN +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/types.h> + #include <sys/un.h> + + int main() { + printf(\"%d\", (int) sizeof(struct sockaddr_un)); + return 0; + }" +. auto/feature + + +nxt_feature="struct sockaddr_storage size" +nxt_feature_name=NXT_HAVE_SOCKADDR_STORAGE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/socket.h> + + int main() { + printf(\"%d\", (int) sizeof(struct sockaddr_storage)); + return 0; + }" +. auto/feature + + +nxt_feature="socketpair(AF_UNIX, SOCK_SEQPACKET)" +nxt_feature_name=NXT_HAVE_AF_UNIX_SOCK_SEQPACKET +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/socket.h> + + int main() { + int pair[2]; + + if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, pair) != 0) + return 1; + return 0; + }" +. auto/feature + + +nxt_feature="struct msghdr.msg_control" +nxt_feature_name=NXT_HAVE_MSGHDR_MSG_CONTROL +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + #include <sys/socket.h> + + int main() { + struct msghdr msg; + + printf(\"%d\", (int) sizeof(msg.msg_control)); + return 0; + }" +. auto/feature + + +nxt_feature="sys/filio.h" +nxt_feature_name=NXT_HAVE_SYS_FILIO_H +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <sys/filio.h> + + int main() { + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_SYS_FILIO_H="#include <sys/filio.h>" +else + NXT_SYS_FILIO_H= +fi + + +nxt_feature="ioctl(FIONBIO)" +nxt_feature_name=NXT_HAVE_FIONBIO +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <unistd.h> + #include <sys/socket.h> + $NXT_SYS_FILIO_H + #include <sys/ioctl.h> + + int main() { + int nb; + + nb = 0; + ioctl(-1, FIONBIO, &nb); + return 0; + }" +. auto/feature + + +# socket(SOCK_NONBLOCK), Linux 2.6.27/glibc 2.10, NetBSD 6.0, FreeBSD 9.2. + +nxt_feature="socket(SOCK_NONBLOCK)" +nxt_feature_name=NXT_HAVE_SOCK_NONBLOCK +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#define _GNU_SOURCE + #include <sys/socket.h> + + int main() { + socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); + return 0; + }" +. auto/feature + + +# accept4(), Linux 2.6.28/glibc 2.10, NetBSD 6.0, FreeBSD 9.2. + +nxt_feature="accept4()" +nxt_feature_name=NXT_HAVE_ACCEPT4 +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#define _GNU_SOURCE + #include <stdlib.h> + #include <sys/socket.h> + + int main() { + accept4(0, NULL, NULL, SOCK_NONBLOCK); + return 0; + }" +. auto/feature diff --git a/auto/sources b/auto/sources new file mode 100644 index 00000000..3e189197 --- /dev/null +++ b/auto/sources @@ -0,0 +1,326 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +NXT_LIB_DEPS=" \ + src/nxt_main.h \ + src/nxt_clang.h \ + src/nxt_types.h \ + src/nxt_atomic.h \ + src/nxt_errno.h \ + src/nxt_time.h \ + src/nxt_unix.h \ + src/nxt_malloc.h \ + src/nxt_file.h \ + src/nxt_mem_map.h \ + src/nxt_socket.h \ + src/nxt_process.h \ + src/nxt_signal.h \ + src/nxt_chan.h \ + src/nxt_dyld.h \ + src/nxt_thread.h \ + src/nxt_thread_id.h \ + src/nxt_spinlock.h \ + src/nxt_random.h \ + src/nxt_queue.h \ + src/nxt_rbtree.h \ + src/nxt_string.h \ + src/nxt_utf8.h \ + src/nxt_unicode_lowcase.h \ + src/nxt_parse.h \ + src/nxt_mem_pool.h \ + src/nxt_mem_pool_cleanup.h \ + src/nxt_mem_cache_pool.h \ + src/nxt_mem_zone.h \ + src/nxt_sprintf.h \ + src/nxt_file_name.h \ + src/nxt_log.h \ + src/nxt_djb_hash.h \ + src/nxt_murmur_hash.h \ + src/nxt_lvlhsh.h \ + src/nxt_hash.h \ + src/nxt_sort.h \ + src/nxt_array.h \ + src/nxt_vector.h \ + src/nxt_list.h \ + src/nxt_buf.h \ + src/nxt_buf_pool.h \ + src/nxt_buf_filter.h \ + src/nxt_recvbuf.h \ + src/nxt_sendbuf.h \ + src/nxt_thread_log.h \ + src/nxt_thread_time.h \ + src/nxt_work_queue.h \ + src/nxt_service.h \ + src/nxt_fiber.h \ + src/nxt_log_moderation.h \ + src/nxt_event_set.h \ + src/nxt_event_engine.h \ + src/nxt_event_timer.h \ + src/nxt_event_fd.h \ + src/nxt_event_conn.h \ + src/nxt_event_file.h \ + src/nxt_job.h \ + src/nxt_job_file.h \ + src/nxt_sockaddr.h \ + src/nxt_job_resolve.h \ + src/nxt_listen_socket.h \ +" + +NXT_LIB_SRCS=" \ + src/nxt_lib.c \ + src/nxt_gmtime.c \ + src/nxt_errno.c \ + src/nxt_time.c \ + src/nxt_malloc.c \ + src/nxt_file.c \ + src/nxt_mem_map.c \ + src/nxt_socket.c \ + src/nxt_socketpair.c \ + src/nxt_process.c \ + src/nxt_process_title.c \ + src/nxt_signal.c \ + src/nxt_chan.c \ + src/nxt_dyld.c \ + src/nxt_random.c \ + src/nxt_queue.c \ + src/nxt_rbtree.c \ + src/nxt_mem_pool.c \ + src/nxt_mem_pool_cleanup.c \ + src/nxt_mem_cache_pool.c \ + src/nxt_mem_zone.c \ + src/nxt_string.c \ + src/nxt_utf8.c \ + src/nxt_parse.c \ + src/nxt_sprintf.c \ + src/nxt_file_name.c \ + src/nxt_log.c \ + src/nxt_djb_hash.c \ + src/nxt_murmur_hash.c \ + src/nxt_lvlhsh.c \ + src/nxt_lvlhsh_pool.c \ + src/nxt_array.c \ + src/nxt_vector.c \ + src/nxt_list.c \ + src/nxt_buf.c \ + src/nxt_buf_pool.c \ + src/nxt_buf_filter.c \ + src/nxt_recvbuf.c \ + src/nxt_sendbuf.c \ + src/nxt_thread_time.c \ + src/nxt_time_parse.c \ + src/nxt_work_queue.c \ + src/nxt_service.c \ + src/nxt_fiber.c \ + src/nxt_log_moderation.c \ + src/nxt_event_set.c \ + src/nxt_event_engine.c \ + src/nxt_event_timer.c \ + src/nxt_event_conn.c \ + src/nxt_event_conn_connect.c \ + src/nxt_event_conn_accept.c \ + src/nxt_event_conn_read.c \ + src/nxt_event_conn_write.c \ + src/nxt_event_conn_job_sendfile.c \ + src/nxt_event_conn_proxy.c \ + src/nxt_job.c \ + src/nxt_job_file.c \ + src/nxt_sockaddr.c \ + src/nxt_job_resolve.c \ + src/nxt_listen_socket.c \ +" + +NXT_LIB_THREAD_DEPS=" \ + src/nxt_semaphore.h \ + src/nxt_thread_pool.h \ +" + +NXT_LIB_THREAD_SRCS=" \ + src/nxt_thread.c \ + src/nxt_thread_id.c \ + src/nxt_thread_mutex.c \ + src/nxt_thread_cond.c \ + src/nxt_spinlock.c \ + src/nxt_semaphore.c \ + src/nxt_thread_pool.c \ +" + +NXT_LIB_SSLTLS_DEPS="src/nxt_ssltls.h" +NXT_LIB_SSLTLS_SRCS="src/nxt_ssltls.c" +NXT_LIB_OPENSSL_SRCS="src/nxt_openssl.c" +NXT_LIB_GNUTLS_SRCS="src/nxt_gnutls.c" +NXT_LIB_CYASSL_SRCS="src/nxt_cyassl.c" +NXT_LIB_POLARSSL_SRCS="src/nxt_polarssl.c" + +NXT_LIB_EPOLL_SRCS="src/nxt_epoll.c" +NXT_LIB_KQUEUE_SRCS="src/nxt_kqueue.c" +NXT_LIB_EVENTPORT_SRCS="src/nxt_eventport.c" +NXT_LIB_DEVPOLL_SRCS="src/nxt_devpoll.c" +NXT_LIB_POLLSET_SRCS="src/nxt_pollset.c" +NXT_LIB_POLL_SRCS="src/nxt_poll.c" +NXT_LIB_SELECT_SRCS="src/nxt_select.c" + +NXT_LIB_LINUX_SENDFILE_SRCS="src/nxt_linux_sendfile.c" +NXT_LIB_FREEBSD_SENDFILE_SRCS="src/nxt_freebsd_sendfile.c" +NXT_LIB_SOLARIS_SENDFILEV_SRCS="src/nxt_solaris_sendfilev.c" +NXT_LIB_MACOSX_SENDFILE_SRCS="src/nxt_macosx_sendfile.c" +NXT_LIB_AIX_SEND_FILE_SRCS="src/nxt_aix_send_file.c" +NXT_LIB_HPUX_SENDFILE_SRCS="src/nxt_hpux_sendfile.c" + +NXT_LIB_TEST_BUILD_DEPS="src/nxt_test_build.h" +NXT_LIB_TEST_BUILD_SRCS="src/nxt_test_build.c" + +NXT_LIB_UNIT_TEST_DEPS="test/nxt_lib_unit_test.h \ + test/nxt_rbtree1.h \ +" + +NXT_LIB_UNIT_TEST_SRCS=" \ + test/nxt_lib_unit_test.c \ + test/nxt_rbtree1.c \ + test/nxt_rbtree_unit_test.c \ + test/nxt_term_parse_unit_test.c \ + test/nxt_msec_diff_unit_test.c \ + test/nxt_exp_approximation.c \ + test/nxt_mem_cache_pool_unit_test.c \ + test/nxt_mem_zone_unit_test.c \ + test/nxt_lvlhsh_unit_test.c \ + test/nxt_gmtime_unit_test.c \ + test/nxt_sprintf_unit_test.c \ + test/nxt_malloc_unit_test.c \ + test/nxt_utf8_unit_test.c \ + test/nxt_rbtree1_unit_test.c \ +" + +NXT_LIB_UTF8_FILE_NAME_TEST_SRCS=" \ + test/nxt_utf8_file_name_test.c \ +" + + +if [ $NXT_THREADS = YES ]; then + NXT_LIB_DEPS="$NXT_LIB_DEPS $NXT_LIB_THREAD_DEPS" + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_THREAD_SRCS" +fi + + +if [ $NXT_SSLTLS = YES ]; then + nxt_have=NXT_SSLTLS . auto/have + NXT_LIB_DEPS="$NXT_LIB_DEPS $NXT_LIB_SSLTLS_DEPS" + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_SSLTLS_SRCS" +fi + + +if [ $NXT_OPENSSL = YES ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_OPENSSL_SRCS" +fi + + +if [ $NXT_GNUTLS = YES ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_GNUTLS_SRCS" +fi + + +if [ $NXT_CYASSL = YES ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_CYASSL_SRCS" +fi + + +if [ $NXT_POLARSSL = YES ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_POLARSSL_SRCS" +fi + + +if [ "$NXT_HAVE_EPOLL" = "YES" -o "$NXT_TEST_BUILD_EPOLL" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_EPOLL_SRCS" +fi + + +if [ "$NXT_HAVE_KQUEUE" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_KQUEUE_SRCS" +fi + + +if [ "$NXT_HAVE_EVENTPORT" = "YES" -o "$NXT_TEST_BUILD_EVENTPORT" = "YES" ]; +then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_EVENTPORT_SRCS" +fi + + +if [ "$NXT_HAVE_DEVPOLL" = "YES" -o "$NXT_TEST_BUILD_DEVPOLL" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_DEVPOLL_SRCS" +fi + + +if [ "$NXT_HAVE_POLLSET" = "YES" -o "$NXT_TEST_BUILD_POLLSET" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_POLLSET_SRCS" +fi + + +NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_POLL_SRCS" +NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_SELECT_SRCS" + + +if [ "$NXT_HAVE_LINUX_SENDFILE" = "YES" \ + -o "$NXT_TEST_BUILD_LINUX_SENDFILE" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_LINUX_SENDFILE_SRCS" +fi + + +if [ "$NXT_HAVE_FREEBSD_SENDFILE" = "YES" \ + -o "$NXT_TEST_BUILD_FREEBSD_SENDFILE" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_FREEBSD_SENDFILE_SRCS" +fi + + +if [ "$NXT_HAVE_SOLARIS_SENDFILEV" = "YES" \ + -o "$NXT_TEST_BUILD_SOLARIS_SENDFILEV" = "YES" ]; +then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_SOLARIS_SENDFILEV_SRCS" +fi + + +if [ "$NXT_HAVE_MACOSX_SENDFILE" = "YES" \ + -o "$NXT_TEST_BUILD_MACOSX_SENDFILE" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_MACOSX_SENDFILE_SRCS" +fi + + +if [ "$NXT_HAVE_AIX_SEND_FILE" = "YES" \ + -o "$NXT_TEST_BUILD_AIX_SEND_FILE" = "YES" ]; +then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_AIX_SEND_FILE_SRCS" +fi + + +if [ "$NXT_HAVE_HPUX_SENDFILE" = "YES" \ + -o "$NXT_TEST_BUILD_HPUX_SENDFILE" = "YES" ]; then + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_HPUX_SENDFILE_SRCS" +fi + + +if [ "$NXT_TEST_BUILD" = "YES" ]; then + NXT_LIB_DEPS="$NXT_LIB_DEPS $NXT_LIB_TEST_BUILD_DEPS" + NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_TEST_BUILD_SRCS" +fi + + +if [ $NXT_LIB_UNIT_TEST = YES ]; then + nxt_have=NXT_LIB_UNIT_TEST . auto/have +fi + +NXT_DEPS=" \ + src/nxt_cycle.h \ + src/nxt_process_chan.h \ + src/nxt_application.h \ + src/nxt_master_process.h \ +" + +NXT_SRCS=" \ + src/nxt_main.c \ + src/nxt_app_log.c \ + src/nxt_cycle.c \ + src/nxt_process_chan.c \ + src/nxt_application.c \ + src/nxt_master_process.c \ + src/nxt_worker_process.c \ +" diff --git a/auto/ssltls b/auto/ssltls new file mode 100644 index 00000000..63b67fdb --- /dev/null +++ b/auto/ssltls @@ -0,0 +1,184 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +NXT_OPENSSL_CFLAGS= +NXT_OPENSSL_LIBS= +NXT_GNUTLS_CFLAGS= +NXT_GNUTLS_LIBS= +NXT_OPENSSL_LIBS= +NXT_CYASSL_CFLAGS= +NXT_CYASSL_LIBS= +NXT_POLARSSL_CFLAGS= +NXT_POLARSSL_LIBS= + + +if [ $NXT_OPENSSL = YES ]; then + + nxt_feature="OpenSSL library" + nxt_feature_name=NXT_HAVE_OPENSSL + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs="-lssl -lcrypto" + nxt_feature_test="#include <openssl/ssl.h> + + int main() { + SSL_library_init(); + return 0; + }" + . auto/feature + + + if [ $nxt_found = yes ]; then + NXT_SSLTLS=YES + NXT_OPENSSL_LIBS="$nxt_feature_libs" + + nxt_feature="OpenSSL version" + nxt_feature_name=NXT_HAVE_OPENSSL_VERSION + nxt_feature_run=value + nxt_feature_test="#include <openssl/ssl.h> + + int main() { + printf(\"\\\"%s\\\"\", + SSLeay_version(SSLEAY_VERSION)); + return 0; + }" + . auto/feature + + else + $echo + $echo $0: error: no OpenSSL library found. + $echo + exit 1; + fi +fi + + +if [ $NXT_GNUTLS = YES ]; then + + if /bin/sh -c "(pkg-config gnutls --exists)" >> $NXT_AUTOCONF_ERR 2>&1; + then + NXT_GNUTLS_CFLAGS=`pkg-config gnutls --cflags` + NXT_GNUTLS_LIBS=`pkg-config gnutls --libs` + + nxt_feature="GnuTLS library" + nxt_feature_name=NXT_HAVE_GNUTLS + nxt_feature_run=yes + nxt_feature_incs=$NXT_GNUTLS_CFLAGS + nxt_feature_libs=$NXT_GNUTLS_LIBS + nxt_feature_test="#include <gnutls/gnutls.h> + + int main() { + gnutls_global_init(); + gnutls_global_deinit(); + return 0; + }" + . auto/feature + + + if [ $nxt_found = yes ]; then + NXT_SSLTLS=YES + + $echo " + GnuTLS version: `pkg-config gnutls --modversion`" + + + nxt_feature="gnutls_transport_set_vec_push_function" + nxt_feature_name=NXT_HAVE_GNUTLS_VEC_PUSH + nxt_feature_run=no + nxt_feature_incs=$NXT_GNUTLS_CFLAGS + nxt_feature_libs=$NXT_GNUTLS_LIBS + nxt_feature_test="#include <gnutls/gnutls.h> + + int main() { + gnutls_transport_set_vec_push_function(NULL, NULL); + return 0; + }" + . auto/feature + + + nxt_feature="gnutls_global_set_time_function" + nxt_feature_name=NXT_HAVE_GNUTLS_SET_TIME + nxt_feature_run=no + nxt_feature_incs=$NXT_GNUTLS_CFLAGS + nxt_feature_libs=$NXT_GNUTLS_LIBS + nxt_feature_test="#include <gnutls/gnutls.h> + + int main() { + gnutls_global_set_time_function(NULL); + return 0; + }" + . auto/feature + + else + $echo + $echo $0: error: no GnuTLS library found. + $echo + exit 1; + fi + fi +fi + + +if [ $NXT_CYASSL = YES ]; then + + nxt_feature="CyaSSL library" + nxt_feature_name=NXT_HAVE_CYASSL + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs="-lcyassl" + nxt_feature_test="#include <cyassl/ssl.h> + + int main() { + CyaSSL_Init(); + CyaSSL_Cleanup(); + return 0; + }" + . auto/feature + + + if [ $nxt_found = yes ]; then + NXT_SSLTLS=YES + NXT_CYASSL_CFLAGS="$nxt_feature_incs" + NXT_CYASSL_LIBS="$nxt_feature_libs" + + else + $echo + $echo $0: error: no CyaSSL library found. + $echo + exit 1; + fi +fi + + +if [ $NXT_POLARSSL = YES ]; then + + nxt_feature="PolarSSL library" + nxt_feature_name=NXT_HAVE_POLARSSL + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs="-lpolarssl" + nxt_feature_test="#include <polarssl/ssl.h> + + int main() { + ssl_context ssl; + memset(&ssl, '\0', sizeof(ssl)); + ssl_init(&ssl); + ssl_free(&ssl); + return 0; + }" + . auto/feature + + + if [ $nxt_found = yes ]; then + NXT_SSLTLS=YES + NXT_POLARSSL_CFLAGS="$nxt_feature_incs" + NXT_POLARSSL_LIBS="$nxt_feature_libs" + + else + $echo + $echo $0: error: no PolarSSL library found. + $echo + exit 1; + fi +fi diff --git a/auto/test_build b/auto/test_build new file mode 100644 index 00000000..6889048e --- /dev/null +++ b/auto/test_build @@ -0,0 +1,76 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +NXT_TEST_BUILD=NO + + +if [ $NXT_TEST_BUILD_EPOLL = YES ]; then + nxt_have=NXT_TEST_BUILD_EPOLL . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_EVENTPORT = YES ]; then + nxt_have=NXT_TEST_BUILD_EVENTPORT . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_DEVPOLL = YES ]; then + nxt_have=NXT_TEST_BUILD_DEVPOLL . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_POLLSET = YES ]; then + nxt_have=NXT_TEST_BUILD_POLLSET . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_LINUX_SENDFILE = YES ]; then + nxt_have=NXT_TEST_BUILD_LINUX_SENDFILE . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_FREEBSD_SENDFILE = YES ]; then + nxt_have=NXT_TEST_BUILD_FREEBSD_SENDFILE . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_SOLARIS_SENDFILEV = YES ]; then + nxt_have=NXT_TEST_BUILD_SOLARIS_SENDFILEV . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_MACOSX_SENDFILE = YES ]; then + nxt_have=NXT_TEST_BUILD_MACOSX_SENDFILE . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_AIX_SEND_FILE = YES ]; then + nxt_have=NXT_TEST_BUILD_AIX_SEND_FILE . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi + + +if [ $NXT_TEST_BUILD_HPUX_SENDFILE = YES ]; then + nxt_have=NXT_TEST_BUILD_HPUX_SENDFILE . auto/have + nxt_have=NXT_TEST_BUILD . auto/have + NXT_TEST_BUILD=YES +fi diff --git a/auto/threads b/auto/threads new file mode 100644 index 00000000..9187caab --- /dev/null +++ b/auto/threads @@ -0,0 +1,282 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +case "$NXT_SYSTEM" in + + Linux) + NXT_PTHREAD="-lpthread" + ;; + + FreeBSD) + # FreeBSD libc supports only pthread stubs. + NXT_PTHREAD="-lpthread" + ;; + + SunOS) + case "$NXT_SYSTEM_VERSION" in + 5.8 | 5.9) + NXT_PTHREAD="-lpthread" + ;; + *) + # Solaris 10 libpthread.so.1 is a filter to libc.so.1. + NXT_PTHREAD= + ;; + esac + ;; + + Darwin) + # MacOSX libpthread.dylib is a symlink to libSystem.dylib. + NXT_PTHREAD= + ;; + + *) + NXT_PTHREAD="-lpthread" + ;; +esac + + +# Linux, FreeBSD. + +nxt_feature="pthread_yield()" +nxt_feature_name=NXT_HAVE_PTHREAD_YIELD +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs=$NXT_PTHREAD +nxt_feature_test="#define _GNU_SOURCE + #include <pthread.h> + + int main() { + pthread_yield(); + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # MacOSX. + + nxt_feature="pthread_yield_np()" + nxt_feature_name=NXT_HAVE_PTHREAD_YIELD_NP + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs=$NXT_PTHREAD + nxt_feature_test="#include <pthread.h> + + int main() { + pthread_yield_np(); + return 0; + }" + . auto/feature +fi + + +# FreeBSD, Solaris, AIX. + +nxt_feature="pthread spinlock" +nxt_feature_name=NXT_HAVE_PTHREAD_SPINLOCK +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs=$NXT_PTHREAD +nxt_feature_test="#include <pthread.h> + + int main() { + pthread_spinlock_t lock; + + if (pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) != 0) + return 1; + if (pthread_spin_lock(&lock) != 0) + return 1; + if (pthread_spin_unlock(&lock) != 0) + return 1; + if (pthread_spin_destroy(&lock) != 0) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = yes ]; then + + # Linux glibc uses 0 as pthread_spinlock_t initial value on the most + # platforms. However, on i386 and x86_64 the initial value is 1. + + nxt_feature="pthread spinlock zero initial value" + nxt_feature_name=NXT_HAVE_PTHREAD_SPINLOCK_ZERO + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs=$NXT_PTHREAD + nxt_feature_test="#include <pthread.h> + + pthread_spinlock_t lock = 0; + + int main() { + if (pthread_spin_trylock(&lock) != 0) + return 1; + if (pthread_spin_unlock(&lock) != 0) + return 1; + return 0; + }" + . auto/feature +fi + + +if [ $nxt_found = no ]; then + + # MacOSX spinlock(3). + + nxt_feature="MacOSX spinlock" + nxt_feature_name=NXT_HAVE_MACOSX_SPINLOCK + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs=$NXT_PTHREAD + nxt_feature_test="#include <libkern/OSAtomic.h> + + int main() { + OSSpinLock lock = 0; + + if (OSSpinLockTry(&lock) == 0) + return 1; + OSSpinLockUnlock(&lock); + return 0; + }" + . auto/feature +fi + + +nxt_feature="sem_timedwait()" +nxt_feature_name=NXT_HAVE_SEM_TIMEDWAIT +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <semaphore.h> + + int main() { + sem_t sem; + struct timespec ts; + + if (sem_init(&sem, 0, 0) != 0) + return 1; + if (sem_post(&sem) != 0) + return 1; + + ts.tv_sec = 0; + ts.tv_nsec = 0; + if (sem_timedwait(&sem, &ts) != 0) + return 1; + + if (sem_destroy(&sem) != 0) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + if [ -n "$NXT_PTHREAD" ]; then + + # Linux requires libpthread. + + nxt_feature="sem_timedwait() in libpthread" + nxt_feature_libs=$NXT_PTHREAD + . auto/feature + fi + + if [ $nxt_found = no ]; then + + # Solaris 10 requires librt. + + nxt_feature="sem_timedwait() in librt" + nxt_feature_libs="-lrt" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_LIBRT="-lrt" + fi + fi +fi + + +# Thread Local Storage / Thread Specific Data. +# +# Linux, FreeBSD 5.3, Solaris. +# MacOSX 10.7 (Lion) Clang. However, if the -mmacosx-version-min +# option is specified it must be at least 10.7. + +nxt_feature="__thread" +nxt_feature_name=NXT_HAVE_THREAD_STORAGE_CLASS +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs=$NXT_PTHREAD +nxt_feature_test="#include <pthread.h> + #include <stdlib.h> + + __thread int key; + + void *func(void *p); + + void *func(void *p) { + key = 0x9abcdef0; + return NULL; + } + + int main() { + void *n; + pthread_t pt; + + key = 0x12345678; + if (pthread_create(&pt, NULL, func, NULL)) + return 1; + if (pthread_join(pt, &n)) + return 1; + if (key != 0x12345678) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # MacOSX GCC lacks __thread support. + # On NetBSD __thread causes segmentation fault. + + nxt_feature="phtread_key_t" + nxt_feature_name=NXT_HAVE_PTHREAD_SPECIFIC_DATA + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs=$NXT_PTHREAD + nxt_feature_test="#include <pthread.h> + + int main() { + pthread_key_t key = -1; + + if (pthread_key_create(&key, NULL)) + return 1; + if (pthread_setspecific(key, (void *) 0x12345678)) + return 1; + if (pthread_getspecific(key) != (void *) 0x12345678) + return 1; + return 0; + }" + . auto/feature + + + nxt_feature="PTHREAD_KEYS_MAX" + nxt_feature_name= + nxt_feature_run=value + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <limits.h> + #include <pthread.h> + #include <stdio.h> + + int main() { + printf(\"%d\", PTHREAD_KEYS_MAX); + return 0; + }" + . auto/feature +fi diff --git a/auto/time b/auto/time new file mode 100644 index 00000000..712a4297 --- /dev/null +++ b/auto/time @@ -0,0 +1,226 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Linux 2.6.32 CLOCK_REALTIME_COARSE. +# Linux clock_gettime() is in librt. + +NXT_LIBRT= + +nxt_feature="Linux clock_gettime(CLOCK_REALTIME_COARSE)" +nxt_feature_name=NXT_HAVE_CLOCK_REALTIME_COARSE +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs="-lrt" +nxt_feature_test="#include <time.h> + + int main() { + struct timespec ts; + + if (clock_gettime(CLOCK_REALTIME_COARSE, &ts) == -1) + return 1; + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_LIBRT=$nxt_feature_libs +fi + + +# FreeBSD 7.0 CLOCK_REALTIME_FAST + +nxt_feature="FreeBSD clock_gettime(CLOCK_REALTIME_FAST)" +nxt_feature_name=NXT_HAVE_CLOCK_REALTIME_FAST +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + struct timespec ts; + + if (clock_gettime(CLOCK_REALTIME_FAST, &ts) == -1) + return 1; + return 0; + }" +. auto/feature + + +nxt_feature="clock_gettime(CLOCK_REALTIME)" +nxt_feature_name=NXT_HAVE_CLOCK_REALTIME +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + struct timespec ts; + + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # Linux and Solaris 10 clock_gettime() are in librt. + + nxt_feature="clock_gettime(CLOCK_REALTIME) in librt" + nxt_feature_libs="-lrt" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_LIBRT=$nxt_feature_libs + fi +fi + + +# Linux 2.6.32 CLOCK_MONOTONIC_COARSE. +# Linux clock_gettime() is in librt. + +nxt_feature="Linux clock_gettime(CLOCK_MONOTONIC_COARSE)" +nxt_feature_name=NXT_HAVE_CLOCK_MONOTONIC_COARSE +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs="-lrt" +nxt_feature_test="#include <time.h> + + int main() { + struct timespec ts; + + if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ts) == -1) + return 1; + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_LIBRT=$nxt_feature_libs +fi + + +# FreeBSD 7.0 CLOCK_MONOTONIC_FAST + +nxt_feature="FreeBSD clock_gettime(CLOCK_MONOTONIC_FAST)" +nxt_feature_name=NXT_HAVE_CLOCK_MONOTONIC_FAST +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + struct timespec ts; + + if (clock_gettime(CLOCK_MONOTONIC_FAST, &ts) == -1) + return 1; + return 0; + }" +. auto/feature + + +nxt_feature="clock_gettime(CLOCK_MONOTONIC)" +nxt_feature_name=NXT_HAVE_CLOCK_MONOTONIC +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + struct timespec ts; + + if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) + return 1; + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # Linux and Solaris 10 clock_gettime() are in librt. + + nxt_feature="clock_gettime(CLOCK_MONOTONIC) in librt" + nxt_feature_libs="-lrt" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_LIBRT=$nxt_feature_libs + fi +fi + + +# HP-UX Mercury Library hg_gethrtime(). + +NXT_LIBHG= + +nxt_feature="HP-UX hg_gethrtime()" +nxt_feature_name=NXT_HAVE_HG_GETHRTIME +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs="-lhg" +nxt_feature_test="#include <stdlib.h> + #include <sys/mercury.h> + + int main() { + hg_gethrtime(); + return 0; + }" +. auto/feature + +if [ $nxt_found = yes ]; then + NXT_LIBHG=$nxt_feature_libs +fi + + +nxt_feature="struct tm.tm_gmtoff" +nxt_feature_name=NXT_HAVE_TM_GMTOFF +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + time_t t; + struct tm tm; + + t = 0; + localtime_r(&t, &tm); + return tm.tm_gmtoff; + }" +. auto/feature + + +nxt_feature="altzone" +nxt_feature_name=NXT_HAVE_ALTZONE +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + altzone = 0; + return 0; + }" +. auto/feature + + +nxt_feature="localtime_r()" +nxt_feature_name=NXT_HAVE_LOCALTIME_R +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + + int main() { + time_t t; + struct tm tm; + + t = 0; + localtime_r(&t, &tm); + return 0; + }" +. auto/feature diff --git a/auto/types b/auto/types new file mode 100644 index 00000000..91d53b6f --- /dev/null +++ b/auto/types @@ -0,0 +1,118 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# Sizes of C types. + +# "-Wall -Werror" or similar constraints in default CFLAGS may require +# to use "%zu" format to printf() result of sizeof(). But "%zu" may +# be unavailable, so the "(int)" cast is a simple and portable solution: +# printf("%d", (int) sizeof(TYPE)); + + +nxt_feature="int size" +nxt_feature_name=NXT_INT_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(int)); + return 0; + }" +. auto/feature + + +nxt_feature="long size" +nxt_feature_name=NXT_LONG_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(long)); + return 0; + }" +. auto/feature + + +nxt_feature="long long size" +nxt_feature_name=NXT_LONG_LONG_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(long long)); + return 0; + }" +. auto/feature + + +nxt_feature="void * size" +nxt_feature_name=NXT_PTR_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(void *)); + return 0; + }" +. auto/feature + + +case "$nxt_feature_value" in + 8) NXT_64BIT=1 ;; + *) NXT_64BIT=0 ;; +esac + + +nxt_feature="size_t size" +nxt_feature_name=NXT_SIZE_T_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(size_t)); + return 0; + }" +. auto/feature + + +nxt_feature="off_t size" +nxt_feature_name=NXT_OFF_T_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#define _FILE_OFFSET_BITS 64 + #include <unistd.h> + #include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(off_t)); + return 0; + }" +. auto/feature + + +nxt_feature="time_t size" +nxt_feature_name=NXT_TIME_T_SIZE +nxt_feature_run=value +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <time.h> + #include <stdio.h> + + int main() { + printf(\"%d\", (int) sizeof(time_t)); + return 0; + }" +. auto/feature diff --git a/auto/unix b/auto/unix new file mode 100644 index 00000000..18256007 --- /dev/null +++ b/auto/unix @@ -0,0 +1,153 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +nxt_feature="arc4random()" +nxt_feature_name=NXT_HAVE_ARC4RANDOM +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + + int main() { + + (void) arc4random(); + + return 0; + }" +. auto/feature + + +# Linux 3.17 getrandom(). + +nxt_feature="getrandom()" +nxt_feature_name=NXT_HAVE_GETRANDOM +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <linux/random.h> + + int main() { + char buf[4]; + + (void) getrandom(buf, 4, 0); + + return 0; + }" +. auto/feature + + +nxt_feature="ucontext" +nxt_feature_name=NXT_HAVE_UCONTEXT +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + #include <ucontext.h> + + int main() { + ucontext_t uc; + + if (getcontext(&uc) == 0) { + makecontext(&uc, NULL, 0); + setcontext(&uc); + } + + return 0; + }" +. auto/feature + + +if [ $nxt_found = no ]; then + + # MacOSX 10.6 (Snow Leopard) has deprecated ucontext + # and requires _XOPEN_SOURCE to be defined. + + nxt_feature="_XOPEN_SOURCE ucontext" + nxt_feature_name=NXT_HAVE_UCONTEXT + nxt_feature_run= + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#define _XOPEN_SOURCE + #include <stdlib.h> + #include <ucontext.h> + + int main() { + ucontext_t uc; + + if (getcontext(&uc) == 0) { + makecontext(&uc, NULL, 0); + setcontext(&uc); + } + + return 0; + }" + . auto/feature +fi + + +# FreeBSD dlopen() is in libc. +# MacOSX libdl.dylib is a symlink to libSystem.dylib. + +NXT_LIBDL= + +nxt_feature="dlopen()" +nxt_feature_name=NXT_HAVE_DLOPEN +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + #include <dlfcn.h> + + int main() { + dlopen(NULL, 0); + return 0; + }" +. auto/feature + +if [ $nxt_found = no ]; then + + # Linux and Solaris prior to 10 require libdl. + # Solaris 10 libdl.so.1 is a filter to /usr/lib/ld.so.1. + + nxt_feature="dlopen() in libdl" + nxt_feature_libs="-ldl" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_LIBDL="-ldl" + fi +fi + + +nxt_feature="posix_spawn()" +nxt_feature_name=NXT_HAVE_POSIX_SPAWN +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <spawn.h> + #include <unistd.h> + + int main() { + (void) posix_spawn(NULL, NULL, NULL, NULL, NULL, NULL); + return 0; + }" +. auto/feature + + +# NetBSD 1.0, OpenBSD 1.0, FreeBSD 2.2 setproctitle(). + +nxt_feature="setproctitle()" +nxt_feature_name=NXT_HAVE_SETPROCTITLE +nxt_feature_run= +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="#include <stdlib.h> + #include <unistd.h> + + int main() { + setproctitle(\"%s\", \"title\"); + return 0; + }" +. auto/feature |