# -*- mode: mak; -*-
###############################################################################
# File:         TOOLSET/VS2012_X64.DEF
# Contents:     Visual Studio .NET 2012 C/C++ defines for 64 Bit compilation
###############################################################################

toolset	= vs2012_x64

o		= obj
s		= asm
a		= lib
exe		= .exe

.SUFFIXES:	.asm

#
#   Setup the basic 64 Bit Visual Studio environment paths
#   This is taken from "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat"
#   This is a 64-bit compiler running natively on a 64-bit system
#
#   Cannot use vsvars64.bat data imported from the environment as it
#   will conflict with other versions of MS
#
#   The following are the default installed locations
#   Currently assume default installation of Visual Studio 2012
#
PROGRAMFILES        ?= C:/Program Files
WINDIR              ?= C:/WINDOWS

Platform			:= X64
CommandPromptType	:= Native

VSINSTALLDIR		?= $(PROGRAMFILES)/Microsoft Visual Studio 11.0
VCINSTALLDIR		?= $(VSINSTALLDIR)/VC


Framework35Version	?= v3.5
FrameworkVersion64	?= v4.0.30319
FrameworkVersion	?= $(FrameworkVersion64)

FrameworkDIR64		?= $(WINDIR)/Microsoft.NET/Framework64
FrameworkDir		?= $(FrameworkDIR64)

WindowsSdkDir		?= $(PROGRAMFILES)/Windows Kits/8.0
WindowsSdkDir_35	?= $(PROGRAMFILES)/Microsoft SDKs/Windows/v7.0A/Bin
WindowsSdkDir_old	?= $(PROGRAMFILES)/Microsoft SDKs/Windows/v8.0A

ExtensionSdkDir		?= $(PROGRAMFILES)/Microsoft SDKs/Windows/v8.0/ExtensionSDKs


DevEnvDir   := $(VSINSTALLDIR)/Common7/IDE
MSVCDir     := $(VCINSTALLDIR)/VC

# Clean up directory paths and remove trailing backslash
VSINSTALLDIR        := $(subst \,/,$(patsubst %\,%,$(VSINSTALLDIR)))
VCINSTALLDIR        := $(subst \,/,$(patsubst %\,%,$(VCINSTALLDIR)))
FrameworkDir        := $(subst \,/,$(patsubst %\,%,$(FrameworkDir)))
FrameworkDIR64      := $(subst \,/,$(patsubst %\,%,$(FrameworkDIR64)))
WindowsSdkDir       := $(subst \,/,$(patsubst %\,%,$(WindowsSdkDir)))
WindowsSdkDir       := $(subst \,/,$(patsubst %\,%,$(WindowsSdkDir)))
WindowsSdkDir_35    := $(subst \,/,$(patsubst %\,%,$(WindowsSdkDir_35)))
WindowsSdkDir_old   := $(subst \,/,$(patsubst %\,%,$(WindowsSdkDir_old)))
ExtensionSdkDir     := $(subst \,/,$(patsubst %\,%,$(ExtensionSdkDir)))

DevEnvDir           := $(subst \,/,$(patsubst %\,%,$(DevEnvDir)))
MSVCDir             := $(subst \,/,$(patsubst %\,%,$(MSVCDir)))

# Check for required update installed
GBE_VS2012_ENVVER   ?= HKCU/SOFTWARE/Microsoft/VisualStudio/11.0_Config/SplashInfo/EnvVersion
GBE_VS2012_ENVVAL4   ?= 11.0.61030.00 Update 4
GBE_VS2012_ENVVAL5   ?= 11.0.61219.00 Update 5
 

# Verify environment variable requirements
.PHONY:		visualc
visualc:
  ifndef GBE_NOTOOLSTEST
	    $(AA_PRE)$(echo) '[Toolset VS2012 X64]'; \
	    if [ ! -d "$(VSINSTALLDIR)" ]; then echo "Directory VSINSTALLDIR does not exist: $(VSINSTALLDIR)"; exit 2; fi; \
	    if [ ! -d "$(VCINSTALLDIR)" ]; then echo "Directory VCINSTALLDIR does not exist: $(VCINSTALLDIR)"; exit 2; fi; \
	    if [ ! -d "$(FrameworkDir)" ]; then echo "Directory FrameworkDir does not exist: $(FrameworkDir)"; exit 2; fi; \
	    if [ ! -d "$(FrameworkDir)/$(FrameworkVersion)" ]; then echo "Directory FrameworkVersion does not exist: $(FrameworkVersion)"; exit 2; fi; \
	    if [ ! -d "$(WindowsSdkDir)" ]; then echo "Directory WindowsSdkDir does not exist: $(WindowsSdkDir)"; exit 2; fi ; \
		checkReg "-key:$(GBE_VS2012_ENVVER)" "-value:$(GBE_VS2012_ENVVAL4)" && update4=1 ;\
		checkReg "-key:$(GBE_VS2012_ENVVER)" "-value:$(GBE_VS2012_ENVVAL5)" && update5=1 ;\
	    if [ "$${update4}$${update5}" ]; then true; else echo "VS2012 Update 4 or 5 not installed"; exit 2; fi;
  endif

VISUALC		:= $(subst \,/,$(strip $(MSVCDir)))
visualc		:= $(subst $(space),$(spacealt),$(subst \,/,$(strip $(MSVCDir))))

#
#   Setup PATH, VC_LIB and INCLUDE for the SDK
#
NET_PATH:= $(DevEnvDir)/CommonExtensions/Microsoft/TestWindow;
NET_PATH:= $(NET_PATH);$(VSINSTALLDIR)/VC/BIN/amd64;
NET_PATH:= $(NET_PATH);$(FrameworkDIR64)/$(FrameworkVersion64);
NET_PATH:= $(NET_PATH);$(FrameworkDIR64)/$(Framework35Version);
NET_PATH:= $(NET_PATH);$(VSINSTALLDIR)/VC/VCPackages;
NET_PATH:= $(NET_PATH);$(DevEnvDir);
NET_PATH:= $(NET_PATH);$(VSINSTALLDIR)/Common7/Tools;
NET_PATH:= $(NET_PATH);$(ProgramFiles(x86))/HTML Help Workshop;
NET_PATH:= $(NET_PATH);$(VSINSTALLDIR)/Team Tools/Performance Tools/x64;
NET_PATH:= $(NET_PATH);$(VSINSTALLDIR)/Team Tools/Performance Tools;
NET_PATH:= $(NET_PATH);$(WindowsSdkDir)/bin/x64;
NET_PATH:= $(NET_PATH);$(WindowsSdkDir)/bin/x86;
NET_PATH:= $(NET_PATH);$(WindowsSdkDir_old)/bin/NETFX 4.0 Tools/x64;
NET_PATH:= $(NET_PATH);$(WindowsSdkDir_35)/x64;
NET_PATH:= $(NET_PATH);$(WindowsSdkDir_old)/bin/NETFX 4.0 Tools;
NET_PATH:= $(NET_PATH);$(WindowsSdkDir_35);

ifeq "$(findstring $(NET_PATH),$(PATH))" ""
PATH    := $(NET_PATH);$(PATH)
endif
Path    := $(PATH)
export PATH


INCLUDE  := $(VSINSTALLDIR)/VC/INCLUDE;
INCLUDE  := $(INCLUDE);$(VSINSTALLDIR)/VC/ATLMFC/INCLUDE;
INCLUDE  := $(INCLUDE);$(WindowsSdkDir)/include/shared;
INCLUDE  := $(INCLUDE);$(WindowsSdkDir)/include/um;
INCLUDE  := $(INCLUDE);$(WindowsSdkDir)/include/winrt;
export INCLUDE


LIB :=
export LIB

VC_LIB     :=$(VSINSTALLDIR)/VC/LIB/amd64;
VC_LIB     := $(VC_LIB);$(VSINSTALLDIR)/VC/ATLMFC/LIB/amd64;
VC_LIB     := $(VC_LIB);$(WindowsSdkDir)/lib/win8/um/x64;
VC_LIB     := $(VC_LIB);$(FrameworkDIR64)/$(FrameworkVersion64);
VC_LIB     := $(VC_LIB);$(FrameworkDIR64)/$(Framework35Version);
VC_LIB     := $(VC_LIB);$(VSINSTALLDIR)/VC/LIB/amd64;
VC_LIB     := $(VC_LIB);$(VSINSTALLDIR)/VC/ATLMFC/LIB/amd64;
VC_LIB     := $(VC_LIB);$(WindowsSdkDir)/References/CommonConfiguration/Neutral;
VC_LIB     := $(VC_LIB);$(ExtensionSdkDir)/Microsoft.VCLibs/11.0/References/CommonConfiguration/neutral;


# rpcgen configuration
#
RPCGEN_CPP	:= cl
RPCGEN_CFLAGS	:= -EP
export RPCGEN_CPP RPCGEN_CFLAGS

#
