add _XOPEN_SOURCE and option to disable TR1