Rev 6177 | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- mode: mak; -*-################################################################################ File: TOOLSET/vcwin64.rul[e]# Contents: Visual C/C++ WIN64 rules## Based on vcwin32, but it has been cleaned up for the 64-bit builds# Legacy support has been removed#################################################################################.. Remove "undef" warnings#cc_includes +=cc_defines +=cxx_includes +=cxx_defines +=purecov_ld_flags +=################################################################################.. Parse user options# Global options already parsed# These options extend the global options#ifdef OPTIONSifneq "$(findstring purify,$(OPTIONS))" "" # Enable purifyelseifneq "$(findstring purecov,$(OPTIONS))" "" # Enable pure coveragepurecov_ld_flags += FIXED:NOendifendififneq "$(findstring ccdepend,$(OPTIONS))" "" # Build depends using CCendififneq "$(findstring wall,$(OPTIONS))" "" # Enable all warningsUSE_WALL = 1endififneq "$(findstring gensbr,$(OPTIONS))" "" # Generate Source Browser FilesGEN_SBR_FILES = 1endifendif################################################################################# Define a macro to assist in selecting compiler options based on the# type of compiler being being used. New versions of compilers will deprecate# options or replace some## select_co - Select Compiler Option# - Arguments are for the different compilers as defined by VSCOMPILER# VSCOMPILER in the range 1.. as defined in the .PL file## Current usage# 1 - vc6# 2 - vc7# 3 - vc8,vc9,vc10,vc12#$(if $(VSCOMPILER),,$(error VCWIN64 toolset requires VSCOMPILER to be defined))select_co = $(subst --,,$(word $(VSCOMPILER),$1 $2 $3))################################################################################ Standard library paths# Export LIB as this is used by the compiler (#import) as well as the# librarian and the linker. It is also used by the library generation# process.## VC_LIB - Lib paths from Compiler toolkit# - ';' seperated path list# - Uses \ or / as a dir sep# - Uses real spaces in pathnames# - Should be Absolute Paths## LIBDIRS - Lib paths from JATS# - Space seperated path list# - Uses / as dir sep# - Must not contain spaces# - Will be Relative## ALL_LIBDIRS and LIB# - Only contain valid paths# VS2005 will complain about bad LIB entries# Use $(wildcard ...) to limit to test for existence# - Contain absolute paths# msdev/devenv don't work with relative paths# Use $(abspath ...) to convert## ALL_LIBDIRS - Used internally# - Space seperated path list# - Uses / as dir sep# - Uses %20 as a altspace in pathnames## LIB - Exported to tools# - ';' seperated path list# - Uses \ as a dir sep# - Uses real spaces in pathnames#..vc_libs := $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(VC_LIB))))ALL_LIBDIRS := $(wildcard $(call myabspath,$(LIBDIRS))) $(vc_libs)LIB := $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,%;,$(subst /,\,$(ALL_LIBDIRS)))))export LIB#one_per_line = $(foreach aa,$2,$(info $1 :: $(subst $(spacealt),$(space),$(aa))))#$(call one_per_line,Good LIBDIRS,$(ALL_LIBDIRS))################################################################################.. Compiler definitions##.. C Compiler definition## Standard defines##..vc_defines += -DWIN32 -D_WIN32 -DWIN64 -D_WIN64ifdef ALVLvc_defines += -DALVL=$(ALVL)endififdef DLVLvc_defines += -DDLVL=$(DLVL)endif## __SOURCE__ interferes with Windows Precompiled headers# It can be disabled, but its not for backward compatability#ifndef DISABLE__SOURCE__vc_defines += -D__SOURCE__=\"$(notdir $<)\"endif# Standard flags## Both compilers now use the same front end - you must still define either# _X86_ or _ALPHA_. These have replaced the i386 and ALPHA definitions# which are not ANSI compliant.## Common compiler flags:# -c - compile without linking# -W3 - Set warning level to level 3# -Zi - generate debugging information# -Zd - generate only public symbols and line numbers for debugging# -Od - disable all optimizations# -Ox - use maximum optimizations# -Ge - enable stack checks# -Gm - enable min builds# -GX - (Deprecated: Use -EHsc) Enables synchronous exception handling (C++)# -EHsc - Enables synchronous exception handling (C++)# -YX - (Deprecated: Don't use) Automatically generate precompiled headers# -Yd - Place debug info within objects.# -GZ - (Deprecated: Use -RTC1)Enable runtime debug checks# -GR - Enables run-time type information (RTTI)# -MD - Creates a multithreaded DLL, using MSVCRT.LIB# -MDd - Creates a debug multithreaded DLL, using MSVCRTD.LIB## Output options:# -Fo<file> name object file# -Fp<file> name precompiled header file# -Fd[file] name .PDB file# -Fm[file] name map file# -FR[file] name source browser file (Complete)# -Fr[file] name source browser file (No locals)## i386 specific compiler flags:# -Gz - stdcall# -Gd - cdecl## Plus:# -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl# _X86_ | _MIPS_ | _PPC_# WINNT | WIN95# WINVER=0x0500 (5.0) | WINVER=0x0400 (4.0) | WINVER=0x030A (3.51)# _MT## Linker# -MT[d] using MT safe C library## ! Warning !# If you are going to call C run-time routines from a program# built with LIBCMT.LIB, you must start your threads with the# _beginthread function. Do not use the Win32 functions# ExitThread and CreateThread. Using SuspendThread can lead to# a deadlock when more than one thread is blocked waiting for# the suspend thread to complete its access to a C run-time# data structure.#..vc_flags += -c -nologovc_flags += -GRvc_flags += -Gdvc_flags += $(call select_co,-GX,-GX,-EHsc)#vc_flags += -Wp64ifdef USE_WALLvc_flags += -W4elsevc_flags += -W3endifvc_compile_flags = -TC # Force C unless otherwise demandedifdef FORCE_C_COMPILEvc_compile_flags = -TCendififdef FORCE_CC_COMPILEvc_compile_flags = -TPendififdef USE_OPTIMISE # default for productionvc_flags += -Od # Don't optimise production code. Too many problems. Ship what we testelsevc_flags += -Odendififdef USE_DEBUGINFO # default for debugvc_flags += $(call select_co,-GZ,-GZ,-RTC1)vc_defines += -DDEBUGelsevc_flags +=endififdef LEAVETMP # Create an assembly listingvc_flags += -FAs -Fa$(subst /,\\,$(basename $@).src)endififndef THREADMODETHREADMODE = "D"endififeq "$(DEBUG)" "1" # debug/prod specificvc_flags += -M$(THREADMODE)dvc_defines += -D_DEBUGelsevc_flags += -M$(THREADMODE)vc_defines += -DNDEBUGendififdef USE_STRICT_ANSI # default OFFvc_flags += -Zaelsevc_flags +=endififdef USE_RTTIvc_flags += -GRendififndef PDB_NONE # Supress PDB generationvc_flags += -Ziendififdef PRECOMPILEHDRS # Precompile headersvc_flags += $(call select_co,-YX,-YX,--)endifvc_flags += -Fp$(subst /,\\,$(OBJDIR)/)vc_flags += -Fd$(subst /,\\,$(PDB))ifdef GEN_SBR_FILESvc_flags += -FR$(subst /,\\,$(basename $@).sbr)endififdef WARNINGS_AS_ERRORSvc_flags += -WXendifSHCFLAGS += $(call select_co,-GD,--,--)SHCXXFLAGS += $(call select_co,-GD,--,--)# Standard includes# INCLUDE - a ';' seperated list of paths# vc_include - a 'space' seperated list of paths# - Using / for path sep# - Using 'spacealt'(%20) for 'space' placeholder#..vc_includes =\$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(INCLUDE))))# Command##..cc = $(CC_PRE) clcc_init =cc_o_switch = $(subst /,\\,-Fo$@)cc_source = $(subst /,\\,$<)# CFLAGS must follow vc_flags to build with netbula headers# these should be the ONLY c files that must be built with the C compiler# until netbula support the C++ compilercc_flags = \$(strip $(vc_compile_flags)) \$(strip $(patsubst %,%,$(vc_flags))) \$(strip $(patsubst %,%,$(vc_defines))) \$(patsubst %,%,$(CFLAGS)) \$(patsubst %,-D%,$(cc_defines)) \$(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst /,\,$(INCDIRS)))) \$(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst /,\,$(cc_includes)))) \$(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst /,\,$(vc_includes))))cc_term =define cc_pre@$(echo) '[$<] Compiling..'endef# Note: The compiler gets the case of the PDB file# wrong, force to be mixed case. Also generating of the# PDB image is optional based on debugging options, must# test if file exists.## Leave the $(PDB).tmp file otherwise clearaudit gets upset#define cc_post@if [ -f $(PDB) ]; then \$(rm) -f $(PDB).tmp; \$(mv) $(PDB) $(PDB).tmp; \$(cp) $(PDB).tmp $(PDB); \fiendefcc_filter := "$(notdir $(wildcard $(GBE_ROOT)/warnings.visualc))"ifeq ($(strip $(cc_filter)), "warnings.visualc")cc_filter = $(GBE_ROOT)/warnings.visualcelsecc_filter =endififdef cc_filtercc_redirect_stderr = 1cc_error_filter = $(awk) -f $(cc_filter)endif################################################################################.. C/C++ dependencies# depend and depend.err## Definitions provided by the compiler.# Need to mimic them for dependency generation#vc_depend = -D_MSC_VER=1700 -D_MSC_EXTENSIONS=1vc_depend += -D_MTvc_depend += _M_X64=100vc_depend += _M_AMD64=100vc_depend += -D_INTEGRAL_MAX_BITS=64ccdep = $(XX_PRE) $(GBE_BIN)/mkdependccdep_init =ccdep_o_switch = -f -ccdep_source = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.errccdep_flags = -MM -b -We -p '$$(OBJDIR)/' \$(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \-o ".$(o)" \$(patsubst %,%,$(vc_depend)) \$(patsubst %,%,$(vc_defines)) \$(patsubst %,%,$(CFLAGS)) \$(patsubst %,%,$(CXXFLAGS)) \$(patsubst %,-D%,$(cc_defines)) \$(patsubst %,-D%,$(cxx_defines)) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(INCDIRS)))) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(cc_includes)))) \$(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(subst /,\,$(vc_includes)))) \$(patsubst %,-Y %,$(NODEPDIRS))ccdep_pre =ccdep_post =#.. C/C++ Lint definitions# -D Definition is not allowed: PCLINT does not like the space#lint_flags += \$(patsubst %,%,$(vc_depend)) \$(subst -D$(space),-D,$(patsubst %,%,$(vc_defines))) \$(patsubst %,%,$(CLINTFLAGS)) \$(patsubst %,-D%,$(cc_defines)) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(INCDIRS))) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(cc_includes))) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(vc_includes)))lint_libpath = $(LIB)#.. C++ Compiler definitions#cxx = $(CC_PRE) clcxx_init =cxx_o_switch = $(subst /,\\,-Fo$@)cxx_source = $(subst /,\\,$<)# CXXFLAGS must follow vc_flags to build with netbula headers# these should be the ONLY c files that must be built with the C compiler# until netbula support the C++ compilercxx_flags = -TP \$(patsubst %,%,$(vc_flags)) \$(patsubst %,%,$(vc_defines)) \$(patsubst %,%,$(CXXFLAGS)) \$(patsubst %,-D%,$(cxx_defines)) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(INCDIRS)))) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(cxx_includes)))) \$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(vc_includes))))cxx_term =define cxx_pre@echo '[$<] compiling..'endefdefine cxx_postendef################################################################################.. Assembler definition##.. Assembler (Microsoft 6.11)#as = $(XX_PRE) mlas_init =as_i_switch = /Ias_o_switch = /Fo$(subst /,\\,$@)as_source = $(subst /,\\,$<)as_cmdfile = $(subst /,\\,$(basename $@).cmd)as_flags = @$(as_cmdfile)as_term =as_includes += $(masm)/includeas_defines +=ml_flags = /c /Zm /Cp /Xifeq "$(DEBUG)" "1"ml_flags += /W2 /Zd /DDEBUGendififdef DLVLml_flags += /DDLVL=$(DLVL)endififdef ALVLml_flags += /DALVL=$(ALVL)endifas_defines := $(addprefix /D,$(as_defines))as_defines += $(ml_flags)define as_pre$(AA_PRE)$(cmdfile) -wko$(as_cmdfile) "\$(patsubst %,%\\n,$(ASFLAGS)) \$(patsubst %,%\\n,$(as_defines)) \$(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(INCLUDES))) \$(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(as_includes)))";\$(call show_cmdfile,$(as_cmdfile))endefifndef LEAVETMPdefine as_post@$(rm) -f $(as_cmdfile)endefelsedefine as_postendefendif################################################################################.. Archiver definition##.. Archiver#ar = $(XX_PRE)libar_init =ar_flags = -nologo -machine:X64ifeq "$(DEBUG)" "1"ar_flags += $(call select_co,-debugtype:cv,--,--)endifLIBDEF +=ar_flags += $(patsubst %,-def:%,$(LIBDEF))LIBNAME +=ar_flags += $(patsubst %,-name:%,$(LIBNAME))ar_o_switch = -out:$(subst /,\\,$@) $(subst /,\\,$(filter %.obj,$^)) $(subst /,\\,$(filter %.res,$^))ar_term =define ar_preecho '[$@] Building library ..';endefdefine ar_postendef#.. Archive Merge#armerge = $(XX_PRE) $(GBE_TOOLS)/armergearmerge_init =armerge_cmdfile =armerge_flags = -d $(MLIBDIR) -t MSVCarmerge_o_switch= $(subst /,\\,$@) $(subst /,\\,$^)define armerge_pre-echo '[$@] Merging library ..'; $(rm) -f $@endefarmerge_post =################################################################################.. Linker## Standard flags##..vc_ldflags = \-nologo\\n\-incremental:no\\n\-debug\\n\$(subst $(spacealt),$(space),$(patsubst %,-libpath:\"%\"\\n,$(subst /,\\\\,$(ALL_LIBDIRS))))\$(subst $(spacealt),$(space),$(patsubst %,\"-%\"\\n,$(LDFLAGS)))\$(patsubst %,-%\\n,$(purecov_ld_flags))ifdef LDSUBSYSTEMvc_ldflags += -subsystem:$(LDSUBSYSTEM)\\nendif#.. Shared library (dll)#shld = $(CC_PRE) linkshld_cmdfile = $(subst /,\\,$(basename $@).ld)shld_flags =shld_o_switch = @$(shld_cmdfile)shld_term =define shld_pre$(AA_PRE)$(cmdfile) -wkWeo$(shld_cmdfile) \"$(vc_ldflags) $($(notdir $(SHBASE))_shld)"; \echo '[$@] Linking shared library ..';\$(call show_cmdfile,$(shld_cmdfile))endefifndef LEAVETMPdefine shld_post@$(rm) -f $(shld_cmdfile)endefelsedefine shld_postendefendifdefine SHLDDEPEND$(AA_PRE)$(cmdfile) -wkWeo$(@) "$($(DPLIST))"endef#.. Application#ld = $(CC_PRE) linkld_cmdfile = $(subst /,\\,$(basename $@).ld)ld_flags =ld_o_switch = @$(ld_cmdfile)ld_term =define ld_pre$(AA_PRE)$(cmdfile) -wkWeo$(ld_cmdfile) \"$(vc_ldflags) $($(notdir $(basename $@))_ld)"; \echo '[$@] Linking application ..';\$(call show_cmdfile,$(ld_cmdfile))endefifndef LEAVETMPdefine ld_post@$(rm) -f $(ld_cmdfile)endefelsedefine ld_postendefendifdefine LDDEPEND$(AA_PRE)$(cmdfile) -wkWeo$(@) "$($(DPLIST))"endef#.. Resource Compiler# Convert a .rc file into a .res file# Set up the INCLUDE envar to conatin the path to locate required# files and the local and interface directories then the compiler directories## Currently RC has a limit of 100 include paths to seach# Simply limit the list to the system paths and the directories# required by the prerequisite files#rc_defines = $(subst -D,/d ,$(vc_defines))rc_dirs = $(subst /,\,$(sort $(dir $^)))rc_dirs += $(LINCDIRS)rc_dirs += $(vc_includes)rc_include = $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,%;,$(subst /,\,$(rc_dirs)))))rc_include1 = $(subst \;,;,$(rc_include))define RC@$(echo) '[$@] Compile Resource File ..'@$(show_environment)$(XX_PRE) export INCLUDE; INCLUDE="$(rc_include1)"; \RC /l 0xC09 $(rc_defines) /fo $(subst /,\\,$@) $(subst /,\\,$<)endef#.. Browser Information# Create a .BSC file from many .SBR files# Filter out non .SBR files to assist in rule creation#define BSCMAKE@$(echo) '[$@] Create Source Browser Information ..'@$(show_environment)$(XX_PRE) bscmake -nologo -n -o $(subst /,\\,$@) $(subst /,\\,$(filter %.sbr,$^))endef#