view auto/fmt/fmt @ 196:11fbd0fc041d

nginx-0.0.1-2003-11-26-18:42:18 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 26 Nov 2003 15:42:18 +0000
parents 8dee38ea9117
children 0b81c7a0b133
line wrap: on
line source


echo "checking for $NGX_TYPE printf() format"

NGX_FMT=NO

for FMT in $NGX_FORMATS
do
    echo "#include <stdio.h>" > autotest.c
    echo "#include <sys/types.h>" >> autotest.c
    echo "#include <sys/time.h>" >> autotest.c
    echo "#include <sys/resource.h>" >> autotest.c
    echo "$NGX_INTTYPES_H" >> autotest.c
    echo "$NGX_AUTO_CONFIG" >> autotest.c
    echo "int main() {" >> autotest.c
    echo "printf(\"${FMT}\", ($NGX_TYPE) $NGX_MAX_SIZE);" >> autotest.c
    echo "return 0; }" >> autotest.c

    eval "$CC_WARN $CC_TEST_FLAGS -o autotest autotest.c > /dev/null 2>&1"

    MAX_SIZE=`echo $NGX_MAX_SIZE | sed -e "s/L*\$//"`

    if [ -x ./autotest ]; then
        if [ "`./autotest`" = $MAX_SIZE ]; then
            if [ $NGX_FMT_COLLECT = YES ]; then
                echo " + \"${FMT}\" is appropriate"
            else
                echo " + \"${FMT}\" used"
            fi
            NGX_FMT=$FMT
        fi
    fi

    rm autotest*

    if [ $NGX_FMT != NO ]; then
        if [ $NGX_FMT_COLLECT = YES ]; then
            eval "NGX_${NGX_BYTES}_FMT=\"\${NGX_${NGX_BYTES}_FMT} \$NGX_FMT\""
            continue
        else
            break
        fi
    fi

    echo " + \"${FMT}\" is not appropriate"
done


if [ $NGX_FMT = NO ]; then
    echo "$0: error: printf() $NGX_TYPE format not found"
    exit 1
fi


if [ $NGX_FMT_COLLECT = NO ]; then
    echo "#ifndef $NGX_FMT_NAME"                 >> $NGX_AUTO_CONFIG_H
    echo "#define $NGX_FMT_NAME  \"$NGX_FMT\""   >> $NGX_AUTO_CONFIG_H
    echo "#endif"                                >> $NGX_AUTO_CONFIG_H
    echo                                         >> $NGX_AUTO_CONFIG_H
fi