#! /bin/sh

. ../support/simple_eval_tools.sh

HEADER header compilation

find "${srcdir}/include/net-snmp" \
    -path "${srcdir}/include/net-snmp/system/*" -prune -o \
    -path "${srcdir}/include/net-snmp/machine/*" -prune -o \
    -path "${srcdir}/include/net-snmp/data_access/*" -prune -o \
    -name '*.h' -print \
    | while true ; do
    if read path ; then
        file=`echo $path | sed -e "s#^${srcdir}/include/##"`
        dest="${SNMP_TMPDIR}/T210-"`expr "$outputcount" + 1`
        cat > "$dest.c" <<EOF
#include <net-snmp/net-snmp-config.h>
#include <${file}>
int i;
EOF
        CAPTURE `${builddir}/net-snmp-config --build-command` \
            -I$builddir/include -I$srcdir/include -c -o "$dest.o" "$dest.c"
        if [ "$?" = 0 -a -f "$dest.o" ] ; then
            GOOD "Successfully compiled $file"
        else
            BAD "Failed to compile $file"
        fi
        echo "# testnum = $testnum"
    else
        echo ']]]]]]]]' > "$SNMP_TMPDIR/dummy.pid"

        FINISHED
        break
    fi
done

# This exit is here since the above loop have a bad habit of ending up in a
# subshell and thus the 'exit' that FINISHED performs only terminate the
# subshell.
# Putting the FINISHED outside the loop instead means that all the test
# variables won't be seen by it and so the output will be wrong.

exit 0
