Fix nativeapi.pm so it knows about AC_HEADER_STAT(). Make the error message about unexpected '#ifdef HAVE_XXX' clearer. Protect sys/stat.h #includes with the corresponding '#ifdef HAVE_XXX' check.