[tz] [PATCH] Support building zic.exe and zdump.exe natively on Windows with Visual Studio nmake.

Paul Eggert eggert at cs.ucla.edu
Wed Jan 31 19:55:10 UTC 2018


On 01/31/2018 08:17 AM, Manuela Friedrich wrote:
>
> We did more research on the topic and found a way that we can make 1 
> makefile work if we redefine a number of variables including some 
> scripts (shell/batch code) in tools.ini for Visual Studio compiler and 
> tools.gcc for gcc compiler and then reference these variables in 
> Makefile, each compiler type will load their own compiler specific 
> file with variables and all the variables will need to be 
> parameterized in 1 platform independent makefile.
>

That sounds like it might be a reasonable way to go, if it isn't too 
intrusive on the current Makefile. The goal would be for the Makefile to 
work unmodified on POSIX platforms, but you could use make FOO=x BAR=y 
etc. to get it to work with nmake on Microsoft platforms.

> Alternatively, we can keep the two separate makefiles, it’s pretty 
> common to have two separate makefiles
>

I'd rather avoid this, as it's more work to maintain two closely-related 
makefiles than to maintain one. Among other things, I couldn't easily 
test the nmake version.

> Regarding the Nameslashdot change on Windows stat() behaves 
> differently. It always returns 0 when run on a filename with /. appended.
>

Even if the file does not exist, or the file exists but is not a 
directory? That sounds weird. Is this behavior documented somewhere?


> Windows does not define S_ISDIR, but S_IFDIR and S_IFMT so I suggest 
> this change:
>
Thanks. I installed the attached patch into the development version; 
it's like your suggestion but moves the backward-compatibility hack more 
out of the way. As a bonus, this ports this part of tzcode back to 7th 
Edition Unix (1979).

-------------- next part --------------
From ab434a6fc826dd7eccd38b7e2a60f0fe1362b9de Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert at cs.ucla.edu>
Date: Wed, 31 Jan 2018 11:46:49 -0800
Subject: [PROPOSED] Port directory testing to MS-Windows
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From a suggestion by Manuela Friedrich in:
https://mm.icann.org/pipermail/tz/2018-January/026105.html
* zic.c (S_ISDIR): Define if sys/stat.h doesn’t, but defines the
ancient UNIX macros S_IFDIR and S_IFMT.
---
 zic.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/zic.c b/zic.c
index dc1a612..55c83e9 100644
--- a/zic.c
+++ b/zic.c
@@ -41,6 +41,10 @@ typedef int_fast64_t	zic_t;
 #else
 #define MKDIR_UMASK 0755
 #endif
+/* Port to native MS-Windows and to ancient UNIX.  */
+#if !defined S_ISDIR && defined S_IFDIR && defined S_IFMT
+# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
 
 #if HAVE_SYS_WAIT_H
 #include <sys/wait.h>	/* for WIFEXITED and WEXITSTATUS */
-- 
2.14.3



More information about the tz mailing list