Rev 6177 | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- mode: mak; -*-################################################################################ File: TOOLSET/vcwce.rul[e]# Contents: eMbedded C++ rules#################################################################################.. Remove "undef" warnings#vc_includes +=vc_libs +=cc_includes +=cc_defines +=cxx_includes +=cxx_defines +=################################################################################.. 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 coverageendifendififneq "$(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 - evc# 2 - vs2005#$(if $(VSCOMPILER),,$(error VCWIN32 toolset requires VSCOMPILER to be defined))select_co = $(subst --,,$(word $(VSCOMPILER),$1 $2 $3))################################################################################ Add in SDK specfic paths# Already have Framework specfic paths## Standard includes##..vc_includes +=\$(call encodepath,$(SDKROOT)/Include/$(WCE_TARGETCPU))\$(call encodepath,$(SDKROOT)/Include)\$(call encodepath,$(SDKROOT)/MFC/Include)\$(call encodepath,$(SDKROOT)/ATL/Include)# Standard library paths##..ifdef WCE_EMULATORvc_libs +=\$(call encodepath,$(SDKROOT)/Lib/$(WCE_TARGETCPU))\$(call encodepath,$(SDKROOT)/MFC/Lib/$(WCE_HOSTCPU))\$(call encodepath,$(SDKROOT)/ATL/Lib/$(WCE_HOSTCPU))elsevc_libs +=\$(call encodepath,$(SDKROOT)/Lib/$(WCE_TARGETCPU))\$(call encodepath,$(SDKROOT)/MFC/Lib/$(WCE_TARGETCPU))\$(call encodepath,$(SDKROOT)/ATL/Lib/$(WCE_TARGETCPU))endif################################################################################ Standard include paths - in the order they should be searched# INCDIRS - Local and Global Interface paths# Relative and absolute# No spaces in paths# cc_includes - Toolset paths (this toolset)# Relative and absolute# No spaces in paths# vc_includes - SDK paths# Encoded to handle spaces in paths## These are then converted into# INCLUDE_LIST - Encoded Path List# INCLUDE - Colon Sep, May have spaces, Uses /## Note: Convert INCDIRS to absolute paths for project/solution builds#INCLUDE_LIST = $(wildcard $(call myabspath,$(INCDIRS))) $(cc_includes) $(vc_includes)INCLUDE = $(call decodepath,,;,$(INCLUDE_LIST))export INCLUDE################################################################################ Standard library paths - in the order they should be searched# LIBDIRS - Local and Global Interface paths# Relative and absolute# No spaces in paths# vc_libs - SDK paths# Encoded to handle spaces in paths## These are then converted into# INCLUDE_LIST - Encoded Path List# INCLUDE - Colon Sep, May have spaces, Uses /## Note: Convert INCDIRS to absolute paths for project/solution builds#LIB_LIST = $(wildcard $(call myabspath,$(LIBDIRS))) $(vc_libs)LIB = $(call decodepath,,;,$(LIB_LIST))export LIB#$(info INCLUDE_LIST: $(INCLUDE_LIST))#$(info INCLUDE: $(INCLUDE))##$(info LIB_LIST: $(LIB_LIST))#$(info LIB: $(LIB))################################################################################.. Compiler definitions##.. C Compiler definition## Standard defines##..vc_defines += -DUNDER_CE=$(WCE_VERSION) -D_WIN32_WCE=$(WCE_VERSION) -D$(WCE_PLATFORM_SDK_DEF)vc_defines += -D "$(WCE_PLATFORM)" -D "$(WCE_TARGETCPU)"ifdef WCE_DEFINESvc_defines += $(WCE_DEFINES)endifvc_defines += -D "UNICODE" -D "_UNICODE"ifdef 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# -GZ - enable runtime debug checks# -Gm - enable min builds# -GX - enable C++ EH (same as /EHsc)# -YX - generate precompiled headers# -Yd - Place debug info within objects.# -GF - enable read-only string pooling# 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 += -cvc_flags += -nologoifdef USE_WALLvc_flags += -W4elsevc_flags += -W3endififdef WCE_CFLAGSvc_flags += $(WCE_CFLAGS)endifvc_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_defines += -DDEBUGelsevc_flags +=endififdef LEAVETMP # Create an assembly listingvc_flags += -FAs -Fa$(subst /,\\,$(basename $@).src)endififeq "$(DEBUG)" "1" # debug/prod specificvc_defines += -D_DEBUGifdef WCE_CFLAGSDvc_flags += $(WCE_CFLAGSD)endifelsevc_defines += -DNDEBUGifdef WCE_CFLAGSPvc_flags += $(WCE_CFLAGSP)endifendififdef USE_STRICT_ANSI # default OFFvc_flags += -Zaelsevc_flags +=endififdef USE_RTTIvc_flags += -GRendififdef USE_HANDLINGvc_flags += $(call select_co,-GX,-EHsc)endififndef PDB_NONE # Supress PDB generationvc_flags += -Ziendifvc_flags += $(call select_co,-YX,--)vc_flags += -Fp$(subst /,\\,$(OBJDIR)/)vc_flags += -Fd$(subst /,\\,$(PDB))ifdef GEN_SBR_FILESvc_flags += -FR$(subst /,\\,$(basename $@).sbr)endifSHCFLAGS +=SHCXXFLAGS +=ifeq "\$(WCE_CC)" "cl"SHCFLAGS += -GDSHCXXFLAGS += -GDendif# Command##..cc = $(CC_PRE) $(WCE_CC)cc_init =cc_o_switch = $(subst /,\\,-Fo$@)cc_source = $(subst /,\\,$<)cc_flags = \$(strip $(vc_compile_flags)) \$(strip $(patsubst %,%,$(vc_flags))) \$(strip $(patsubst %,%,$(vc_defines))) \$(patsubst %,%,$(CFLAGS)) \$(patsubst %,-D%,$(cc_defines)) \$(call decodepath,-I","$(spacealt),$(INCLUDE_LIST))cc_term =define cc_pre@$(echo) '[$<] compiling..';endefdefine cc_postendefcc_filter := "$(notdir $(wildcard $(GBE_ROOT)/warnings.vcembedded))"ifeq ($(strip $(cc_filter)), "warnings.vcembedded")cc_filter = $(GBE_ROOT)/warnings.vcembeddedelsecc_filter =endififdef cc_filtercc_redirect_stderr = 1cc_error_filter = $(awk) -f $(cc_filter)endif################################################################################.. C/C++ dependencies# depend and depend.err#vc_depend += -D_MSC_VER=1200vc_depend += -DWIN32 -D_WIN32vc_depend += -D_M_CEEccdep = $(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)) \$(call decodepath,-I","$(spacealt),$(INCDIRS) $(cc_includes)) \$(call decodepath,-Y","$(spacealt),$(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)) \$(call decodepath,-I","$(spacealt),$(INCLUDE_LIST))lint_libpath = $(LIB)#.. C++ Compiler definitions#cxx = $(CC_PRE) $(WCE_CC)cxx_init =cxx_o_switch = $(subst /,\\,-Fo$@)cxx_source = $(subst /,\\,$<)cxx_flags = -TP \$(patsubst %,%,$(vc_flags)) \$(patsubst %,%,$(vc_defines)) \$(patsubst %,%,$(CXXFLAGS)) \$(patsubst %,-D%,$(cxx_defines)) \$(call decodepath,-I","$(spacealt),$(INCLUDE_LIST))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@$(cmdfile) -wkWeo$(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# Need to set up LIB to allow the librarian to locate libraries# This feature is needed when building DLL stub libraries##ar = $(XX_PRE)libar_init =ar_flags = -nologo $(WCE_LIBFLAGS)ifeq "$(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\\nifdef WCE_LDFLAGS # Platform specificvc_ldflags += $(patsubst %,%\\n,$(WCE_LDFLAGS))endififeq "$(DEBUG)" "1" # debug/prod specificifdef WCE_LDFLAGSDvc_ldflags += $(patsubst %,%\\n,$(WCE_LDFLAGSD))endifelseifdef WCE_LDFLAGSPvc_ldflags += $(patsubst %,%\\n,$(WCE_LDFLAGSP))endifendifvc_ldflags += \$(call decodepath,-libpath:\",\"\\n,$(LIB_LIST)) \$(subst $(spacealt),$(space),$(patsubst %,\"-%\"\\n,$(LDFLAGS)))#.. Shared library (dll)#shld = $(CC_PRE) linkshld_cmdfile = $(subst /,\\,$(basename $@).ld)shld_flags =shld_o_switch = @$(shld_cmdfile)shld_term =define shld_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@$(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@$(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@$(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 = $(call decodepath,,;,$(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#