Subversion Repositories DevTools

Rev

Rev 261 | 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
#
# Version   Who      Date        Description#
#           APY      26/04/04    Created
#
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/VCWCE.RUL,v $
# $Revision: 1.8 $ $Date: 2004/06/29 06:40:24 $ $State: Exp $
# $Author: ayoung $ $Locker:  $
#............................................................................#

###############################################################################
#..     Remove "undef" warnings
#
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 ignoreenv,$(OPTIONS))" ""   # Ignore WCE_LIB and WCE_INCLUDE vars
IGNOREENV       = 1
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

###############################################################################
#..     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

vc_defines      += -D__SOURCE__=\"$(notdir $<)\"

        # 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

ifndef PDB_NONE                 # Supress PDB generation
vc_flags        += -Zi
endif
vc_flags        += -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

        # Standard includes
        #
        #..
ifndef IGNOREENV
ifdef WCE_INCLUDE
vc_includes     =\
                $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(WCE_INCLUDE))))
endif
endif
ifndef vc_includes
vc_includes     =\
                $(sdkroot)/Include/$(WCE_TARGETCPU)\
                $(sdkroot)/MFC/Include\
                $(sdkroot)/ATL/Include
WCE_INCLUDE     =
export WCE_INCLUDE      # Zap env image
endif
ifdef MSVCDir
INCLUDE         =
export INCLUDE          # Dual installtion, clean env
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)) \
                $(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

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)) \
                $(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    = $(VC_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)) \
                $(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
        @$(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)))"
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)export LIB; LIB="$(VC_LIB)"; lib
ar_init         =
ar_flags        = -nologo $(WCE_LIBFLAGS)
ifeq "$(DEBUG)" "1"
ar_flags        += -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 $(OBJDIR) -t MSVC
armerge_o_switch= $(subst /,\\,$@) $(subst /,\\,$^)

define armerge_pre
        -echo [$@] Merging library ..; $(rm) -f $@
endef
armerge_post    =


###############################################################################
#..     Linker
#

        # Standard library paths
        #
        #..
ifndef IGNOREENV
ifdef WCE_LIB
vc_libs         =\
                $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(WCE_LIB))))
endif
endif
ifndef vc_libs
ifdef WCE_EMULATOR
vc_libs         =\
                $(sdkroot)/Lib/$(WCE_TARGETCPU)\
                $(sdkroot)/MFC/Lib/$(WCE_HOSTCPU)\
                $(sdkroot)/ATL/Lib/$(WCE_HOSTCPU)
else
vc_libs         =\
                $(sdkroot)/Lib/$(WCE_TARGETCPU)\
                $(sdkroot)/MFC/Lib/$(WCE_TARGETCPU)\
                $(sdkroot)/ATL/Lib/$(WCE_TARGETCPU)
endif
WCE_LIB         =
export WCE_LIB          # Zap env image
endif
ifdef MSVCDir
LIB             =
export LIB              # Dual installation, clean env
endif

ALL_LIBDIRS = $(LIBDIRS);$(vc_libs)
VC_LIB          =\
                $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,%;,$(subst /,\,$(ALL_LIBDIRS)))))

        # Standard flags
        #
        #..
vc_ldflags      = \
                -nologo\\n\
                -incremental:no\\n\
                -debug:full\\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      += \
                $(subst $(spacealt),$(space),$(patsubst %,-libpath:\"%\"\\n,$(subst /,\\\\,$(LIBDIRS))))\
                $(subst $(spacealt),$(space),$(patsubst %,-libpath:\"%\"\\n,$(subst /,\\\\,$(vc_libs))))\
                $(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
        @export VC_LIB; VC_LIB="$(VC_LIB)"; \
        $(cmdfile) -wkWeo$(shld_cmdfile) \
                "$(vc_ldflags) $($(notdir $(SHBASE))_shld)"; \
        echo [$@] Linking shared library ..;
endef

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

define SHLDDEPEND
        @export VC_LIB; VC_LIB="$(VC_LIB)"; \
        $(cmdfile) -wkWeo$(@) \
                "$($(notdir $(SHNAME))_shdp)";
endef

#..      Application
#

ld              = $(CC_PRE) link
ld_cmdfile      = $(subst /,\\,$(basename $@).ld)
ld_depfile      = $(subst /,\\,$(basename $@).dep)
ld_flags        =
ld_o_switch     = @$(ld_cmdfile)
ld_term         =

define ld_pre
        @export VC_LIB; VC_LIB="$(VC_LIB)"; \
        $(cmdfile) -wkWeo$(ld_cmdfile) \
                "$(vc_ldflags) $($(notdir $(basename $@))_ld)"; \
        echo [$@] Linking application ..
endef

ifndef LEAVETMP
define ld_post
        @$(rm) -f $(ld_cmdfile)
endef
else
define ld_post
endef
endif

define LDDEPEND
        @export VC_LIB; VC_LIB="$(VC_LIB)"; \
        $(cmdfile) -wkWeo$(ld_depfile) \
                "$($(notdir $(basename $@))_dp)";
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

#