#
# nmake.opt - main configuration file for NMAKE makefiles
#
!MESSAGE **********************************************************************
!MESSAGE *** GEOS Build Configuration ***

# TODO: Confirm as redundant and remove, nmake /P displays _NMAKE_VER anyway.
#!INCLUDE <ntwin32.mak>

###############################################################################
# For convenience, user may put custom settings to private mynmake.opt
# and use EXT_NMAKE_OPT option while calling nmake.exe, as follows:
#
# nmake -f makefile.vc EXT_NMAKE_OPT=mynmake.opt

!IFDEF EXT_NMAKE_OPT
!MESSAGE *** Setting EXT_NMAKE_OPT $(EXT_NMAKE_OPT)
!INCLUDE $(EXT_NMAKE_OPT)
!ENDIF

###############################################################################
# Set BUILD_DEBUG to YES if you want to make debug build
# and to prepare not optimized binaries.

!IFNDEF BUILD_DEBUG
BUILD_DEBUG = NO
!ENDIF

!MESSAGE *** Setting BUILD_DEBUG $(BUILD_DEBUG)

###############################################################################
# Set ENABLE_INLINE to YES if you want to make debug build
# and to prepare not optimized binaries.

!IFNDEF ENABLE_INLINE
ENABLE_INLINE = NO
!ENDIF

!MESSAGE *** Setting ENABLE_INLINE $(ENABLE_INLINE)

###############################################################################
# Set BUILD_BATCH to YES if you want feed compiler with all
# source .c and .cpp files in single batch.

!IFNDEF BUILD_BATCH
BUILD_BATCH = NO
!ENDIF

!MESSAGE *** Setting BUILD_BATCH $(BUILD_BATCH)

###############################################################################
# Set WIN64=YES if you are building for 64-bit windows (x64).
# Alternatively, pass WIN64=YES as NMAKE command line argument.
###############################################################################
!IFNDEF WIN64
WIN64 = NO
!ENDIF

!MESSAGE *** Setting WIN64 $(WIN64)

###############################################################################
# Derive version of Visual C++ being used from NMAKE if not specified
#
# WARNING:
# If we should expect variety of NMAKE build versions, tests below may fail
# and we will need to fall back to setting GEOS_MSVC as command line parameter.

!IF "$(_NMAKE_VER)" == ""
GEOS_MSVC = 4.0
!ERROR *** Failed to determine version of Visual C++
!ELSEIF "$(_NMAKE_VER)" == "162"
GEOS_MSVC = 5.0
!ERROR *** Detected Visual C++ 5.0 - NOT SUPPORTED
!ELSEIF "$(_NMAKE_VER)" == "6.00.8168.0"
GEOS_MSVC = 6.0
GEOS_MSC = 1200
!ERROR *** Detected Visual C++ 6.0 - NOT SUPPORTED
!ELSEIF "$(_NMAKE_VER)" == "7.00.9466"
GEOS_MSVC = 7.0
GEOS_MSC = 1300
!ELSEIF "$(_NMAKE_VER)" == "7.10.3077"
GEOS_MSVC = 7.1
GEOS_MSC = 1310
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42"
GEOS_MSVC = 8.0
GEOS_MSC = 1400
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762"
GEOS_MSVC = 8.0
GEOS_MSC = 1400
!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08"
GEOS_MSVC = 9.0
GEOS_MSC = 1500
!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01"
GEOS_MSVC = 9.0
GEOS_MSC = 1500
!ELSEIF "$(_NMAKE_VER)" == "10.00.30128.01"
GEOS_MSVC = 10.0
GEOS_MSC = 1600
!ELSEIF "$(_NMAKE_VER)" == "10.00.30319.01"
GEOS_MSVC = 10.0
GEOS_MSC = 1600
!ELSEIF "$(_NMAKE_VER)" == "11.00.40825.2"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.50522.1"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.50727.1"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.51106.1"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.60315.1"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.60430.2"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.60521.0"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.60610.1"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "11.00.61030.0"
GEOS_MSVC = 11.0
GEOS_MSC = 1700
!ELSEIF "$(_NMAKE_VER)" == "12.00.21005.1"
GEOS_MSVC = 12.0
GEOS_MSC = 1800
!ELSEIF "$(_NMAKE_VER)" == "14.00.22816.0"
GEOS_MSVC = 14.0
GEOS_MSC = 1900
!ELSEIF "$(_NMAKE_VER)" == "14.00.23026.0"
GEOS_MSVC = 14.0
GEOS_MSC = 1900
!ELSEIF "$(_NMAKE_VER)" == "14.00.23506.0"
GEOS_MSVC = 14.0
GEOS_MSC = 1900
!ELSEIF "$(_NMAKE_VER)" == "14.00.23918.0"
GEOS_MSVC = 14.0
GEOS_MSC = 1900
!ELSEIF "$(_NMAKE_VER)" == "14.00.24210.0"
GEOS_MSVC = 14.0
GEOS_MSC = 1900
!ELSEIF "$(_NMAKE_VER)" == "14.10.25017.0"
GEOS_MSVC = 14.10
GEOS_MSC = 1910
!ELSEIF "$(_NMAKE_VER)" == "14.10.25019.0"
GEOS_MSVC = 14.10
GEOS_MSC = 1910
!ELSEIF "$(_NMAKE_VER)" == "14.11.25506.0"
GEOS_MSVC = 14.10
GEOS_MSC = 1910
!ELSEIF "$(_NMAKE_VER)" == "14.11.25507.1"
GEOS_MSVC = 14.10
GEOS_MSC = 1910
!ELSEIF "$(_NMAKE_VER)" == "14.11.25508.2"
GEOS_MSVC = 14.10
GEOS_MSC = 1910
!ELSEIF "$(_NMAKE_VER)" == "14.11.25547.0"
GEOS_MSVC = 14.1
GEOS_MSC = 1910
!ELSE
GEOS_MSVC = 0.0
GEOS_MSC = 0
!ENDIF

!IF "$(GEOS_MSVC)" == "0.0" && "$(GEOS_MSC)" == "0"
!MESSAGE *** Cannot determine Visual C++ version
!ERROR *** Aborting make job
!ELSE
!MESSAGE *** Using Microsoft NMAKE version $(_NMAKE_VER)
!MESSAGE *** Using Microsoft Visual C++ version $(GEOS_MSVC)
!MESSAGE *** Using Microsoft C/C++ version $(GEOS_MSC)
!ENDIF

###############################################################################
# Optional use of Visual Leak Detector (VLD) http://vld.codeplex.com/
# Uncomment this line to use VLD in debug configuration only:
#MSVC_VLD_DIR=$(EXTLIBDIR)\Source\vld\vld

!IF "$(BUILD_DEBUG)" == "YES"
!IFDEF MSVC_VLD_DIR
MSVC_VLD_FLAGS=-DMSVC_USE_VLD=1 -I$(MSVC_VLD_DIR)\include
!IFDEF WIN64
MSVC_VLD_LIB=/LIBPATH:$(MSVC_VLD_DIR)/lib/Win64
!ELSE
MSVC_VLD_LIB=/LIBPATH:$(MSVC_VLD_DIR)/lib/Win32
!ENDIF
!ENDIF
!ENDIF

###############################################################################
# Include directories

GEOS_INCLUDE = -I..\include -I..\capi

!MESSAGE *** Setting GEOS_INCLUDE $(GEOS_INCLUDE)
!MESSAGE *** Setting INCLUDE $(INCLUDE)

###############################################################################
# Compilation flags for Release and Debug modes

GEOS_CPPFLAGS = /D "NOMINMAX" /D "WIN32_LEAN_AND_MEAN" /D "NOGDI"
GEOS_CPPFLAGS = $(GEOS_CPPFLAGS) /D "GEOS_DLL_EXPORT" $(MSVC_VLD_FLAGS)

!IF "$(BUILD_DEBUG)" == "YES"
BUILD_PREFIX=_d
GEOS_CFLAGS = /nologo /MDd /GR /Od /W4 /Zi
GEOS_CPPFLAGS = /D "DEBUG" /D "_DEBUG" $(GEOS_CPPFLAGS)
!ELSE
GEOS_CFLAGS = /nologo /MD /GR /O2 /W3
GEOS_CPPFLAGS = /D "NDEBUG" $(GEOS_CPPFLAGS)
!ENDIF

# Compiler version specific flags
!IF $(GEOS_MSC) >= 1400
GEOS_CFLAGS = $(GEOS_CFLAGS) /EHs
GEOS_CPPFLAGS = $(GEOS_CPPFLAGS) /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "_SCL_SECURE_NO_DEPRECATE"
!ELSE
GEOS_CFLAGS = $(GEOS_CFLAGS) /GX
!ENDIF

# For Visual C++ 9.0+ use multiple process build
!IF "$(BUILD_BATCH)" == "YES"
!IF $(GEOS_MSC) > 1400
MPFLAGS = /MP
!MESSAGE *** Setting /MP flag to number of effective processors
!ENDIF
!ENDIF

!IF "$(ENABLE_INLINE)" == "YES"
GEOS_CFLAGS = /D "GEOS_INLINE"
!ENDIF

!MESSAGE *** Using GEOS_CFLAGS $(GEOS_CFLAGS)
!MESSAGE *** Using GEOS_CPPFLAGS $(GEOS_CPPFLAGS)

CFLAGS=$(MPFLAGS) $(GEOS_CFLAGS) $(GEOS_CPPFLAGS) $(GEOS_INCLUDE)

!MESSAGE *** Complete CFLAGS $(CFLAGS)

###############################################################################
# Output location

LIBNAME = geos$(BUILD_PREFIX).lib
DLLNAME = geos$(BUILD_PREFIX).dll
SLIBNAME = geos_i$(BUILD_PREFIX).lib
CDLLNAME = geos_c$(BUILD_PREFIX).dll
CLIBNAME = geos_c_i$(BUILD_PREFIX).lib

###############################################################################
# Building toolset programs

MAKE = nmake
CC = cl
RM = del
CP = copy

# Linker executable
# - Dynamic-Linked Libraries
# $(LINK) /dll
# - Static Libraries (use of lib.exe wrapper is not portable, see VC++ Toolkit 2003)
# $(LINK) /lib
LINK = link.exe
LINKER_FLAGS = $(MSVC_VLD_LIB)

!MESSAGE **********************************************************************
# EOF
