export LUAJIT_LIB=$PREFIX/lib
export LUAJIT_INC=$PREFIX/include

RESTY_CONFIG_OPTIONS=""

if [ `uname` == 'Linux' ]; then
    RESTY_CONFIG_OPTIONS="--with-file-aio"
fi

./configure --prefix="${PREFIX}" \
            --with-http_addition_module \
            --with-http_auth_request_module \
            --with-http_gunzip_module \
            --with-http_gzip_static_module \
            --with-http_random_index_module \
            --with-http_realip_module \
            --with-http_secure_link_module \
            --with-http_slice_module \
            --with-http_ssl_module \
            --with-http_stub_status_module \
            --with-http_sub_module \
            --with-http_v2_module \
            --with-mail \
            --with-mail_ssl_module \
            --with-pcre-jit \
            --with-stream \
            --with-stream_ssl_module \
            --with-threads \
            --with-luajit=$PREFIX \
            --with-cc=$CC \
            --with-cc-opt="$CFLAGS" \
            --with-ld-opt="$LDFLAGS" \
            ${RESTY_CONFIG_OPTIONS}

make -j${CPU_COUNT}
make -j${CPU_COUNT} install
