Blame nss/coreconf/WIN32.mk

Packit 40b132
#
Packit 40b132
# This Source Code Form is subject to the terms of the Mozilla Public
Packit 40b132
# License, v. 2.0. If a copy of the MPL was not distributed with this
Packit 40b132
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit 40b132
Packit 40b132
#
Packit 40b132
# Configuration common to all versions of Windows NT
Packit 40b132
# and Windows 95
Packit 40b132
#
Packit 40b132
Packit 40b132
DEFAULT_COMPILER = cl
Packit 40b132
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
	CC           = gcc
Packit 40b132
	CCC          = g++
Packit 40b132
	LINK         = ld
Packit 40b132
	AR           = ar
Packit 40b132
	AR          += cr $@
Packit 40b132
	RANLIB       = ranlib
Packit 40b132
	BSDECHO      = echo
Packit 40b132
	RC           = windres.exe -O coff --use-temp-file
Packit 40b132
	LINK_DLL      = $(CC) $(OS_DLLFLAGS) $(DLLFLAGS)
Packit 40b132
else
Packit 40b132
	CC           = cl
Packit 40b132
	CCC          = cl
Packit 40b132
	LINK         = link
Packit 40b132
	AR           = lib
Packit 40b132
	AR          += -NOLOGO -OUT:$@
Packit 40b132
	RANLIB       = echo
Packit 40b132
	BSDECHO      = echo
Packit 40b132
	RC           = rc.exe
Packit 40b132
	MT           = mt.exe
Packit 40b132
	# Check for clang-cl
Packit 40b132
	CLANG_CL    := $(shell expr `$(CC) -? 2>&1 | grep -w clang | wc -l` \> 0)
Packit 40b132
	# Determine compiler version
Packit 40b132
	ifeq ($(CLANG_CL),1)
Packit 40b132
	    # clang-cl pretends to be MSVC 2012.
Packit 40b132
	    CC_VERSION  := 17.00.00.00
Packit 40b132
	else
Packit 40b132
	    CC_VERSION  := $(shell $(CC) 2>&1 | sed -ne \
Packit 40b132
		's|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p')
Packit 40b132
	endif
Packit 40b132
	# Change the dots to spaces.
Packit 40b132
	_CC_VERSION_WORDS := $(subst ., ,$(CC_VERSION))
Packit 40b132
	_CC_VMAJOR  := $(word 1,$(_CC_VERSION_WORDS))
Packit 40b132
	_CC_VMINOR  := $(word 2,$(_CC_VERSION_WORDS))
Packit 40b132
	_CC_RELEASE := $(word 3,$(_CC_VERSION_WORDS))
Packit 40b132
	_CC_BUILD   := $(word 4,$(_CC_VERSION_WORDS))
Packit 40b132
	_MSC_VER     = $(_CC_VMAJOR)$(_CC_VMINOR)
Packit 40b132
	_MSC_VER_6   = 1200
Packit 40b132
	# VC10 (2010) is 16.00.30319.01, VC10SP1 is 16.00.40219.01.
Packit 40b132
	_MSC_VER_GE_10SP1 := $(shell expr $(_MSC_VER) \> 1600 \| \
Packit 40b132
		$(_MSC_VER) = 1600 \& $(_CC_RELEASE) \>= 40219)
Packit 40b132
	# VC11 (2012).
Packit 40b132
	_MSC_VER_GE_11 := $(shell expr $(_MSC_VER) \>= 1700)
Packit 40b132
	# VC12 (2013).
Packit 40b132
	_MSC_VER_GE_12 := $(shell expr $(_MSC_VER) \>= 1800)
Packit 40b132
	ifeq ($(_CC_VMAJOR),14)
Packit 40b132
	    # -DYNAMICBASE is only supported on VC8SP1 or newer,
Packit 40b132
	    # so be very specific here!
Packit 40b132
	    # VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
Packit 40b132
	    ifeq ($(_CC_RELEASE).$(_CC_BUILD),50727.42)
Packit 40b132
		USE_DYNAMICBASE =
Packit 40b132
	    else
Packit 40b132
	    ifeq ($(_CC_RELEASE).$(_CC_BUILD),50727.762)
Packit 40b132
		USE_DYNAMICBASE = 1
Packit 40b132
	    else
Packit 40b132
		_LOSER := $(error Unknown compiler version $(CC_VERSION))
Packit 40b132
	    endif
Packit 40b132
	    endif
Packit 40b132
	endif
Packit 40b132
	# if $(_CC_VMAJOR) >= 15
Packit 40b132
	# NOTE: 'sort' sorts the words in lexical order, so this test works
Packit 40b132
	# only if $(_CC_VMAJOR) is two digits.
Packit 40b132
	ifeq ($(firstword $(sort $(_CC_VMAJOR) 15)),15)
Packit 40b132
	    USE_DYNAMICBASE = 1
Packit 40b132
	endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifdef BUILD_TREE
Packit 40b132
NSINSTALL_DIR  = $(BUILD_TREE)/nss
Packit 40b132
else
Packit 40b132
NSINSTALL_DIR  = $(CORE_DEPTH)/coreconf/nsinstall
Packit 40b132
endif
Packit 40b132
NSINSTALL      = nsinstall
Packit 40b132
Packit 40b132
MKDEPEND_DIR    = $(CORE_DEPTH)/coreconf/mkdepend
Packit 40b132
MKDEPEND        = $(MKDEPEND_DIR)/$(OBJDIR_NAME)/mkdepend.exe
Packit 40b132
# Note: MKDEPENDENCIES __MUST__ be a relative pathname, not absolute.
Packit 40b132
# If it is absolute, gmake will crash unless the named file exists.
Packit 40b132
MKDEPENDENCIES  = $(OBJDIR_NAME)/depend.mk
Packit 40b132
Packit 40b132
INSTALL      = $(NSINSTALL)
Packit 40b132
MAKE_OBJDIR  = mkdir
Packit 40b132
MAKE_OBJDIR += $(OBJDIR)
Packit 40b132
GARBAGE     += $(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb
Packit 40b132
XP_DEFINE   += -DXP_PC
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
LIB_SUFFIX   = a
Packit 40b132
else
Packit 40b132
LIB_SUFFIX   = lib
Packit 40b132
endif
Packit 40b132
DLL_SUFFIX   = dll
Packit 40b132
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
    # The -mnop-fun-dllimport flag allows us to avoid a drawback of
Packit 40b132
    # the dllimport attribute that a pointer to a function marked as
Packit 40b132
    # dllimport cannot be used as as a constant address.
Packit Service 2e48ff
    OS_CFLAGS += -mwindows -mms-bitfields -mnop-fun-dllimport
Packit 40b132
    _GEN_IMPORT_LIB=-Wl,--out-implib,$(IMPORT_LIBRARY)
Packit 40b132
    DLLFLAGS  += -mwindows -o $@ -shared -Wl,--export-all-symbols $(if $(IMPORT_LIBRARY),$(_GEN_IMPORT_LIB))
Packit 40b132
    ifdef BUILD_OPT
Packit 40b132
	ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
Packit 40b132
		OPTIMIZER += -Os
Packit 40b132
	else
Packit 40b132
		OPTIMIZER += -O2
Packit 40b132
	endif
Packit 40b132
	DEFINES    += -UDEBUG -U_DEBUG -DNDEBUG
Packit 40b132
    else
Packit 40b132
	OPTIMIZER  += -g
Packit 40b132
	NULLSTRING :=
Packit 40b132
	SPACE      := $(NULLSTRING) # end of the line
Packit 40b132
	USERNAME   := $(subst $(SPACE),_,$(USERNAME))
Packit 40b132
	USERNAME   := $(subst -,_,$(USERNAME))
Packit 40b132
	DEFINES    += -DDEBUG -D_DEBUG -UNDEBUG -DDEBUG_$(USERNAME)
Packit 40b132
    endif
Packit 40b132
else # !NS_USE_GCC
Packit 40b132
    OS_CFLAGS += -W3 -nologo -D_CRT_SECURE_NO_WARNINGS \
Packit 40b132
		 -D_CRT_NONSTDC_NO_WARNINGS
Packit 40b132
    OS_DLLFLAGS += -nologo -DLL -SUBSYSTEM:WINDOWS
Packit 40b132
    ifeq ($(_MSC_VER),$(_MSC_VER_6))
Packit 40b132
    ifndef MOZ_DEBUG_SYMBOLS
Packit 40b132
	OS_DLLFLAGS += -PDB:NONE
Packit 40b132
    endif
Packit 40b132
    endif
Packit 40b132
    ifdef USE_DYNAMICBASE
Packit 40b132
	OS_DLLFLAGS += -DYNAMICBASE
Packit 40b132
    endif
Packit 40b132
    #
Packit 40b132
    # Define USE_DEBUG_RTL if you want to use the debug runtime library
Packit 40b132
    # (RTL) in the debug build.
Packit 40b132
    # Define USE_STATIC_RTL if you want to use the static RTL.
Packit 40b132
    #
Packit 40b132
    ifdef USE_DEBUG_RTL
Packit 40b132
	ifdef USE_STATIC_RTL
Packit 40b132
		OS_CFLAGS += -MTd
Packit 40b132
	else
Packit 40b132
		OS_CFLAGS += -MDd
Packit 40b132
	endif
Packit 40b132
	OS_CFLAGS += -D_CRTDBG_MAP_ALLOC
Packit 40b132
    else
Packit 40b132
	ifdef USE_STATIC_RTL
Packit 40b132
		OS_CFLAGS += -MT
Packit 40b132
	else
Packit 40b132
		OS_CFLAGS += -MD
Packit 40b132
	endif
Packit 40b132
    endif
Packit 40b132
    ifdef BUILD_OPT
Packit 40b132
	ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
Packit 40b132
		OPTIMIZER += -O1
Packit 40b132
	else
Packit 40b132
		OPTIMIZER += -O2
Packit 40b132
	endif
Packit 40b132
	DEFINES    += -UDEBUG -U_DEBUG -DNDEBUG
Packit 40b132
	DLLFLAGS   += -OUT:$@
Packit 40b132
	ifdef MOZ_DEBUG_SYMBOLS
Packit 40b132
		ifdef MOZ_DEBUG_FLAGS
Packit 40b132
			OPTIMIZER += $(MOZ_DEBUG_FLAGS) -Fd$(OBJDIR)/
Packit 40b132
		else
Packit 40b132
			OPTIMIZER += -Zi -Fd$(OBJDIR)/
Packit 40b132
		endif
Packit 40b132
		DLLFLAGS += -DEBUG -OPT:REF
Packit 40b132
		LDFLAGS += -DEBUG -OPT:REF
Packit 40b132
	endif
Packit 40b132
    else
Packit 40b132
	OPTIMIZER += -Zi -Fd$(OBJDIR)/ -Od
Packit 40b132
	NULLSTRING :=
Packit 40b132
	SPACE      := $(NULLSTRING) # end of the line
Packit 40b132
	USERNAME   := $(subst $(SPACE),_,$(USERNAME))
Packit 40b132
	USERNAME   := $(subst -,_,$(USERNAME))
Packit 40b132
	DEFINES    += -DDEBUG -D_DEBUG -UNDEBUG -DDEBUG_$(USERNAME)
Packit 40b132
	DLLFLAGS   += -DEBUG -OUT:$@
Packit 40b132
	LDFLAGS    += -DEBUG 
Packit 40b132
ifeq ($(_MSC_VER),$(_MSC_VER_6))
Packit 40b132
ifndef MOZ_DEBUG_SYMBOLS
Packit 40b132
	LDFLAGS    += -PDB:NONE 
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
	# Purify requires /FIXED:NO when linking EXEs.
Packit 40b132
	LDFLAGS    += /FIXED:NO
Packit 40b132
    endif
Packit 40b132
ifneq ($(_MSC_VER),$(_MSC_VER_6))
Packit 40b132
    # Convert certain deadly warnings to errors (see list at end of file)
Packit 40b132
    OS_CFLAGS += -we4002 -we4003 -we4004 -we4006 -we4009 -we4013 \
Packit 40b132
     -we4015 -we4028 -we4033 -we4035 -we4045 -we4047 -we4053 -we4054 -we4063 \
Packit 40b132
     -we4064 -we4078 -we4087 -we4090 -we4098 -we4390 -we4551 -we4553 -we4715
Packit 40b132
Packit 40b132
    ifeq ($(_MSC_VER_GE_12),1)
Packit 40b132
	OS_CFLAGS += -FS
Packit 40b132
    endif
Packit 40b132
endif # !MSVC6
Packit 40b132
endif # NS_USE_GCC
Packit 40b132
Packit 40b132
ifdef USE_64
Packit 40b132
DEFINES += -DWIN64
Packit 40b132
else
Packit 40b132
DEFINES += -DWIN32
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq (,$(filter-out x386 x86_64,$(CPU_ARCH)))
Packit 40b132
ifdef USE_64
Packit 40b132
	DEFINES += -D_AMD64_
Packit 40b132
	# Use subsystem 5.02 to allow running on Windows XP.
Packit 40b132
	ifeq ($(_MSC_VER_GE_11),1)
Packit 40b132
		LDFLAGS += -SUBSYSTEM:CONSOLE,5.02
Packit 40b132
	endif
Packit 40b132
else
Packit 40b132
	DEFINES += -D_X86_
Packit 40b132
	# VS2012 defaults to -arch:SSE2. Use -arch:IA32 to avoid requiring
Packit 40b132
	# SSE2.
Packit 40b132
	# Use subsystem 5.01 to allow running on Windows XP.
Packit 40b132
	ifeq ($(_MSC_VER_GE_11),1)
Packit 40b132
		OS_CFLAGS += -arch:IA32
Packit 40b132
		LDFLAGS += -SUBSYSTEM:CONSOLE,5.01
Packit 40b132
	endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
ifeq ($(CPU_ARCH), ALPHA)
Packit 40b132
	DEFINES += -D_ALPHA_=1
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifdef MAPFILE
Packit 40b132
ifndef NS_USE_GCC
Packit 40b132
DLLFLAGS += -DEF:$(MAPFILE)
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
# Change PROCESS to put the mapfile in the correct format for this platform
Packit 40b132
PROCESS_MAP_FILE = cp $< $@
Packit 40b132
Packit 40b132
Packit 40b132
#
Packit 40b132
#  The following is NOT needed for the NSPR 2.0 library.
Packit 40b132
#
Packit 40b132
Packit 40b132
DEFINES += -D_WINDOWS
Packit 40b132
Packit 40b132
# override default, which is ASFLAGS = CFLAGS
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
	AS	= $(CC)
Packit 40b132
	ASFLAGS = $(INCLUDES)
Packit 40b132
else
Packit 40b132
ifdef USE_64
Packit 40b132
	AS	= ml64.exe
Packit 40b132
	ASFLAGS = -nologo -Cp -Sn -Zi $(INCLUDES)
Packit 40b132
else
Packit 40b132
	AS	= ml.exe
Packit 40b132
	ASFLAGS = -nologo -Cp -Sn -Zi -coff $(INCLUDES)
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# override the definitions of RELEASE_TREE found in tree.mk
Packit 40b132
#
Packit 40b132
ifndef RELEASE_TREE
Packit 40b132
    ifdef BUILD_SHIP
Packit 40b132
	ifdef USE_SHIPS
Packit 40b132
	    RELEASE_TREE = $(NTBUILD_SHIP)
Packit 40b132
	else
Packit 40b132
	    RELEASE_TREE = //redbuild/components
Packit 40b132
	endif
Packit 40b132
    else
Packit 40b132
	RELEASE_TREE = //redbuild/components
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# override the definitions of IMPORT_LIB_PREFIX, LIB_PREFIX, and
Packit 40b132
# DLL_PREFIX in prefix.mk
Packit 40b132
#
Packit 40b132
Packit 40b132
ifndef IMPORT_LIB_PREFIX
Packit 40b132
    ifdef NS_USE_GCC
Packit 40b132
	IMPORT_LIB_PREFIX = lib
Packit 40b132
    else
Packit 40b132
	IMPORT_LIB_PREFIX = $(NULL)
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifndef LIB_PREFIX
Packit 40b132
    ifdef NS_USE_GCC
Packit 40b132
	LIB_PREFIX = lib
Packit 40b132
    else
Packit 40b132
	LIB_PREFIX = $(NULL)
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifndef DLL_PREFIX
Packit 40b132
    DLL_PREFIX =  $(NULL)
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# override the definitions of various _SUFFIX symbols in suffix.mk
Packit 40b132
#
Packit 40b132
Packit 40b132
#
Packit 40b132
# Object suffixes
Packit 40b132
#
Packit 40b132
ifndef OBJ_SUFFIX
Packit 40b132
    ifdef NS_USE_GCC
Packit 40b132
	OBJ_SUFFIX = .o
Packit 40b132
    else
Packit 40b132
	OBJ_SUFFIX = .obj
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# Assembler source suffixes
Packit 40b132
#
Packit 40b132
ifndef ASM_SUFFIX
Packit 40b132
    ifdef NS_USE_GCC
Packit 40b132
	ASM_SUFFIX = .s
Packit 40b132
    else
Packit 40b132
	ASM_SUFFIX = .asm
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# Library suffixes
Packit 40b132
#
Packit 40b132
Packit 40b132
ifndef IMPORT_LIB_SUFFIX
Packit 40b132
    IMPORT_LIB_SUFFIX = .$(LIB_SUFFIX)
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifndef DYNAMIC_LIB_SUFFIX_FOR_LINKING
Packit 40b132
    DYNAMIC_LIB_SUFFIX_FOR_LINKING = $(IMPORT_LIB_SUFFIX)
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# Program suffixes
Packit 40b132
#
Packit 40b132
ifndef PROG_SUFFIX
Packit 40b132
    PROG_SUFFIX = .exe
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# When the processor is NOT 386-based on Windows NT, override the
Packit 40b132
# value of $(CPU_TAG).  For WinNT, 95, 16, not CE.
Packit 40b132
#
Packit 40b132
ifneq ($(CPU_ARCH),x386)
Packit 40b132
    CPU_TAG = _$(CPU_ARCH)
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# override ruleset.mk, removing the "lib" prefix for library names, and
Packit 40b132
# adding the "32" after the LIBRARY_VERSION.
Packit 40b132
#
Packit 40b132
ifdef LIBRARY_NAME
Packit 40b132
    SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)32$(JDK_DEBUG_SUFFIX).dll
Packit 40b132
    IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)32$(JDK_DEBUG_SUFFIX).lib
Packit 40b132
endif
Packit 40b132
Packit 40b132
#
Packit 40b132
# override the TARGETS defined in ruleset.mk, adding IMPORT_LIBRARY
Packit 40b132
#
Packit 40b132
ifndef TARGETS
Packit 40b132
    TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(PROGRAM)
Packit 40b132
endif
Packit 40b132
Packit 40b132
# list of MSVC warnings converted to errors above:
Packit 40b132
# 4002: too many actual parameters for macro 'identifier'
Packit 40b132
# 4003: not enough actual parameters for macro 'identifier'
Packit 40b132
# 4004: incorrect construction after 'defined'
Packit 40b132
# 4006: #undef expected an identifier
Packit 40b132
# 4009: string too big; trailing characters truncated
Packit 40b132
# 4015: 'identifier' : type of bit field must be integral
Packit 40b132
# 4028: formal parameter different from declaration
Packit 40b132
# 4033: 'function' must return a value
Packit 40b132
# 4035: 'function' : no return value
Packit 40b132
# 4045: 'identifier' : array bounds overflow
Packit 40b132
# 4047: 'function' : 'type 1' differs in levels of indirection from 'type 2'
Packit 40b132
# 4053: one void operand for '?:'
Packit 40b132
# 4054: 'conversion' : from function pointer 'type1' to data pointer 'type2'
Packit 40b132
# 4059: pascal string too big, length byte is length % 256
Packit 40b132
# 4063: case 'identifier' is not a valid value for switch of enum 'identifier'
Packit 40b132
# 4064: switch of incomplete enum 'identifier'
Packit 40b132
# 4078: case constant 'value' too big for the type of the switch expression
Packit 40b132
# 4087: 'function' : declared with 'void' parameter list
Packit 40b132
# 4090: 'function' : different 'const' qualifiers
Packit 40b132
# 4098: 'function' : void function returning a value
Packit 40b132
# 4390: ';' : empty controlled statement found; is this the intent?
Packit 40b132
# 4541: RTTI train wreck
Packit 40b132
# 4715: not all control paths return a value
Packit 40b132
# 4013: function undefined; assuming extern returning int
Packit 40b132
# 4553: '==' : operator has no effect; did you intend '='?
Packit 40b132
# 4551: function call missing argument list
Packit 40b132