# Microsoft Visual C++ # (C) Copyright David Abrahams 2001. Permission to copy, use, # modify, sell and distribute this software is granted provided this # copyright notice appears in all copies. This software is provided # "as is" without express or implied warranty, and with no claim as # to its suitability for any purpose. # Get these variable set on the targets so that we can re-use the # build actions for other toolsets using this one as a base. flags msvc VC_TOOL_PATH ; flags msvc VC_SETUP ; flags msvc VC_COMPILER ; flags msvc VC_LINKER ; flags msvc VC_PDB_NAME ; # compute MSVC tool path # You can either put the msvc bin directory in your PATH, or you can set # MSVCDir to point at the msvc installation directory if ! $(MSVCDir) { MSVC_ROOT ?= $(VISUALC) ; MSVC_ROOT ?= "C:\\Program Files\\Microsoft Visual C++\\VC98" ; VC_TOOL_PATH ?= "$(MSVC_ROOT)"$(SLASH)bin$(SLASH) ; VC_SETUP ?= "CALL \"$(VC_TOOL_PATH)VCVARS32.BAT\" >nul" ; } else { VC_TOOL_PATH ?= "" ; # Don't clobber adjoining text if MSVCDir is already set } VC_COMPILER = cl ; VC_LINKER = link ; VC_PDB_NAME = vc60 ; flags msvc CFLAGS on/object : /Z7 ; flags msvc CFLAGS on/database : /Zi ; flags msvc PDB_CFLAG on/database : /Fd ; flags msvc LINKFLAGS on : /DEBUG ; flags msvc CFLAGS off : /Od ; flags msvc CFLAGS speed : /O2 ; flags msvc CFLAGS space : /O1 ; flags msvc CFLAGS off : /Ob0 ; flags msvc CFLAGS on : /Ob1 ; flags msvc CFLAGS full : /Ob2 ; flags msvc CFLAGS on : /GX ; flags msvc CFLAGS on : /GR ; # Note that these two options actually imply multithreading support on MSVC # because there is no single-threaded dynamic runtime library. Specifying # multi would be a bad idea, though, because no option would be # matched when the build uses the default settings of dynamic # and single. flags msvc CFLAGS release/dynamic : /MD ; flags msvc CFLAGS debug/dynamic : /MDd ; flags msvc CFLAGS release/static/single : /ML ; flags msvc CFLAGS debug/static/single : /MLd ; flags msvc CFLAGS release/static/multi : /MT ; flags msvc CFLAGS debug/static/multi : /MTd ; flags msvc CFLAGS ; flags msvc C++FLAGS ; flags msvc DEFINES ; flags msvc UNDEFS ; flags msvc HDRS ; flags msvc STDHDRS ; flags msvc LINKFLAGS ; flags msvc ARFLAGS ; flags msvc STDHDRS : $(MSVCDir)$(SLASH)include ; flags msvc STDLIBPATH : $(MSVCDir)$(SLASH)lib ; flags msvc LIBPATH ; flags msvc NEEDLIBS ; flags msvc FINDLIBS ; flags msvc LINKFLAGS $(SHARED_TYPES) : /DLL ; rule vc-set-pdb-file ( targets + : name ) { local pdb = $(targets[1]:B=$(name):S=.pdb) ; VC_PDB_FILE on $(targets) = $(pdb:G=:R=$(LOCATE_TARGET)) ; LOCATE on $(pdb) = $(LOCATE_TARGET) ; Clean clean : $(pdb) ; } #### Link #### rule Link-action ( target implib ? : sources + : target-type ? ) { with-command-file vc-Link $(<) : $(sources) $(NEEDLIBS) ; if $(implib) { # incremental linking a DLL causes no end of problems: if the # actual exports don't change, the import .lib file is never # updated. Therefore, the .lib is always out-of-date and gets # rebuilt every time. I'm not sure that incremental linking is # such a great idea in general, but in this case I'm sure we # don't want it. NOINCREMENTAL on $(<) = /INCREMENTAL:NO ; } vc-set-pdb-file $(<) : $(target:B) ; } actions together vc-Link bind NEEDLIBS { $(VC_SETUP) "$(VC_TOOL_PATH)$(VC_LINKER)" /nologo $(NOINCREMENTAL) $(LINKFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<[1])" /IMPLIB:$(<[2]) /LIBPATH:$(LIBPATH) /LIBPATH:$(STDLIBPATH) "$(FINDLIBS:S=.lib)" @"$(>)" } #### Cc ##### rule Cc-action { vc-set-pdb-file $(<) : $(VC_PDB_NAME) ; vc-Cc $(<) : $(>) ; } actions vc-Cc { $(VC_SETUP) "$(VC_TOOL_PATH)$(VC_COMPILER)" /Zm400 -nologo -c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I"$(STDHDRS)" $(PDB_CFLAG)"$(VC_PDB_FILE)" -Fo"$(<)" "$(>)" } #### C++ #### rule C++-action { vc-set-pdb-file $(<) : $(VC_PDB_NAME) ; vc-C++ $(<) : $(>) ; } actions vc-C++ { $(VC_SETUP) "$(VC_TOOL_PATH)$(VC_COMPILER)" /Zm400 -nologo -GX -c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" $(PDB_CFLAG)"$(VC_PDB_FILE)" -Fo"$(<)" -Tp"$(>)" } #### Archive #### rule Archive-action { vc-set-pdb-file $(<) : $(<:B) ; with-command-file vc-Archive $(<) : $(>) ; } actions updated together piecemeal vc-Archive { $(VC_SETUP) if exist "$(<)" set _$(<:B)_="$(<)" "$(VC_TOOL_PATH)$(VC_LINKER)" /lib $(ARFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<)" %_$(<:B)_% @"$(>)" }