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

Manuela Friedrich Manuela.Friedrich at actian.com
Wed Feb 21 09:20:00 UTC 2018


This is the tools.ini file we use

[NMAKE]
!IF [ if not "%PLATFORM%" == "x64" exit /b 1 ] == 0
CFLAGSW  = /Zi -DHAVE_SYS_WAIT_H=0 -DHAVE_UNISTD_H=0 -DHAVE_INTTYPES_H=0 -DHAVE_POSIX_DECLS=0 -DHAVE_LINK=0 -DHAVE_SYMLINK=0 -DHAVE_DECL_ASCTIME_R=0 -Dssize_t=__int64 -DHAVE_STRTOLL=0 -DRESERVE_STD_EXT_IDS -DSUPPRESS_TZDIR
!ELSE
CFLAGSW  = /Zi -DHAVE_SYS_WAIT_H=0 -DHAVE_UNISTD_H=0 -DHAVE_INTTYPES_H=0 -DHAVE_POSIX_DECLS=0 -DHAVE_LINK=0 -DHAVE_SYMLINK=0 -DHAVE_DECL_ASCTIME_R=0 -Dssize_t=int -DHAVE_STRTOLL=0 -DRESERVE_STD_EXT_IDS -DSUPPRESS_TZDIR
!ENDIF
LINKW = cl $(LDFLAGS)
CCW  = cl /c
LDLIBSW  =
X   = .exe
O   = .obj
PACKAGE=          tzcode


BUGEMAIL=       tz at iana.org
TZCOBJSW=        zic$(O) getopt$(O)
TZDOBJSW=       zdump$(O) getopt$(O) localtime$(O) asctime$(O) strftime$(O)

root:                      zic$(X) zdump$(X)

version:
!IF [git describe > nul 2>&1] == 0
                                if not exist version for /f "delims=-" %%a in ('git describe') do echo %%a > version
!ELSE
                                if not exist version echo $(VERSION) > version
!ENDIF

version.h:
                                echo static char const PKGVERSION[]="($(PACKAGE)) "; >version.h
                                for /F %%H in ('type version') do echo static char const TZVERSION[]="%%H"; >> version.h
                                echo static char const REPORT_BUGS_TO[]="$(BUGEMAIL)"; >>version.h

zic$(X): $(TZCOBJSW)
                                $(LINKW) $(CFLAGSW) $(TZCOBJSW) /link /out:$@

zdump$(X):        $(TZDOBJSW)
                                $(LINKW) $(CFLAGSW) $(TZDOBJSW) /link /out:$@

clean_misc:
                                del  *$(O) *.out version.h

clean:                    clean_misc
                                del zdump$(X) zic$(X)

asctime$(O):      private.h tzfile.h
date$(O):            private.h
difftime$(O):     private.h
localtime$(O):   private.h tzfile.h
strftime$(O):     private.h tzfile.h
zdump$(O):        version.h
zic$(O):                 private.h tzfile.h version.h
getopt$(O):

.c.obj:
                                $(CCW) $*.c $(CFLAGSW)

.PHONY: root

From: Manuela Friedrich
Sent: Montag, 19. Februar 2018 12:14
To: 'Matt Johnson' <mj1856 at hotmail.com>; Paul Eggert <eggert at cs.ucla.edu>; Time Zone Mailing List <tz at iana.org>
Subject: RE: [tz] [PATCH] Support building zic.exe and zdump.exe natively on Windows with Visual Studio nmake.

Hello Matt,

Sure, here is what we currently do.

Setup 32 or 64bit Visual Studio environment

"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86_amd64
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

Place getopt.c from ftp://ftp.es.ele.tue.nl/pub/users/jos/poster/getopt.c in the source directory.

Copy attached tools.ini file into the source directory.
It uses these flags for 64bit:
CFLAGSW  = /Zi -DHAVE_SYS_WAIT_H=0 -DHAVE_UNISTD_H=0 -DHAVE_INTTYPES_H=0 -DHAVE_POSIX_DECLS=0 -DHAVE_LINK=0 -DHAVE_SYMLINK=0 -DHAVE_DECL_ASCTIME_R=0 -Dssize_t=__int64 -DHAVE_STRTOLL=0 -DRESERVE_STD_EXT_IDS -DSUPPRESS_TZDIR

Run nmake

Regards
Manuela Friedrich

From: Matt Johnson [mailto:mj1856 at hotmail.com]
Sent: Freitag, 16. Februar 2018 22:42
To: Manuela Friedrich <Manuela.Friedrich at actian.com<mailto:Manuela.Friedrich at actian.com>>; Paul Eggert <eggert at cs.ucla.edu<mailto:eggert at cs.ucla.edu>>; Time Zone Mailing List <tz at iana.org<mailto:tz at iana.org>>
Subject: Re: [tz] [PATCH] Support building zic.exe and zdump.exe natively on Windows with Visual Studio nmake.

Thanks for this.  May I request a brief summary of how to compile in Visual Studio, starting from sources to final output?  I'm not sure which flags to set, where to set them, how to work with the makefile vs. Visual Studio's project files, etc.

Thanks,
Matt
________________________________
From: tz <tz-bounces at iana.org<mailto:tz-bounces at iana.org>> on behalf of Manuela Friedrich <Manuela.Friedrich at actian.com<mailto:Manuela.Friedrich at actian.com>>
Sent: Friday, February 16, 2018 2:20 AM
To: Paul Eggert; Time Zone Mailing List
Subject: Re: [tz] [PATCH] Support building zic.exe and zdump.exe natively on Windows with Visual Studio nmake.

Thanks, Paul!

Your patches work.
We can no build zic.exe and zdump.exe from the latest git revision.

Regards
Manuela Friedrich

-----Original Message-----
From: Paul Eggert [mailto:eggert at cs.ucla.edu]
Sent: Donnerstag, 15. Februar 2018 09:10
To: Manuela Friedrich <Manuela.Friedrich at actian.com<mailto:Manuela.Friedrich at actian.com>>; Time Zone Mailing List <tz at iana.org<mailto:tz at iana.org>>
Subject: Re: [tz] [PATCH] Support building zic.exe and zdump.exe natively on Windows with Visual Studio nmake.

Manuela Friedrich wrote:

> localtime.c(1540) : error C2084: function 'tm *localtime(const time_t
> *)' already has a body

I guess the Microsoft compiler is within its rights, since C89 and later say that portable applications are not allowed to redefine 'localtime'. Proposed patch attached (it's the first patch; it's not what you suggested, but I hope it works).


> So we added code that checks if TZDIR is not empty and only then applies the the leading slash.

I'm reluctant to base this on an empty TZDIR, partly because it's confusing (empty file names do not work with POSIX), and partly because skipping TZDIR has security implications on POSIX platforms. However, I suppose we can add a macro to do something similar. Proposed patch attached (it's the 2nd patch).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20180221/38dbb015/attachment-0001.html>


More information about the tz mailing list