Make the error message about unexpected '#ifdef HAVE_XXX' clearer. Protect sys/stat.h #includes with the corresponding '#ifdef HAVE_XXX' check.
get rid of misc/registry.c and the misc directory.