Taking #define optreset out of the _BSD_SOURCE guard requires also to take the
extern int optreset; definition to be made available.
Discovered that when compiling xz 5.0.4
Attached patch solves that problem.
Patch for optreset definition
AFAICS, xz source doesn't define _BSD_SOURCE and only checks it by AC_CHECK_DECL from getopt.m4 and as it happens only a define is enough for AC_CHECK_DECL to set the existence of queried symbol. I'd argue that it would be better to use TRY_COMPILE or TRY_LINK or something, but since we have that getopt.m4 in the wild, I'll probably revert the __mingw_optreset define move and add it to getopt.c instead.
Fixed in the trunk (rev. 5368), stable/v1.x (rev. 5367) and stable/v2.x (rev. 5366).