# -*- 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 OPTIONS ifneq "$(findstring purify,$(OPTIONS))" "" # Enable purify else ifneq "$(findstring purecov,$(OPTIONS))" "" # Enable pure coverage purecov_ld_flags += FIXED:NO endif endif ifneq "$(findstring ccdepend,$(OPTIONS))" "" # Build depends using CC endif ifneq "$(findstring wall,$(OPTIONS))" "" # Enable all warnings USE_WALL = 1 endif ifneq "$(findstring gensbr,$(OPTIONS))" "" # Generate Source Browser Files GEN_SBR_FILES = 1 endif endif ################################################################################ # 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_WIN64 ifdef ALVL vc_defines += -DALVL=$(ALVL) endif ifdef DLVL vc_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 name object file # -Fp 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 -nologo vc_flags += -GR vc_flags += -Gd vc_flags += $(call select_co,-GX,-GX,-EHsc) #vc_flags += -Wp64 ifdef USE_WALL vc_flags += -W4 else vc_flags += -W3 endif vc_compile_flags = -TC # Force C unless otherwise demanded ifdef FORCE_C_COMPILE vc_compile_flags = -TC endif ifdef FORCE_CC_COMPILE vc_compile_flags = -TP endif ifdef USE_OPTIMISE # default for production vc_flags += -Od # Don't optimise production code. Too many problems. Ship what we test else vc_flags += -Od endif ifdef USE_DEBUGINFO # default for debug vc_flags += $(call select_co,-GZ,-GZ,-RTC1) vc_defines += -DDEBUG else vc_flags += endif ifdef LEAVETMP # Create an assembly listing vc_flags += -FAs -Fa$(subst /,\\,$(basename $@).src) endif ifndef THREADMODE THREADMODE = "D" endif ifeq "$(DEBUG)" "1" # debug/prod specific vc_flags += -M$(THREADMODE)d vc_defines += -D_DEBUG else vc_flags += -M$(THREADMODE) vc_defines += -DNDEBUG endif ifdef USE_STRICT_ANSI # default OFF vc_flags += -Za else vc_flags += endif ifdef USE_RTTI vc_flags += -GR endif ifndef PDB_NONE # Supress PDB generation vc_flags += -Zi endif ifdef PRECOMPILEHDRS # Precompile headers vc_flags += $(call select_co,-YX,-YX,--) endif vc_flags += -Fp$(subst /,\\,$(OBJDIR)/) vc_flags += -Fd$(subst /,\\,$(PDB)) ifdef GEN_SBR_FILES vc_flags += -FR$(subst /,\\,$(basename $@).sbr) endif ifdef WARNINGS_AS_ERRORS vc_flags += -WX endif SHCFLAGS += $(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) cl cc_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++ compiler cc_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); \ fi endef cc_filter := "$(notdir $(wildcard $(GBE_ROOT)/warnings.visualc))" ifeq ($(strip $(cc_filter)), "warnings.visualc") cc_filter = $(GBE_ROOT)/warnings.visualc else cc_filter = endif ifdef cc_filter cc_redirect_stderr = 1 cc_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=1 vc_depend += -D_MT vc_depend += _M_X64=100 vc_depend += _M_AMD64=100 vc_depend += -D_INTEGRAL_MAX_BITS=64 ccdep = $(XX_PRE) $(GBE_BIN)/mkdepend ccdep_init = ccdep_o_switch = -f - ccdep_source = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err ccdep_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) cl cxx_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++ compiler cxx_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..' endef define cxx_post endef ############################################################################### #.. Assembler definition # #.. Assembler (Microsoft 6.11) # as = $(XX_PRE) ml as_init = as_i_switch = /I as_o_switch = /Fo$(subst /,\\,$@) as_source = $(subst /,\\,$<) as_cmdfile = $(subst /,\\,$(basename $@).cmd) as_flags = @$(as_cmdfile) as_term = as_includes += $(masm)/include as_defines += ml_flags = /c /Zm /Cp /X ifeq "$(DEBUG)" "1" ml_flags += /W2 /Zd /DDEBUG endif ifdef DLVL ml_flags += /DDLVL=$(DLVL) endif ifdef ALVL ml_flags += /DALVL=$(ALVL) endif as_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)) endef ifndef LEAVETMP define as_post @$(rm) -f $(as_cmdfile) endef else define as_post endef endif ############################################################################### #.. Archiver definition # #.. Archiver # ar = $(XX_PRE)lib ar_init = ar_flags = -nologo -machine:X64 ifeq "$(DEBUG)" "1" ar_flags += $(call select_co,-debugtype:cv,--,--) endif LIBDEF += 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_pre echo '[$@] Building library ..'; endef define ar_post endef #.. Archive Merge # armerge = $(XX_PRE) $(GBE_TOOLS)/armerge armerge_init = armerge_cmdfile = armerge_flags = -d $(MLIBDIR) -t MSVC armerge_o_switch= $(subst /,\\,$@) $(subst /,\\,$^) define armerge_pre -echo '[$@] Merging library ..'; $(rm) -f $@ endef armerge_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 LDSUBSYSTEM vc_ldflags += -subsystem:$(LDSUBSYSTEM)\\n endif #.. Shared library (dll) # shld = $(CC_PRE) link shld_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)) endef ifndef LEAVETMP define shld_post @$(rm) -f $(shld_cmdfile) endef else define shld_post endef endif define SHLDDEPEND $(AA_PRE)$(cmdfile) -wkWeo$(@) "$($(DPLIST))" endef #.. Application # ld = $(CC_PRE) link ld_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)) endef ifndef LEAVETMP define ld_post @$(rm) -f $(ld_cmdfile) endef else define ld_post endef endif define 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 #