2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Configuration common to all versions of Windows NT
21 RC
= windres.exe
-O coff
--use-temp-file
22 LINK_DLL
= $(CC
) $(OS_DLLFLAGS
) $(DLLFLAGS
)
35 CLANG_CL
:= $(shell expr
`$(CC) -? 2>&1 | grep -w clang | wc -l` \
> 0)
36 # Determine compiler version
38 # clang-cl pretends to be MSVC 2012.
39 CC_VERSION
:= 17.00.00.00
41 CC_VERSION
:= $(shell $(CC
) 2>&1 | sed
-ne \
42 's|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p')
44 # Change the dots to spaces.
45 _CC_VERSION_WORDS
:= $(subst .
, ,$(CC_VERSION
))
46 _CC_VMAJOR
:= $(word 1,$(_CC_VERSION_WORDS
))
47 _CC_VMINOR
:= $(word 2,$(_CC_VERSION_WORDS
))
48 _CC_RELEASE
:= $(word 3,$(_CC_VERSION_WORDS
))
49 _CC_BUILD
:= $(word 4,$(_CC_VERSION_WORDS
))
50 _MSC_VER
= $(_CC_VMAJOR
)$(_CC_VMINOR
)
52 # VC10 (2010) is 16.00.30319.01, VC10SP1 is 16.00.40219.01.
53 _MSC_VER_GE_10SP1
:= $(shell expr
$(_MSC_VER
) \
> 1600 \| \
54 $(_MSC_VER
) = 1600 \
& $(_CC_RELEASE
) \
>= 40219)
56 _MSC_VER_GE_11
:= $(shell expr
$(_MSC_VER
) \
>= 1700)
58 _MSC_VER_GE_12
:= $(shell expr
$(_MSC_VER
) \
>= 1800)
60 _MSC_VER_GE_14
:= $(shell expr
$(_MSC_VER
) \
>= 1900)
61 ifeq ($(_CC_VMAJOR
),14)
62 # -DYNAMICBASE is only supported on VC8SP1 or newer,
63 # so be very specific here!
64 # VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
65 ifeq ($(_CC_RELEASE
).
$(_CC_BUILD
),50727.42)
68 ifeq ($(_CC_RELEASE
).
$(_CC_BUILD
),50727.762)
71 _LOSER
:= $(error Unknown compiler version
$(CC_VERSION
))
75 # if $(_CC_VMAJOR) >= 15
76 # NOTE: 'sort' sorts the words in lexical order, so this test works
77 # only if $(_CC_VMAJOR) is two digits.
78 ifeq ($(firstword $(sort $(_CC_VMAJOR
) 15)),15)
84 NSINSTALL_DIR
= $(BUILD_TREE
)/nss
86 NSINSTALL_DIR
= $(CORE_DEPTH
)/coreconf
/nsinstall
90 INSTALL
= $(NSINSTALL
)
91 GARBAGE
+= $(OBJDIR
)/vc20.pdb
$(OBJDIR
)/vc40.pdb
101 if
test ! -d
$(@D
); then mkdir
-p
$(@D
); fi
105 OS_CFLAGS
+= -mwindows
106 _GEN_IMPORT_LIB
=-Wl
,--out-implib
,$(IMPORT_LIBRARY
)
107 DLLFLAGS
+= -mwindows
-o
$@
-shared
-Wl
,--export-all-symbols
$(if
$(IMPORT_LIBRARY
),$(_GEN_IMPORT_LIB
))
109 ifeq (11,$(ALLOW_OPT_CODE_SIZE
)$(OPT_CODE_SIZE
))
114 DEFINES
+= -UDEBUG
-DNDEBUG
117 DEFINES
+= -DDEBUG
-UNDEBUG
120 WARNING_CFLAGS
= -W3
-nologo
-D_CRT_SECURE_NO_WARNINGS \
121 -D_CRT_NONSTDC_NO_WARNINGS
122 OS_DLLFLAGS
+= -nologo
-DLL
-SUBSYSTEM
:WINDOWS
123 ifndef NSS_ENABLE_WERROR
124 NSS_ENABLE_WERROR
= 1
126 ifeq ($(NSS_ENABLE_WERROR
),1)
127 WARNING_CFLAGS
+= -WX
129 ifeq ($(_MSC_VER
),$(_MSC_VER_6
))
130 ifndef MOZ_DEBUG_SYMBOLS
131 OS_DLLFLAGS
+= -PDB
:NONE
134 ifdef USE_DYNAMICBASE
135 OS_DLLFLAGS
+= -DYNAMICBASE
138 # Define USE_DEBUG_RTL if you want to use the debug runtime library
139 # (RTL) in the debug build.
140 # Define USE_STATIC_RTL if you want to use the static RTL.
148 OS_CFLAGS
+= -D_CRTDBG_MAP_ALLOC
157 ifeq (11,$(ALLOW_OPT_CODE_SIZE
)$(OPT_CODE_SIZE
))
162 DEFINES
+= -UDEBUG
-DNDEBUG
164 ifdef MOZ_DEBUG_SYMBOLS
165 ifdef MOZ_DEBUG_FLAGS
166 OPTIMIZER
+= $(MOZ_DEBUG_FLAGS
) -Fd
$(OBJDIR
)/
168 OPTIMIZER
+= -Zi
-Fd
$(OBJDIR
)/
170 DLLFLAGS
+= -DEBUG
-OPT
:REF
171 LDFLAGS
+= -DEBUG
-OPT
:REF
174 OPTIMIZER
+= -Zi
-Fd
$(OBJDIR
)/ -Od
176 DEFINES
+= -DDEBUG
-UNDEBUG
177 DLLFLAGS
+= -DEBUG
-OUT
:$@
179 ifeq ($(_MSC_VER
),$(_MSC_VER_6
))
180 ifndef MOZ_DEBUG_SYMBOLS
184 # Purify requires /FIXED:NO when linking EXEs.
186 # So the linker will find main in the gtestutil library
187 LDFLAGS
+= -SUBSYSTEM
:CONSOLE
189 ifneq ($(_MSC_VER
),$(_MSC_VER_6
))
190 # NSS has too many of these to fix, downgrade the warning
191 # Disable C4267: conversion from 'size_t' to 'type', possible loss of data
192 # Disable C4244: conversion from 'type1' to 'type2', possible loss of data
193 # Disable C4018: 'expression' : signed/unsigned mismatch
194 # Disable C4312: 'type cast': conversion from 'type1' to 'type2' of greater size
195 OS_CFLAGS
+= -w44267
-w44244
-w44018
-w44312
196 ifeq ($(_MSC_VER_GE_12
),1)
208 ifeq (,$(filter-out x386 x86_64
,$(CPU_ARCH
)))
211 # Use subsystem 5.02 to allow running on Windows XP.
212 ifeq ($(_MSC_VER_GE_11
),1)
213 LDFLAGS
+= -SUBSYSTEM
:CONSOLE
,5.02
218 # VS2012 defaults to -arch:SSE2. Use -arch:IA32 to avoid requiring
219 # SSE2. Clang-cl gets confused by -arch:IA32, so don't add it.
220 # (See https://llvm.org/bugs/show_bug.cgi?id=24335)
221 # Use subsystem 5.01 to allow running on Windows XP.
222 ifeq ($(_MSC_VER_GE_11
),1)
223 ifneq ($(CLANG_CL
),1)
224 OS_CFLAGS
+= -arch
:IA32
226 LDFLAGS
+= -SUBSYSTEM
:CONSOLE
,5.01
231 ifeq ($(CPU_ARCH
), ALPHA
)
232 DEFINES
+= -D_ALPHA_
=1
237 DLLFLAGS
+= -DEF
:$(MAPFILE
)
240 # Change PROCESS to put the mapfile in the correct format for this platform
241 PROCESS_MAP_FILE
= cp
$< $@
245 # The following is NOT needed for the NSPR 2.0 library.
248 DEFINES
+= -D_WINDOWS
250 # override default, which is ASFLAGS = CFLAGS
253 ASFLAGS
= $(INCLUDES
)
257 ASFLAGS
= -nologo
-Cp
-Sn
-Zi
$(INCLUDES
)
260 ASFLAGS
= -nologo
-Cp
-Sn
-Zi
-coff
-safeseh
$(INCLUDES
)
264 # clear any CSTD and CXXSTD unless we're using GCC
271 # override the definitions of RELEASE_TREE found in tree.mk
276 RELEASE_TREE
= $(NTBUILD_SHIP
)
278 RELEASE_TREE
= //redbuild
/components
281 RELEASE_TREE
= //redbuild
/components
286 # override the definitions of IMPORT_LIB_PREFIX, LIB_PREFIX, and
287 # DLL_PREFIX in prefix.mk
290 ifndef IMPORT_LIB_PREFIX
292 IMPORT_LIB_PREFIX
= lib
294 IMPORT_LIB_PREFIX
= $(NULL
)
311 # override the definitions of various _SUFFIX symbols in suffix.mk
326 # Assembler source suffixes
340 ifndef IMPORT_LIB_SUFFIX
341 IMPORT_LIB_SUFFIX
= .
$(LIB_SUFFIX
)
344 ifndef DYNAMIC_LIB_SUFFIX_FOR_LINKING
345 DYNAMIC_LIB_SUFFIX_FOR_LINKING
= $(IMPORT_LIB_SUFFIX
)
356 # When the processor is NOT 386-based on Windows NT, override the
357 # value of $(CPU_TAG). For WinNT, 95, 16, not CE.
359 ifneq ($(CPU_ARCH
),x386
)
360 CPU_TAG
= _
$(CPU_ARCH
)
364 # override the TARGETS defined in ruleset.mk, adding IMPORT_LIBRARY
367 TARGETS
= $(LIBRARY
) $(SHARED_LIBRARY
) $(IMPORT_LIBRARY
) $(PROGRAM
)