Debian Codegraph @

build/win32/detectenv-msvc.mak

raw
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) < 1920
46 VSVER = 15
47 !elseif $(VCVERSION) > 1919 && $(VCVERSION) < 2000
48 VSVER = 16
49 !else
50 VSVER = 0
51 !endif
52
53 !if "$(VSVER)" == "0"
54 MSG = ^
55 This NMake Makefile set supports Visual Studio^
56 9 (2008) through 16 (2019). Your Visual Studio^
57 version is not supported.
58 !error $(MSG)
59 !endif
60
61 VALID_CFGSET = FALSE
62 !if "$(CFG)" == "release" || "$(CFG)" == "debug" || "$(CFG)" == "Release" || "$(CFG)" == "Debug"
63 VALID_CFGSET = TRUE
64 !endif
65
66 # We want debugging symbols logged for all builds,
67 # using .pdb files for release builds
68 CFLAGS_BASE = /Zi
69
70 !if "$(CFG)" == "release" || "$(CFG)" == "Release"
71 CFLAGS_ADD = /MD /O2 $(CFLAGS_BASE)
72 !else
73 CFLAGS_ADD = /MDd /Od $(CFLAGS_BASE)
74 !endif
75
76 !if "$(PLAT)" == "x64"
77 LDFLAGS_ARCH = /machine:x64
78 !else
79 LDFLAGS_ARCH = /machine:x86
80 !endif