#/*++
#  
#  Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
#  This program and the accompanying materials                          
#  are licensed and made available under the terms and conditions of the BSD License         
#  which accompanies this distribution.  The full text of the license may be found at        
#  http://opensource.org/licenses/bsd-license.php                                            
#                                                                                            
#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
#  
#  Module Name:
#  
#    CommonTools.env 
#  
#  Abstract:
#  
#    This file should not need to be customized. Customizations should
#    be done in LocalTools.env if at all possible.
#
#    This file can be included by other makefiles. 
#   
#    It defines variables used by the different toolchains. It first includes
#    the user-customized LocalTools.env, and then uses those defines to 
#    define other variables.
#
#    It basically has sections for different toolchains which define variables
#    used to build.
#   
#--*/

#
# Everything depends on EDK_SOURCE. Make sure it's defined
#
!IFNDEF EDK_SOURCE
!ERROR EDK_SOURCE environmental variable not set 
!ENDIF

#
# Tools depend on BUILD_DIR. Make sure it's defined
#
!IFNDEF BUILD_DIR
!ERROR BUILD_DIR environmental variable not set.  Should be set in PlatformTools.env
!ENDIF

#
# This include file gets customized by the developer. Get the customizations.
#
!INCLUDE $(EDK_SOURCE)\Sample\LocalTools.env

################################################################################
#
# Define paths for EFI build tools
#
################################################################################
!IFNDEF EDK_TOOLS_PATH
EDK_TOOLS_BIN     = $(EDK_SOURCE)\Tools\Bin
!ELSE
EDK_TOOLS_BIN     = $(EDK_TOOLS_PATH)\Bin
!ENDIF
EDK_TOOLS_DIR     = $(EDK_SOURCE)\Sample\Tools
EDK_TOOLS_SOURCE  = $(EDK_TOOLS_DIR)\Source
EDK_TOOLS_COMMON  = $(EDK_TOOLS_DIR)\Source\Common
EDK_TOOLS_OUTPUT  = $(BUILD_DIR)\Tools
PCCTS_DIR         = $(EDK_SOURCE)\Other\Maintained\Tools\Pccts

#
# This include file gets some version info.
#
!INCLUDE $(EDK_SOURCE)\Sample\Version.env

#
# Macros to define the build tools
#
ANTLR           = $(PCCTS_DIR)\bin\antlr
DLG             = $(PCCTS_DIR)\bin\dlg
EXE2BIN         = $(EDK_TOOLS_OUTPUT)\Strip
FWIMAGE         = $(EDK_TOOLS_OUTPUT)\FwImage
GENDEPEX        = $(EDK_TOOLS_OUTPUT)\GenDepex
GENFDIMAGE      = $(EDK_TOOLS_OUTPUT)\GenFdImage
GENFFSFILE      = $(EDK_TOOLS_OUTPUT)\GenFfsFile
GENFVIMAGE      = $(EDK_TOOLS_OUTPUT)\GenFvImage
GENSECTION      = $(EDK_TOOLS_OUTPUT)\GenSection
GENTEIMAGE      = $(EDK_TOOLS_OUTPUT)\GenTEImage
GUIDCHK         = $(EDK_TOOLS_OUTPUT)\GuidChk
HIIPACK         = $(EDK_TOOLS_OUTPUT)\HiiPack
MAKEDEPS        = $(EDK_TOOLS_OUTPUT)\MakeDeps
PROCESSDSC      = $(EDK_TOOLS_OUTPUT)\ProcessDsc
STRGATHER       = $(EDK_TOOLS_OUTPUT)\StrGather
SETSTAMP        = $(EDK_TOOLS_OUTPUT)\SetStamp
VFRCOMPILE      = $(EDK_TOOLS_OUTPUT)\VfrCompile
GENAPRIORI      = $(EDK_TOOLS_OUTPUT)\GenAprioriFile
MODIFYINF       = $(EDK_TOOLS_OUTPUT)\ModifyInf

MAKE            = nmake -nologo

#
# Everything else requires that TOOLCHAIN be defined. This should be defined
# by the calling makefile. 
#
!IFNDEF TOOLCHAIN
!ERROR TOOLCHAIN not defined for $(EDK_SOURCE)\Sample\CommonTools.env
!ENDIF

###############################################################################
#
# Specify the path and macros for ASL tools
#
###############################################################################
!IF "$(EFI_ASL_LOCAL)" == "YES"
ASL               = $(ASLPATH)\Iasl
!ELSE
ASL               = $(EDK_TOOLS_BIN)\Iasl
!ENDIF

ASL_FLAGS         =
C_FLAGS_ASL       = /nologo /EP /C

###############################################################################
#
# Specify the path and macros for IA32 tools
#
###############################################################################

!IF "$(TOOLCHAIN)" == "TOOLCHAIN_IA32"

#
# Globally relevant flags. Options not appropriate for all builds may be 
# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or
# in the platform specific macros (xxx_PROJ_FLAGS)
#
C_STD_INCLUDE       = /X

!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"

!IF "$(USE_VC8)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /GS- /D USE_VC8 /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /GX- /GR- /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ENDIF
ASM_STD_FLAGS       = /nologo /Fl$*.lst $(INC)

!ELSE

!IF "$(USE_VC8)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /GS- /D USE_VC8 /c /Fo$@ $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /GX- /GR- /Gy /c /Fo$@ $(INC)
!ENDIF
ASM_STD_FLAGS       = /nologo $(INC) 

!ENDIF

LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 $(BUILD_DIR)\IA32\CompilerStub.lib
LIB_STD_FLAGS       = /nologo 

#
# Build type specific flags.  Globally relevant flags belong in the standard 
# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the
# PlatformTools.env file in macros named xxx_PROJ_FLAGS.
#
C_ARCH_FLAGS          = /D EFI32
ASM_ARCH_FLAGS        = /W3 /WX /c /coff /Fo$@ /DEFI32
LINK_ARCH_FLAGS       = /MACHINE:I386
LIB_ARCH_FLAGS        =

ASM16_FLAGS           = /nologo /c /omf /Fo$@
ASMLINK16_FLAGS       =

#
# Build tools
#
CC                = cl
LINK              = link
LIB               = lib
#
# When using VS ml to compile 16bit code, please add /omf compiler option 
#
ASM               = ml

!IF "$(EFI_ASSEMBLER_NAME)" == ""
ASM16             = $(MASMPATH)\bin\ml
ASMLINK16         = $(MASMPATH)\binr\link
ASMLINK           = $(MASMPATH)\binr\link
!ELSE
ASM16             = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\bin\ml
ASMLINK16         = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
ASMLINK           = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
!ENDIF

BSCMAKE           = bscmake
RC                = rc

!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
ASM_ARCH_FLAGS      = $(ASM_ARCH_FLAGS) /Zi /DDEBUG
C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj
LINK_STD_FLAGS      = $(LINK_STD_FLAGS) /DEBUG
!ENDIF

# END OF TOOLCHAIN_IA32
###############################################################################

###############################################################################
#
# Specify the path and macros for the X64 (also called x86-64, EM64T, AMD64) tools
#
###############################################################################

!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_X64"

#
# Globally relevant flags. Options not appropriate for all builds may be 
# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or
# in the platform specific macros (xxx_PROJ_FLAGS)
#
C_STD_INCLUDE       = /X
!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /c /GS- /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) 
ASM_STD_FLAGS       = /nologo /Fl$*.lst $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /c /GS- /Fo$@ $(INC) 
ASM_STD_FLAGS       = /nologo $(INC)
!ENDIF
LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 $(BUILD_DIR)\X64\CompilerStub.lib
LIB_STD_FLAGS       = /nologo 

#
# Build type specific flags.  Globally relevant flags belong in the standard 
# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the
# PlatformTools.env file in macros named xxx_PROJ_FLAGS.
#
C_ARCH_FLAGS          = /D EFIX64
ASM_ARCH_FLAGS        = /W3 /WX /c /Fo$@ /DEFIX64
LINK_ARCH_FLAGS       = /Machine:AMD64
LIB_ARCH_FLAGS        =

ASM16_FLAGS           = /nologo /c /omf /Fo$@
ASMLINK16_FLAGS       =

#
# Build tools
#
!IF "$(EFI_COMPILER_X64_NAME)" == ""
!IF "$(USE_VC8_X64)" == "YES"
#
# Use VC8 as X64 compiler
#
CC                = "$(VC8_X64_PATH)\cl"
LINK              = "$(VC8_X64_PATH)\link"
LIB               = "$(VC8_X64_PATH)\lib"
ASM               = "$(VC8_X64_PATH)\ml64"
!ELSE
#
# Use DDK as X64 compiler
#
CC                = $(WIN_DDK_X64_PATH)\cl
LINK              = $(WIN_DDK_X64_PATH)\link
LIB               = $(WIN_DDK_X64_PATH)\lib
ASM               = $(WIN_DDK_X64_PATH)\ml64
!ENDIF
!ELSE
CC                = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\cl
LINK              = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\link
LIB               = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\lib
ASM               = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\ml64
!ENDIF

!IF "$(EFI_ASSEMBLER_NAME)" == ""
ASM16             = $(MASMPATH)\bin\ml
ASMLINK16         = $(MASMPATH)\binr\link
ASMLINK           = $(MASMPATH)\binr\link
!ELSE
ASM16             = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\bin\ml
ASMLINK16         = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
ASMLINK           = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
!ENDIF

BSCMAKE           = bscmake
RC                = rc

!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
ASM_ARCH_FLAGS      = $(ASM_ARCH_FLAGS) /Zi /DDEBUG
C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj
LINK_STD_FLAGS      = $(LINK_STD_FLAGS) /DEBUG
!ENDIF

# END OF TOOLCHAIN_X64
###############################################################################

###############################################################################
#
# Specify the path and macros for the IPF tools
#
###############################################################################

!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_IPF"

#
# Globally relevant flags. Options not appropriate for all builds may be 
# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or
# in the platform specific macros (xxx_PROJ_FLAGS)
#
C_STD_INCLUDE       = /X

!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"

!IF "$(USE_VC8_IPF)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /GS- /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ELSE
!IF "$(USE_NEWDDK)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /GS- /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /GX- /GR- /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ENDIF
!ENDIF

!ELSE

!IF "$(USE_VC8_IPF)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /GS- /c /Fo$@ $(INC)
!ELSE
!IF "$(USE_NEWDDK)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHs-c- /GR- /Gy /GS- /c /Fo$@ $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /GX- /GR- /Gy /c /Fo$@ $(INC)
!ENDIF
!ENDIF

!ENDIF

ASM_STD_FLAGS       = $(INC) 
LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108
LIB_STD_FLAGS       = /nologo 

#
# Build type specific flags.  Globally relevant flags belong in the standard 
# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the
# PlatformTools.env file in macros named xxx_PROJ_FLAGS.
#
C_ARCH_FLAGS          = /D EFI64
ASM_ARCH_FLAGS        = -N us -X explicit -M ilp64 -N so -W4 -o $@
LINK_ARCH_FLAGS       = /MACHINE:IA64
LIB_ARCH_FLAGS        =

#
# This is used for preprocessing IPF Assembly files
#
C_FLAGS_PRO       = /nologo /EP /C $(C_STD_FLAGS) $(C_ARCH_FLAGS) $(C_PROJ_FLAGS) $(C_STD_INCLUDE)

!IF "$(EFI_DEBUG)" == "YES"
ASM_ARCH_FLAGS   = $(ASM_ARCH_FLAGS) -d debug
!ENDIF

#
# Build tools
#
!IF "$(EFI_COMPILER_NAME)" == ""
!IF "$(USE_VC8_IPF)" == "YES"
CC                = "$(VC8_IPF_PATH)\cl"
LINK              = "$(VC8_IPF_PATH)\link"
LIB               = "$(VC8_IPF_PATH)\lib"
!ELSE
CC                = $(EFI_IA64TOOLPATH)\cl
LINK              = $(EFI_IA64TOOLPATH)\link
LIB               = $(EFI_IA64TOOLPATH)\lib
!ENDIF
!ELSE
CC                = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\cl
LINK              = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\link
LIB               = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\lib
!ENDIF

!IF "$(EFI_ASSEMBLER_NAME)" == ""
!IF "$(USE_VC8_IPF)" == "YES"
ASM               = "$(VC8_IPF_PATH)\ias"
ASMLINK           = "$(VC8_IPF_PATH)\link"
!ELSE
ASM               = $(EFI_IA64ASMPATH)\ias
ASMLINK           = $(EFI_IA64ASMPATH)\link
!ENDIF
!ELSE
ASM               = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\ias
ASMLINK           = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\link
!ENDIF

BSCMAKE           = bscmake
RC                = rc

!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj
LINK_STD_FLAGS      = $(LINK_STD_FLAGS) /DEBUG
!ENDIF

# END TOOLCHAIN_IPF
###############################################################################

###############################################################################
#
# Define toolchain for building the EFI tools on an IA32 system.
#
###############################################################################

!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_MSVC"

#
# Globally relevant flags. Options not appropriate for all builds may be 
# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or
# in the platform specific macros (xxx_PROJ_FLAGS)
#
!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"

!IF "$(USE_VC8)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /D _CRT_SECURE_NO_DEPRECATE /D USE_VC8 /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)
!ENDIF
ASM_STD_FLAGS       = /nologo /Fl$*.lst $(INC)

!ELSE

!IF "$(USE_VC8)" == "YES"
C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /D _CRT_SECURE_NO_DEPRECATE /D USE_VC8 /c /Fo$@ $(INC)
!ELSE
C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC)
!ENDIF
ASM_STD_FLAGS       = /nologo $(INC)

!ENDIF

LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF
LIB_STD_FLAGS       = /nologo 

MSVS_LINK_LIBPATHS = 

#
# Build type specific flags.  Globally relevant flags belong in the standard 
# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the
# PlatformTools.env file in macros named xxx_PROJ_FLAGS.
#

#
# Add a define to skip inclusion of Microsoft include file rpcasync.h, which
# results in a compile warning at W4.
#
C_ARCH_FLAGS          = /Od /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D __RPCASYNC_H__ 
ASM_ARCH_FLAGS        =
LINK_ARCH_FLAGS       = /MACHINE:i386
LIB_ARCH_FLAGS        =

#
# Always turn on debug for the build tools so that we can debug problems 
# quickly.
# NOTE: Ideally all the tools makefiles should be updated to use LINK_FLAGS_EXE
#       instead of L_FLAGS for linking. When this happens we can get rid of
#       the L_FLAGS definition here.
#

#!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
C_STD_FLAGS       = $(C_STD_FLAGS) /Zi /Gm /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj
LINK_ARCH_FLAGS   = $(LINK_ARCH_FLAGS) /DEBUG
L_FLAGS           = $(L_FLAGS) /DEBUG
#!ENDIF

#
# Clear any project flags when building tools
#
C_PROJ_FLAGS          =
ASM_PROJ_FLAGS        =
LINK_PROJ_FLAGS       =
LIB_PROJ_FLAGS        =
EBC_C_PROJ_FLAGS      =
EBC_LINK_PROJ_FLAGS   =
EBC_LIB_PROJ_FLAGS    =

#
# Build tools
#
CC                = cl
LINK              = link
BSCMAKE           = bscmake
ASM               = ml
ASMLINK           = link
#
# Use a different macro name for tools build to avoid conflict with environment
# variable LIB
#
LIB_EXE           = lib

INC = -I $(EDK_SOURCE)\Foundation                          \
      -I $(EDK_SOURCE)\Foundation\Efi                      \
      -I $(EDK_SOURCE)\Foundation\Framework                \
      -I $(EDK_SOURCE)\Sample\Platform\Nt32                \
      -I $(EDK_SOURCE)\Foundation\Core\Dxe                 \
      -I $(EDK_SOURCE)\Foundation\Include                  \
      -I $(EDK_SOURCE)\Foundation\Efi\Include              \
      -I $(EDK_SOURCE)\Foundation\Framework\Include        \
      -I $(EDK_SOURCE)\Foundation\Include\IndustryStandard \
      -I $(EDK_SOURCE)\Foundation\Include\Ia32             \
      -I $(EDK_SOURCE)\Foundation\Include\Pei              \
      -I $(EDK_SOURCE)\Foundation\Library\Pei\Include      \
      -I $(EDK_SOURCE)\Sample\Include                      \
      -I "$(EDK_TOOLS_COMMON)"

# END TOOLCHAIN_MSVC
###############################################################################

###############################################################################
#
# Specify the path and macros for the EBC tools
#
###############################################################################

!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_EBC"

!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"
EBC_C_STD_FLAGS     = /nologo /W3 /WX /c /Fa$* /FAsc /Fo$@ $(INC) /X
!ELSE
EBC_C_STD_FLAGS     = /nologo /W3 /WX /c /Fo$@ $(INC) /X
!ENDIF

#
# All EBC entry point functions must be called EfiMain. Redefine it.
#
!IF "$(IMAGE_ENTRY_POINT)" == ""
IMAGE_ENTRY_POINT   = EfiMain
!ENDIF
EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /D $(IMAGE_ENTRY_POINT)=EfiMain
EBC_LINK_STD_FLAGS  = /nologo /MACHINE:EBC /BASE:0 /OPT:REF /NODEFAULTLIB
EBC_LIB_STD_FLAGS   = /nologo /MACHINE:EBC 

#
# EBC tools path should be defined in LocalTools.env.
#
EBC_CC            = $(EBC_TOOLS_PATH)\Bin\Iec
EBC_LINK          = $(EBC_TOOLS_PATH)\Bin\Link
EBC_LIB           = $(EBC_TOOLS_PATH)\Bin\Link /lib

RC                = rc

!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /Zi
EBC_LINK_STD_FLAGS  = $(EBC_LINK_STD_FLAGS) /DEBUG
!ENDIF

#  END TOOLCHAIN_EBC

###############################################################################
#
# Let the caller define a NULL toolchain if they don't care. This way you can
# pick up at least some defines.
#
###############################################################################

!ELSEIF "$(TOOLCHAIN)" == ""

###############################################################################
#
# You get this if the calling makefile did not define TOOLCHAIN_xxx before
# including this file.
#
###############################################################################

!ELSE
!ERROR Unknown toolchain $(TOOLCHAIN) defined for $(EDK_SOURCE)\Sample\CommonTools.env use
!ENDIF


###############################################################################
#
# These are standard settings for all tool chains
#
###############################################################################

#
# These are standard build options
#
VERSION_FLAGS       = /D EFI_SPECIFICATION_VERSION=$(EFI_SPECIFICATION_VERSION) \
                      /D PI_SPECIFICATION_VERSION=$(PI_SPECIFICATION_VERSION) \
                      /D TIANO_RELEASE_VERSION=$(TIANO_RELEASE_VERSION)
C_STD_FLAGS         = $(C_STD_FLAGS) $(VERSION_FLAGS)
EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) $(VERSION_FLAGS)
C_FLAGS_ASL         = $(C_FLAGS_ASL) $(VERSION_FLAGS)
VFRCOMPILE_FLAGS    = $(VFRCOMPILE_FLAGS) -ppflag "$(VERSION_FLAGS)"
!IF "$(TOOLCHAIN)" != "TOOLCHAIN_IPF"
ASM_STD_FLAGS       = $(ASM_STD_FLAGS) $(VERSION_FLAGS)
!ENDIF

!IF "$(TOOLCHAIN)" != "TOOLCHAIN_MSVC"
BUILD_STRING_FLAGS       = /D EFI_BUILD_VERSION="L\"$(EDK_BUILD_VERSION)\"" /D EFI_FIRMWARE_VENDOR="L\"TianoCore.org\""
!ELSE
BUILD_STRING_FLAGS       = /D UTILITY_BUILD="\"$(EDK_BUILD_VERSION)\"" /D UTILITY_VENDOR="\"TianoCore.org\""
!ENDIF

C_STD_FLAGS         = $(C_STD_FLAGS) $(BUILD_STRING_FLAGS)
EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) $(BUILD_STRING_FLAGS)

!IF "$(EFI_DEBUG)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_DEBUG
!ENDIF

!IF "$(EFI_DEBUG_CLEAR_MEMORY)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_DEBUG_CLEAR_MEMORY
!ENDIF

!IF "$(EFI_PEI_PERFORMANCE)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_PEI_PERFORMANCE /D EFI_DXE_PERFORMANCE
!ENDIF

!IF "$(EFI_ADDTIONAL_DRIVERS)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_ADDTIONAL_DRIVERS
!ENDIF

!IF "$(EFI_USE_CUSTOM_COMPRESS)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_USE_CUSTOM_COMPRESS
!ENDIF

!IF "$(EFI_UNLOCK_FWH)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_UNLOCK_FWH
!ENDIF

!IF "$(EFI_DXE_PERFORMANCE)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_DXE_PERFORMANCE
!ENDIF

!IF "$(EFI_S3_RESUME)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_S3_RESUME
!ENDIF

!IF "$(EFI_NO_CSM_SUPPORT)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_NO_CSM_SUPPORT
!ENDIF

!IF "$(EFI_SIZE_REDUCTION_APPLIED)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_SIZE_REDUCTION_APPLIED
!ENDIF

!IF "$(EFI_PEI_REPORT_STATUS_CODE)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_PEI_REPORT_STATUS_CODE_ON
!ENDIF

!IF "$(SIZE_REDUCTION_ISA_COMBINED)" == "YES"
FEATURE_FLAGS   = $(FEATURE_FLAGS) /D SIZE_REDUCTION_ISA_COMBINED
!ENDIF

C_STD_FLAGS       = $(C_STD_FLAGS) $(FEATURE_FLAGS)
EBC_C_STD_FLAGS   = $(EBC_C_STD_FLAGS) $(FEATURE_FLAGS)
C_FLAGS_ASL       = $(C_FLAGS_ASL) $(FEATURE_FLAGS)
VFRCOMPILE_FLAGS  = $(VFRCOMPILE_FLAGS) -ppflag "$(FEATURE_FLAGS)"
!IF "$(TOOLCHAIN)" != "TOOLCHAIN_IPF"
ASM_STD_FLAGS     = $(ASM_STD_FLAGS) $(FEATURE_FLAGS)
!ENDIF

#
# This is used for preprocessing dependency files
#
C_FLAGS_DPX       = /nologo /EP $(INC) $(VERSION_FLAGS) $(FEATURE_FLAGS)

###############################################################################

###############################################################################
#
# Collect final build flags for components.  These flags are used to build
# any standard component and some non-standard components.
#
###############################################################################
C_FLAGS           = $(C_STD_FLAGS) $(C_ARCH_FLAGS) $(C_PROJ_FLAGS) $(C_STD_INCLUDE)
ASM_FLAGS         = $(ASM_STD_FLAGS) $(ASM_ARCH_FLAGS) $(ASM_PROJ_FLAGS)
LINK_FLAGS_DLL    = $(LINK_STD_FLAGS) $(LINK_ARCH_FLAGS) $(LINK_PROJ_FLAGS) /DLL 
LINK_FLAGS_EXE    = $(LINK_STD_FLAGS) $(LINK_ARCH_FLAGS) $(LINK_PROJ_FLAGS) 
LIB_FLAGS         = $(LIB_STD_FLAGS) $(LIB_ARCH_FLAGS) $(LIB_PROJ_FLAGS)
EBC_C_FLAGS       = $(EBC_C_STD_FLAGS) $(EBC_C_ARCH_FLAGS) $(EBC_C_PROJ_FLAGS)
EBC_LINK_FLAGS    = $(EBC_LINK_STD_FLAGS) $(EBC_LINK_ARCH_FLAGS) $(EBC_LINK_PROJ_FLAGS)
EBC_LIB_FLAGS     = $(EBC_LIB_STD_FLAGS) $(EBC_LIB_ARCH_FLAGS) $(EBC_LIB_PROJ_FLAGS)

###############################################################################
#
# define X64 denpendant driver files
#
###############################################################################
!IF "$(EFI_BUILD_TARGET_X64)" == "YES"
BUILD_TARGET_PROCESSOR = X64
DXE_IPL                = DxeIplX64
!ELSE
BUILD_TARGET_PROCESSOR = IA32
DXE_IPL                = DxeIpl
!ENDIF                                                                                        
###############################################################################
#
# define EFI specification denpendant driver files
#
###############################################################################
!IF "$(UEFI_MODE)" == "YES"
UEFI_PREFIX = Uefi
ATAPI_PASS_THRU_INF = Sample\Bus\Pci\AtapiExtPassThru\Dxe\AtapiExtPassThru.inf
!IF "$(CAPSULE_INF)" == ""
CAPSULE_INF = Sample\Universal\Capsule\RuntimeDxe\Capsule.inf 
!ENDIF
DEVPATH_INF = Sample\Universal\DevicePath\Dxe\DevicePath.inf
!ELSE
UEFI_PREFIX =
CAPSULE_INF =
DEVPATH_INF =
ATAPI_PASS_THRU_INF = Sample\Bus\Pci\AtapiPassThru\Dxe\AtapiPassThru.inf
!ENDIF
###############################################################################
#
# define PIWG specification denpendant driver files
#
###############################################################################
!IF "$(PI_MODE)" == "YES"
PI_PREFIX = Pi
!ELSE
PI_PREFIX =
!ENDIF
###############################################################################
#
# define customized compress makefile
#
###############################################################################
CUSTOMIZEDCOMPRESS_MAKEFILE   = $(EDK_TOOLS_SOURCE)\CustomizedCompress\Makefile 
COMPRESS_METHOD               = Dummy                                                 
###############################################################################         
#                                                                                       
# define EFI_BINARY default path
#                                                                                       
###############################################################################  
!IFNDEF EFI_BINARY
EFI_BINARY=$(EDK_SOURCE)\Bin
!ENDIF

EFI_PLATFORM_BIN=$(EFI_BINARY)\$(PROJECT_NAME)$(BUILD_TARGET_DIRECTORY)