Please find my patch based on my last commit “Adjustments for Windows MSYS2/MinGW” (I can’t attach file, so here is the code):
From df685877d9844f98813f3043458c88d82be1a36e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Ancher?= <herve.ancher@cea.fr>
Date: Wed, 3 Oct 2018 10:42:14 +0200
Subject: [PATCH] Adjustments for Windows MSYS2/MinGW
---
.gitignore | 8 +++++
configure | 2 +-
src/H5private.h | 12 +++++--
src/H5system.c | 73 ++++++++++++++++++++++---------------------
tools/src/h5ls/h5ls.c | 5 +++
5 files changed, 62 insertions(+), 38 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3caf16a1c6..c04e7f36a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,9 @@ bin/missing
bin/test-driver
/build*
/configure
+/config.log
+/config.lt
+/config.status
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
@@ -41,3 +44,8 @@ src/H5overflow.h
src/H5version.h
/.classpath
+
+# Compilation objects
+**/*.o
+**/*.lo
+**/*.exe
diff --git a/configure b/configure
index e767bc9ccb..e6b198379e 100755
--- a/configure
+++ b/configure
@@ -7353,7 +7353,7 @@ fi
;;
-lkernel32)
case $host_os in
- *cygwin*) ;;
+ *cygwin* | *msys*) ;;
*) ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
;;
esac
diff --git a/src/H5private.h b/src/H5private.h
index 8974e46120..a8e8ec5710 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -1110,7 +1110,11 @@ typedef off_t h5_stat_size_t;
#define HDmemset(X,C,Z) memset(X,C,Z)
#endif /* HDmemset */
#ifndef HDmkdir
- #define HDmkdir(S,M) mkdir(S,M)
+ #if defined __MINGW32__
+ #define HDmkdir(S,M) mkdir(S)
+ #else
+ #define HDmkdir(S,M) mkdir(S,M)
+ #endif
#endif /* HDmkdir */
#ifndef HDmkfifo
#define HDmkfifo(S,M) mkfifo(S,M)
@@ -1232,7 +1236,11 @@ typedef off_t h5_stat_size_t;
#define HDsetbuf(F,S) setbuf(F,S)
#endif /* HDsetbuf */
#ifndef HDsetenv
- #define HDsetenv(N,V,O) setenv(N,V,O)
+ #if defined __MINGW32__
+ #define HDsetenv(N,V,O) Wsetenv(N,V,O)
+ #else
+ #define HDsetenv(N,V,O) setenv(N,V,O)
+ #endif
#endif /* HDsetenv */
#ifndef HDsetgid
#define HDsetgid(G) setgid(G)
diff --git a/src/H5system.c b/src/H5system.c
index 186d8fa575..a64e5508fd 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -726,6 +726,44 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5_make_time() */
+#if defined(H5_HAVE_WIN32_API) || defined(__MINGW32__)
+
+/*-------------------------------------------------------------------------
+ * Function: Wsetenv
+ *
+ * Purpose: Wrapper function for setenv on Windows systems.
+ * Interestingly, getenv *is* available in the Windows
+ * POSIX layer, just not setenv.
+ *
+ * Return: Success: 0
+ * Failure: non-zero error code
+ *
+ * Programmer: Dana Robinson
+ * February 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+Wsetenv(const char *name, const char *value, int overwrite)
+{
+ size_t bufsize;
+ errno_t err;
+
+ /* If we're not overwriting, check if the environment variable exists.
+ * If it does (i.e.: the required buffer size to store the variable's
+ * value is non-zero), then return an error code.
+ */
+ if(!overwrite) {
+ err = getenv_s(&bufsize, NULL, 0, name);
+ if (err || bufsize)
+ return (int)err;
+ } /* end if */
+
+ return (int)_putenv_s(name, value);
+} /* end Wsetenv() */
+
+#endif // H5_HAVE_WIN32_API || __MINGW32__
+
#ifdef H5_HAVE_WIN32_API
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */
@@ -783,41 +821,6 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz)
return 0;
} /* end Wgettimeofday() */
-
-/*-------------------------------------------------------------------------
- * Function: Wsetenv
- *
- * Purpose: Wrapper function for setenv on Windows systems.
- * Interestingly, getenv *is* available in the Windows
- * POSIX layer, just not setenv.
- *
- * Return: Success: 0
- * Failure: non-zero error code
- *
- * Programmer: Dana Robinson
- * February 2016
- *
- *-------------------------------------------------------------------------
- */
-int
-Wsetenv(const char *name, const char *value, int overwrite)
-{
- size_t bufsize;
- errno_t err;
-
- /* If we're not overwriting, check if the environment variable exists.
- * If it does (i.e.: the required buffer size to store the variable's
- * value is non-zero), then return an error code.
- */
- if(!overwrite) {
- err = getenv_s(&bufsize, NULL, 0, name);
- if (err || bufsize)
- return (int)err;
- } /* end if */
-
- return (int)_putenv_s(name, value);
-} /* end Wsetenv() */
-
#ifdef H5_HAVE_WINSOCK2_H
#pragma comment(lib, "advapi32.lib")
#endif
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index 4bc15260cf..53a45f95fd 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -28,6 +28,11 @@
#include "h5tools_dump.h"
#include "h5trav.h"
+#if defined(H5_HAVE_GETCONSOLESCREENBUFFERINFO) && defined(__MINGW32__)
+#include <windows.h>
+#include <wincon.h>
+#endif
+
/* Name of tool */
#define PROGRAMNAME "h5ls"
--
2.19.0