win32/detectenv-msvc.mak: Support Visual Studio 2017
[platform/upstream/atk.git] / win32 / detectenv-msvc.mak
1 # Common NMake Makefile module for checking the build environment
2 # This can be copied from $(glib_srcroot)\build\win32 for GNOME items
3 # that support MSVC builds and introspection under MSVC, and can be used
4 # for building test programs as well.
5
6 # Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
7 # VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
8 !if !defined(VCINSTALLDIR) && !defined(WINDOWSSDKDIR)
9 MSG = ^
10 This Makefile is only for Visual Studio 2008 and later.^
11 You need to ensure that the Visual Studio Environment is properly set up^
12 before running this Makefile.
13 !error $(MSG)
14 !endif
15
16 ERRNUL  = 2>NUL
17 _HASH=^#
18
19 !if ![echo VCVERSION=_MSC_VER > vercl.x] \
20     && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
21     && ![echo PLAT=Win32 >> vercl.x] \
22     && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
23     && ![echo PLAT=x64 >> vercl.x] \
24     && ![echo $(_HASH)endif >> vercl.x] \
25     && ![cl -nologo -TC -P vercl.x $(ERRNUL)]
26 !include vercl.i
27 !if ![echo VCVER= ^\> vercl.vc] \
28     && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
29 !include vercl.vc
30 !endif
31 !endif
32 !if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc]
33 !endif
34
35 !if $(VCVERSION) > 1499 && $(VCVERSION) < 1600
36 VSVER = 9
37 !elseif $(VCVERSION) > 1599 && $(VCVERSION) < 1700
38 VSVER = 10
39 !elseif $(VCVERSION) > 1699 && $(VCVERSION) < 1800
40 VSVER = 11
41 !elseif $(VCVERSION) > 1799 && $(VCVERSION) < 1900
42 VSVER = 12
43 !elseif $(VCVERSION) > 1899 && $(VCVERSION) < 1910
44 VSVER = 14
45 !elseif $(VCVERSION) > 1909 && $(VCVERSION) < 2000
46 VSVER = 15
47 !else
48 VSVER = 0
49 !endif
50
51 !if "$(VSVER)" == "0"
52 MSG = ^
53 This NMake Makefile set supports Visual Studio^
54 9 (2008) through 14 (2015).  Your Visual Studio^
55 version is not supported.
56 !error $(MSG)
57 !endif
58
59 VALID_CFGSET = FALSE
60 !if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
61 VALID_CFGSET = TRUE
62 !endif
63
64 # We want debugging symbols logged for all builds,
65 # using .pdb files for release builds
66 CFLAGS_BASE = /Zi
67
68 !if "$(CFG)" == "release" || "$(CFG)" == "Release"
69 CFLAGS_ADD = /MD /O2 $(CFLAGS_BASE)
70 !else
71 CFLAGS_ADD = /MDd /Od $(CFLAGS_BASE)
72 !endif
73
74 !if "$(PLAT)" == "x64"
75 LDFLAGS_ARCH = /machine:x64
76 !else
77 LDFLAGS_ARCH = /machine:x86
78 !endif