Subversion Repositories DevTools

Rev

Rev 357 | Go to most recent revision | 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 OPTIONS

ifneq "$(findstring purify,$(OPTIONS))" ""      # Enable purify
else
ifneq "$(findstring purecov,$(OPTIONS))" ""     # Enable pure coverage
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 - 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_EMULATOR
vc_libs         +=\
                $(call encodepath,$(SDKROOT)/Lib/$(WCE_TARGETCPU))\
                $(call encodepath,$(SDKROOT)/MFC/Lib/$(WCE_HOSTCPU))\
                $(call encodepath,$(SDKROOT)/ATL/Lib/$(WCE_HOSTCPU))
else
vc_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_DEFINES
vc_defines      += $(WCE_DEFINES)
endif

vc_defines      += -D "UNICODE" -D "_UNICODE"

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
        #   -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        += -c
vc_flags        += -nologo
ifdef USE_WALL
vc_flags        += -W4
else
vc_flags        += -W3
endif

ifdef WCE_CFLAGS
vc_flags        += $(WCE_CFLAGS)
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_defines      += -DDEBUG
else
vc_flags        +=
endif

ifdef LEAVETMP                  # Create an assembly listing
vc_flags       += -FAs  -Fa$(subst /,\\,$(basename $@).src)
endif

ifeq "$(DEBUG)" "1"                             # debug/prod specific
vc_defines      += -D_DEBUG
ifdef WCE_CFLAGSD
vc_flags        += $(WCE_CFLAGSD)
endif
else
vc_defines      += -DNDEBUG
ifdef WCE_CFLAGSP
vc_flags        += $(WCE_CFLAGSP)
endif
endif

ifdef USE_STRICT_ANSI                           # default OFF
vc_flags        += -Za
else
vc_flags        +=
endif

ifdef USE_RTTI
vc_flags        += -GR
endif

ifdef USE_HANDLING
vc_flags        += $(call select_co,-GX,-EHsc)
endif

ifndef PDB_NONE                 # Supress PDB generation
vc_flags        += -Zi
endif
vc_flags        += $(call select_co,-YX,--)
vc_flags        += -Fp$(subst /,\\,$(OBJDIR)/)
vc_flags        += -Fd$(subst /,\\,$(PDB))

ifdef GEN_SBR_FILES
vc_flags        += -FR$(subst /,\\,$(basename $@).sbr)
endif

SHCFLAGS        +=
SHCXXFLAGS      +=
ifeq "\$(WCE_CC)" "cl"
SHCFLAGS        += -GD
SHCXXFLAGS      += -GD
endif

# 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..';
endef

define cc_post
endef

cc_filter       := "$(notdir $(wildcard $(GBE_ROOT)/warnings.vcembedded))"
ifeq ($(strip $(cc_filter)), "warnings.vcembedded")
cc_filter       = $(GBE_ROOT)/warnings.vcembedded
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
#
vc_depend       += -D_MSC_VER=1200
vc_depend       += -DWIN32 -D_WIN32
vc_depend       += -D_M_CEE

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)) \
                $(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..';
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
        @$(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))
                
endef

ifndef LEAVETMP
define as_post
        @$(rm) -f $(as_cmdfile)
endef
else
define as_post
endef
endif


###############################################################################
#..     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)lib
ar_init         =
ar_flags        = -nologo $(WCE_LIBFLAGS)
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

ifdef WCE_LDFLAGS                               # Platform specific
vc_ldflags      += $(patsubst %,%\\n,$(WCE_LDFLAGS))              
endif

ifeq "$(DEBUG)" "1"                             # debug/prod specific                         
ifdef WCE_LDFLAGSD
vc_ldflags      += $(patsubst %,%\\n,$(WCE_LDFLAGSD))
endif
else
ifdef WCE_LDFLAGSP
vc_ldflags      += $(patsubst %,%\\n,$(WCE_LDFLAGSP))
endif
endif

vc_ldflags      += \
                $(call decodepath,-libpath:\",\"\\n,$(LIB_LIST)) \
                $(patsubst %,-%\\n,$(LDFLAGS))


#..     Shared library (dll)
#

shld            = $(CC_PRE) link
shld_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))
        
endef

ifndef LEAVETMP
define shld_post
        @$(rm) -f $(shld_cmdfile)
endef
else
define shld_post
endef
endif

define SHLDDEPEND
        @$(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
        @$(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
        @$(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

#