From 36af44c7282b183d205586cb6e059d6b863ef247 Mon Sep 17 00:00:00 2001
From: Martell Malone <martellmalone@gmail.com>
Date: Tue, 13 Jan 2015 12:13:56 +0000
Subject: [PATCH] Fix localtime_r and gmtime_r inline issues

---
 configure.ac | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/configure.ac b/configure.ac
index 77eddd1..9f59632 100644
--- a/configure.ac
+++ b/configure.ac
@@ -234,6 +234,7 @@ case "${host_os}" in
     AC_DEFINE([_ISOC11_SOURCE], [1], [Extensions to ISO C99 from ISO C11.])
     AC_DEFINE([_POSIX_SOURCE], [1], [IEEE Std 1003.1.])
     AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
+    AC_DEFINE([_POSIX],[1],[Used as alternative of _POSIX_SOURCE])
     AC_DEFINE([_XOPEN_SOURCE], [700], [POSIX and XPG 7th edition])
     AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [XPG things and X/Open Unix extensions.])
     AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.])
@@ -563,6 +564,18 @@ AC_CHECK_FUNCS(fdatasync,,
 
 dnl mingw64 implements those as static inline, not functions with C linkage
 AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([#include <time.h>], [
+        struct tm newtime;
+        time_t ltime;
+        localtime_r(&ltime, &newtime);
+    ])],[AC_DEFINE([HAVE_LOCALTIME_R],[1],[Define to 1 if you have localtime_r function])],[AC_LIBOBJ([localtime_r])])
+AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([#include <time.h>], [
+        time_t ltime;
+        struct tm mytime;
+        gmtime_r(&ltime, &mytime);
+    ])],[AC_DEFINE([HAVE_GMTIME_R],[1],[Define to 1 if you have gmtime_r function])],[AC_LIBOBJ([gmtime_r])])
+AC_LINK_IFELSE([
     AC_LANG_PROGRAM([#include <stdio.h>], [
         char *c;
         if (asprintf(&c, "%s %d", "string", 1) == -1)
-- 
2.2.1

