ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <libdrizzle/drizzle_client.h>"
ngx_feature_test="drizzle_version();"

if [ -n "$LIBDRIZZLE_INC" -o -n "$LIBDRIZZLE_LIB" ]; then
    # explicit set libdrizzle lib path
    ngx_feature="libdrizzle library in directories specified by LIBDRIZZLE_INC ($LIBDRIZZLE_INC) and LIBDRIZZLE_LIB ($LIBDRIZZLE_LIB)"
    ngx_feature_path="$LIBDRIZZLE_INC"
    if [ $NGX_RPATH = YES ]; then
        ngx_feature_libs="-R$LIBDRIZZLE_LIB -L$LIBDRIZZLE_LIB -ldrizzle"
    else
        ngx_feature_libs="-L$LIBDRIZZLE_LIB -ldrizzle"
    fi
    . auto/feature
else
    # auto-discovery
    ngx_feature="libdrizzle library"
    ngx_feature_path=
    ngx_feature_libs="-ldrizzle"
    . auto/feature

    if [ $ngx_found = no ]; then
        # Ubuntu 12.04
        ngx_feature="libdrizzle library in /usr/local/"
        ngx_feature_path="/usr/include/libdrizzle-1.0"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/usr/lib -L/usr/lib -ldrizzle"
        else
            ngx_feature_libs="-L/usr/lib -ldrizzle"
        fi
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # FreeBSD, OpenBSD
        ngx_feature="libdrizzle library in /usr/local/"
        ngx_feature_path="/usr/local/include/libdrizzle-1.0"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -ldrizzle"
        else
            ngx_feature_libs="-L/usr/local/lib -ldrizzle"
        fi
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # NetBSD
        ngx_feature="libdrizzle library in /usr/pkg/"
        ngx_feature_path="/usr/pkg/include/libdrizzle-1.0"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -ldrizzle"
        else
            ngx_feature_libs="-L/usr/pkg/lib -ldrizzle"
        fi
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # MacPorts
        ngx_feature="libdrizzle library in /opt/local/"
        ngx_feature_path="/opt/local/include/libdrizzle-1.0"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -ldrizzle"
        else
            ngx_feature_libs="-L/opt/local/lib -ldrizzle"
        fi
        . auto/feature
    fi
fi

if [ $ngx_found = yes ]; then
    CORE_INCS="$CORE_INCS $ngx_feature_path"
    CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
else
 cat << END
 $0: error: the ngx_drizzle addon requires the libdrizzle library.
END
 exit 1
fi

ngx_addon_name=ngx_http_drizzle_module
HTTP_MODULES="$HTTP_MODULES ngx_http_drizzle_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_drizzle_module.c $ngx_addon_dir/src/ngx_http_drizzle_handler.c $ngx_addon_dir/src/ngx_http_drizzle_processor.c $ngx_addon_dir/src/ngx_http_drizzle_upstream.c $ngx_addon_dir/src/ngx_http_drizzle_util.c $ngx_addon_dir/src/ngx_http_drizzle_output.c $ngx_addon_dir/src/ngx_http_drizzle_keepalive.c $ngx_addon_dir/src/ngx_http_drizzle_quoting.c $ngx_addon_dir/src/ngx_http_drizzle_checker.c"
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ddebug.h $ngx_addon_dir/src/ngx_http_drizzle_module.h $ngx_addon_dir/src/ngx_http_drizzle_handler.h $ngx_addon_dir/src/ngx_http_drizzle_processor.h $ngx_addon_dir/src/ngx_http_drizzle_upstream.h $ngx_addon_dir/src/ngx_http_drizzle_util.h $ngx_addon_dir/src/ngx_http_drizzle_output.h $ngx_addon_dir/src/resty_dbd_stream.h $ngx_addon_dir/src/ngx_http_drizzle_keepalive.h $ngx_addon_dir/src/ngx_http_drizzle_quoting.h $ngx_addon_dir/src/ngx_http_drizzle_checker.h"

have=NGX_DRIZZLE_MODULE . auto/have
