From 58b16f47a82323c05ec81f0a821700beb8c2c5a0 Mon Sep 17 00:00:00 2001 From: Bob Friesenhahn Date: Sat, 25 Jan 2020 14:11:05 -0600 Subject: Add nmake build support for manually configuring the 'port' files to be built based on MSVC features. Include tif_config.h in tools/tiffset.c. --- libtiff/tif_config.vc.h | 19 +++++++++++++++---- nmake.opt | 12 +++++++++++- port/Makefile.vc | 36 ++++++++++++++++++++++++++++++++++-- port/libport.h | 8 ++++---- tools/tiffset.c | 4 ++++ 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/libtiff/tif_config.vc.h b/libtiff/tif_config.vc.h index 5cebfa02..78f3b204 100644 --- a/libtiff/tif_config.vc.h +++ b/libtiff/tif_config.vc.h @@ -104,11 +104,22 @@ /* Set the native cpu bit order */ #define HOST_FILLORDER FILLORDER_LSB2MSB +/* + Please see associated settings in "nmake.opt" which configure porting + settings. It should not be necessary to edit the following pre-processor + logic. +*/ +#if defined(_MSC_VER) /* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */ -#if defined(_MSC_VER) && _MSC_VER < 1900 -#define snprintf _snprintf -#else -#define HAVE_SNPRINTF 1 +# if _MSC_VER < 1900 /* Visual C++ 2015 */ +# define snprintf _snprintf +# else +# define HAVE_SNPRINTF 1 +# endif +# if _MSC_VER >= 1920 /* Visual Studio 2019 has strtoll/strtoull */ +# define HAVE_STRTOLL 1 +# define HAVE_STRTOULL 1 +# endif #endif /* Define to 1 if your processor stores words with the most significant byte diff --git a/nmake.opt b/nmake.opt index ae544670..d59be640 100644 --- a/nmake.opt +++ b/nmake.opt @@ -29,6 +29,7 @@ # Usage examples (see details below): # nmake -f makefile.vc # nmake -f makefile.vc DEBUG=1 +# nmake -f makefile.vc clean # # ###### Edit the following lines to choose a feature set you need. ####### @@ -108,6 +109,15 @@ CHECK_JPEG_YCBCR_SUBSAMPLING = 1 ####################### Compiler related options. ####################### # +# If your MSVC does not provide strtol() and strtoul(), then these +# should be set to 0. +HAVE_STRTOL = 1 +HAVE_STRTOUL = 1 + +# Users of MSVC 19.20 ("Visual Studio 2019") and later should set these to 1 +HAVE_STRTOLL = 0 +HAVE_STRTOULL = 0 + # # Pick debug or optimized build flags. We default to an optimized build # with no debugging information. @@ -118,7 +128,7 @@ OPTFLAGS = /MDd /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE !ELSE OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE !ENDIF -#OPTFLAGS = /Zi +#OPTFLAGS = /Zi # # Uncomment following line to enable using Windows Common RunTime Library diff --git a/port/Makefile.vc b/port/Makefile.vc index 992d2696..501f7d74 100644 --- a/port/Makefile.vc +++ b/port/Makefile.vc @@ -23,13 +23,45 @@ # Makefile for MS Visual C and Watcom C compilers. # # To build: -# C:\libtiff\port> nmake /f makefile.vc +# C:\libtiff\port> nmake /f makefile.vc !INCLUDE ..\nmake.opt +!IF $(HAVE_STRTOL) +STRTOL_OBJ = +EXTRAFLAGS = -DHAVE_STRTOL $(EXTRAFLAGS) +!ELSE +STRTOL_OBJ = strtol.obj +!ENDIF + +!IF $(HAVE_STRTOUL) +STRTOUL_OBJ = +EXTRAFLAGS = -DHAVE_STRTOUL $(EXTRAFLAGS) +!ELSE +STRTOUL_OBJ = strtoul.obj +!ENDIF + +!IF $(HAVE_STRTOLL) +STRTOLL_OBJ = +EXTRAFLAGS = -DHAVE_STRTOLL $(EXTRAFLAGS) +!ELSE +STRTOLL_OBJ = strtoll.obj +!ENDIF + +!IF $(HAVE_STRTOULL) +STRTOULL_OBJ = +EXTRAFLAGS = -DHAVE_STRTOULL $(EXTRAFLAGS) +!ELSE +STRTOULL_OBJ = strtoull.obj +!ENDIF + OBJ = \ - snprintf.obj \ + snprintf.obj \ strcasecmp.obj \ + $(STRTOL_OBJ) \ + $(STRTOUL_OBJ) \ + $(STRTOLL_OBJ) \ + $(STRTOULL_OBJ) \ getopt.obj all: libport.lib diff --git a/port/libport.h b/port/libport.h index ff262638..24e559b6 100644 --- a/port/libport.h +++ b/port/libport.h @@ -36,16 +36,16 @@ int strcasecmp(const char *s1, const char *s2); # define HAVE_GETOPT 1 #endif -#if HAVE_STRTOL +#if defined(HAVE_STRTOL) long strtol(const char *nptr, char **endptr, int base); #endif -#if HAVE_STRTOLL +#if defined(HAVE_STRTOLL) long long strtoll(const char *nptr, char **endptr, int base); #endif -#if HAVE_STRTOUL +#if defined(HAVE_STRTOUL) unsigned long strtoul(const char *nptr, char **endptr, int base); #endif -#if HAVE_STRTOULL +#if defined(HAVE_STRTOULL) unsigned long long strtoull(const char *nptr, char **endptr, int base); #endif diff --git a/tools/tiffset.c b/tools/tiffset.c index 7ecc401b..fdfdf3cc 100644 --- a/tools/tiffset.c +++ b/tools/tiffset.c @@ -35,6 +35,10 @@ #include "tiffio.h" +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + static char* usageMsg[] = { "usage: tiffset [options] filename", "where options are:", -- cgit v1.2.1