#! make -f
#----------------------------------------------------------------------------
#  Project:  NitroSDK - buildtools - compiler dependant settings for CW
#  File:     commondefs.cctype.CW
#
#  Copyright 2003-2004 Nintendo.  All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
# Company Ltd., and are protected by Federal copyright law.  They may
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Log: commondefs.cctype.CW,v $
# Revision 1.96  2004/10/05 02:29:54  yasu
# Add LMACRO_FLAGS to MACRO_FLAGS
#
# Revision 1.95  2004/09/24 08:49:02  takano_makoto
# Turn OFF SDK_CW_WARNOFF_SAFESTRB when it is TS.
#
# Revision 1.94  2004/09/04 09:30:36  yosiokat
# Added SDK_SMALL_BUILD.
#
# Revision 1.93  2004/08/27 05:23:26  yasu
# Set default codewarrior version to 0.6.1
#
# Revision 1.92  2004/08/10 00:13:46  yasu
# Support CodeWarrior 0.6.1
#
# Revision 1.91  2004/08/09 11:30:41  yasu
# Don't set default value of NITRO_TS_VERSION on commondefs to support CW
#
# Revision 1.90  2004/07/31 02:57:38  yasu
# support NITRO_TS_VERSION
#
# Revision 1.89  2004/07/27 09:56:07  yasu
# Stop passing SDK_VERSION_WL value thru make option.
#
# Revision 1.88  2004/07/27 06:07:30  yasu
# Let default CW version number back to 0.5
#
# Revision 1.87  2004/07/13 12:33:02  yasu
# Clean up CW_LIB settings
#
# Revision 1.86  2004/07/10 10:14:08  yasu
# Arrange some macros for Marionea Library
#
# Revision 1.85  2004/07/10 04:18:26  yasu
# Update default CodeWarrior path to V0.6
#
# Revision 1.84  2004/06/28 10:50:49  yasu
# Set "SDK_CW_WA_LIBCXX" as workaround flag
#
# Revision 1.83  2004/06/03 09:10:05  yasu
# Add NITRO_NO_OPT_G to switch to enable -g option for CC/LD debug info
#
# Revision 1.82  2004/06/03 01:11:38  yasu
# Change ARM7's optimizing policy from 'speed' to 'space'
#
# Revision 1.81  2004/05/21 05:11:19  yasu
# Invalidate CW_WA_** for CW 0.5
#
# Revision 1.80  2004/05/20 09:49:25  yasu
# change default CW version to 0.5
#
# Revision 1.79  2004/05/19 00:49:30  yasu
# move workaround TEG vblank problems to commondefs.cctype.CW
# add macro switch for anti-thread policy
#
# Revision 1.78  2004/05/18 02:11:38  yasu
# fix SDK_PROFILE_XXX macro
#
# Revision 1.77  2004/05/18 01:51:15  yasu
# add SDK_PROFILE_XXX macro to switch profiling method
#
# Revision 1.76  2004/05/11 10:20:08  yasu
# combine with 'ferret' as ARM7 component
#
# Revision 1.75  2004/05/11 10:13:34  yasu
# clean up comments
#
# Revision 1.74  2004/05/01 10:04:11  yada
# temporary fix for CW0.5
#
# Revision 1.73  2004/04/22 06:56:33  yasu
# workaround for CW blxeq/blxne problem
#
# Revision 1.72  2004/04/19 04:29:12  yasu
# add -Cpp_exceptions off
#
# Revision 1.71  2004/04/14 11:24:37  yasu
# add NITRO_CONSERVATIVE to degrade optimize level
#
# Revision 1.70  2004/04/14 09:39:17  yasu
# support -profile option
#
# Revision 1.69  2004/04/09 07:06:25  yasu
# fix default ARM7 component
#
# Revision 1.68  2004/04/03 08:43:35  yasu
# with MINGW, support detect CW versions
#
# Revision 1.67  2004/04/03 08:01:43  yasu
# auto-detect CW verinfo and switch strb parameters
#
# Revision 1.65  2004/03/26 13:09:09  yasu
# small fix
#
# Revision 1.64  2004/03/26 08:39:25  yasu
# support NITROSDK_LANG
#
# Revision 1.63  2004/03/26 01:44:15  yasu
# define SDK_CW_WA_OPT4 for finalrom
#
# Revision 1.62  2004/03/16 10:11:30  yasu
# set default CWFOLDER to NITRO ver 0.3
#
# Revision 1.61  2004/03/03 01:09:44  yasu
# add workaround flag SDK_CW_WA_CONSTPOOLS for 'ConstantPools.c'line: 346
#
# Revision 1.60  2004/02/25 09:14:03  yasu
# add cw stubs
#
# Revision 1.59  2004/02/25 06:21:01  nishida_kenji
# Use MSL_C_ARM_i_LE_strb.a instead of MSL_C_Thumb_LE.a.
#
# Revision 1.58  2004/02/23 07:00:51  yasu
# append SDK_CW_WA_OPT4
#
# Revision 1.57  2004/02/23 05:01:38  yasu
# axf->nef
#
# Revision 1.56  2004/02/18 01:00:56  yasu
# add switch SDK_CW_WARNOFF_SAFESTRB
#
# Revision 1.55  2004/02/16 01:24:24  yasu
# support file dependancies
#
# Revision 1.54  2004/02/14 07:33:34  yasu
# move components directory
#
# Revision 1.53  2004/02/14 06:38:08  yasu
# workaround for "components"
#
# Revision 1.52  2004/02/13 10:15:38  yasu
# support ARM7 build setting with elftobin
#
# Revision 1.51  2004/02/09 11:11:06  yasu
# change CC option to -avoid_strb all,noerr
#
# Revision 1.50  2004/02/09 01:26:25  yasu
# delete -once option
#
# Revision 1.49  2004/02/05 07:43:17  yasu
# fix definiation of CWFOLDER_IRIS
#
# Revision 1.48  2004/02/05 07:09:01  yasu
# change SDK prefix iris -> nitro
#
# Revision 1.47  2004/02/03 06:38:47  yasu
# add SDK_AUTOTEST
#
# Revision 1.46  2004/01/26 10:53:58  yasu
# delete SDK_CWBUG_VSNPRINTF workaround
#
# Revision 1.45  2004/01/08 01:39:34  yasu
# Add workaround (as comments) codewarrior environment value
#
# Revision 1.44  2003/12/25 12:32:43  yasu
# Clean up comments
#
# Revision 1.43  2003/12/24 09:24:35  yada
# Set -proc arm946e, even for BB compile (because of  nightyly build error).
#
# Revision 1.42  2003/12/22 04:43:46  yasu
# Support CW_NITRO 0.2 Hotfix
#
# Revision 1.41  2003/12/17 09:22:48  yasu
# Added SDK_CWBUG_PROC_OPT
#
# Revision 1.40  2003/12/16 10:44:32  yasu
# Revised SDK_CWBUGS_VSNPRINTF
#
# Revision 1.39  2003/12/16 05:25:12  yasu
# ARM7 version option settings
#
# Revision 1.38  2003/12/12 07:12:55  yasu
# Removed -avoid_strb all,err from ARM7 compile options
#
# Revision 1.37  2003/12/12 05:03:48  yasu
# Added a workaround to use until version is released that supports vsprintf  strb
#
# Revision 1.36  2003/12/10 05:12:48  yasu
# Changed so that will use xxxx/src.c format as source file specification.
# Added Makefile.srcs
# Revised to that when IS_NITRO_DIR is defined, ISDebugger library is linked
#
# Revision 1.35  2003/12/08 09:26:43  yasu
# Added -once option
#
# Revision 1.34  2003/12/02 04:54:02  yasu
# Support for \ as path delimiter for NITROSDK_ROOT
#
# Revision 1.33  2003/12/02 02:40:23  yasu
# Added IS-NITRO-EMULATOR library definitions
#
# Revision 1.32  2003/12/01 23:50:52  yasu
# Revised LM_LICENSE_FILE
#
# Revision 1.31  2003/12/01 11:30:55  yasu
# Changed ROM create tools: objcopy -> elftobin
#
# Revision 1.30  2003/12/01 04:28:03  yasu
# Added old libraries in comment status
#
# Revision 1.29  2003/12/01 00:51:35  yasu
# Revised license.dat file settings
#
# Revision 1.28  2003/11/29 12:29:22  yasu
# Changed all libraries that do not include vsnprintf  to strb version.
#
# Revision 1.27  2003/11/29 10:48:32  yasu
# Added SDK_BB_ICE
#
# Revision 1.26  2003/11/29 04:10:21  yasu
# Revised as options
#
# Revision 1.25  2003/11/29 01:26:21  yasu
# Because vsnprintf is not working, changed library groups to old ones.
#
# Revision 1.24  2003/11/28 02:02:52  yasu
# Moved libsyscall.a to commondefs
#
# Revision 1.23  2003/11/28 02:01:12  yasu
# Swapped CW for NITRO standard libraries
#
# Revision 1.22  2003/11/27 13:43:31  yasu
# Added option for byte access
#
# Revision 1.21  2003/11/27 08:12:34  yasu
# Revised: CWFolder_NITRO -> CWFOLDER_NITRO
#
# Revision 1.20  2003/11/27 05:01:15  yasu
# Support for CodeWarrior for NITRO v0.1
#
# Revision 1.19  2003/11/25 00:03:03  yasu
# Added -stdinc option
#
# Revision 1.18  2003/11/21 06:32:00  yasu
# During SDK_DEBUG, does not define SDK_CWBUG_INLINE
#
# Revision 1.17  2003/11/21 04:07:21  yasu
# Added SDK_CWBUG_INLINE switch. This is used as an inline optimization bug workaround.
#
# Revision 1.16  2003/11/20 13:02:51  yasu
# To SDK_CODE_ARM that avoids SDK_ARM duplicate definition
#
# Revision 1.15  2003/11/20 00:02:47  yasu
# Added SDK_ARM/SDK_THUMB definition
#
# Revision 1.14  2003/11/17 01:31:05  yasu
# Separate C++ definitions and C definitions
#
# Revision 1.13  2003/11/13 11:59:47  yasu
# Corrected typo
#
# Revision 1.12  2003/11/13 06:44:10  yasu
# Added ARM / Thumb mode compile switch
#
# Revision 1.11  2003/11/12 04:19:41  yasu
# Added definitions for ARM7. Use macro switch TARGET_PROC.
#
# Revision 1.10  2003/11/10 05:24:18  yasu
# Added build control using environmental variables.
#
# Revision 1.9  2003/11/07 08:54:49  yasu
# Added -enum int and other options
#
# Revision 1.8  2003/11/06 13:36:58  yasu
# Revised LM_LICENSE_FILE default value
#
# Revision 1.7  2003/11/06 10:39:21  yasu
# Rethought compile options
#
# Revision 1.6  2003/11/05 09:57:26  yasu
# Revised: IRIS_INC_DIR -> IRIS_INCDIR
#
# Revision 1.5  2003/11/05 09:15:13  yasu
# Added ARFLAGS
# Enable source switch using SDK_RELEASE/SDK_DEBUG
#
# Revision 1.4  2003/11/05 07:14:00  yasu
# Provisional completion of CodeWarrior option settings
#
# Revision 1.3  2003/10/29 06:47:28  yasu
# Support "make clean/clobber" only
#
# Revision 1.2  2003/10/24 13:19:07  yasu
# Registration of header files etc.
#
# Revision 1.1  2003/10/23 04:38:07  yasu
# initial version
#
# $NoKeywords: $
#----------------------------------------------------------------------------

EMPTY	 	?=
SPACE 		?= $(EMPTY) $(EMPTY)


#----------------------------------------------------------------------------
CWFOLDER_IRIS   ?= C:/Program Files/Metrowerks/CodeWarrior for NITRO V0.6.1
CWFOLDER_NITRO	?= $(CWFOLDER_IRIS)
LM_LICENSE_FILE	:= $(subst /,\,$(CWFOLDER_NITRO))\license.dat
CW_ROOT		:= $(subst $(SPACE),\ ,$(subst \,/,$(CWFOLDER_NITRO)))
CW_BINDIR	:= $(CW_ROOT)/ARM_Tools/Command_Line_Tools
CW_ARMDIR	:= $(CW_ROOT)/ARM_EABI_Support

#----------------------------------------------------------------------------
SDK_VERINFO_CW_CC	:= $(NITRO_BUILDTOOLSDIR)/verinfo.cw.cc
SDK_VERINFO_CW_LD	:= $(NITRO_BUILDTOOLSDIR)/verinfo.cw.ld

ifeq	($(MAKECMDGOALS),do-build)
-include $(SDK_VERINFO_CW_CC) $(SDK_VERINFO_CW_LD)
endif

ifneq	(,$(findstring $(SDK_CW_BUILD_NUMBER_LD),0050 0056))
######## IRIS V0.2 Hotfix 1
######## NITRO V0.3
CW_AVOID_STRB		:= -avoid_strb all,noerr
#
else
######## NITRO V0.4 or other
CW_AVOID_STRB		:= -avoid_byte strb -warn_byte none
#CW_AVOID_STRB		:= -avoid_byte strb -warn_byte all
#
endif

#----------------------------------------------------------------------------

CC			:= $(CW_BINDIR)/mwccarm.exe
AS			:= $(CW_BINDIR)/mwasmarm.exe
LD			:= $(CW_BINDIR)/mwldarm.exe
AR			:= $(LD)

ELFTOBIN		:= $(CW_BINDIR)/elftobin.exe
ELFTOBIN_TYPE		:= $(NITRO_PLATFORM)$(CODEGEN_ARCH)/$(NITRO_BUILD_DIR)
ELFTOBIN_ARM9		?= $(NITRO_COMPONENTSDIR)/printserver/$(NITRO_BUILDTYPE_ARM9)/printserver.nef
ELFTOBIN_ARM7		?= $(NITRO_COMPONENTSDIR)/ferret/$(NITRO_BUILDTYPE_ARM7)/ferret.nef
ELFTOBIN_ROMHEADER	?= $(NITRO_TOOLSDIR)/elftobin/romHeader.bin

#----------------------------------------------------------------------------
#  Workaround flags
#	SDK_CW_WARNOFF_SAFESTRB	: use code32.h to wipe warning STRB out
#	SDK_CW_WA_OPT4          : workaround for -O4
#	SDK_CW_WA_CONSTPOOLS    : workaround for CW 'ConstantPools.c'line: 346
#	SDK_CW_WA_OPT_BLX	: workaround for blxeq,blxne with opt>=2
#	SDK_CW_WA_LIBCXX	: workaround for 'C++' libname in lcf
#

#--- flags ---
ifeq	($(NITRO_PLATFORM),TEG)
SDK_CW_WARNOFF_SAFESTRB := yes
else
SDK_CW_WARNOFF_SAFESTRB	:=
endif

ifneq	(,$(findstring $(SDK_CW_BUILD_NUMBER_LD),0050 0056 0057))
######## IRIS V0.2 Hotfix 1
######## NITRO V0.3
######## NITRO V0.4.1
SDK_CW_WA_OPT4          := yes
SDK_CW_WA_CONSTPOOLS    := yes
SDK_CW_WA_OPT_BLX	:= yes
else
ifneq	(,$(findstring $(SDK_CW_BUILD_NUMBER_LD),0058 0061 0062))
######## NITRO V0.5
######## NITRO V0.5 + HotFix1
######## NITRO V0.6
SDK_CW_WA_LIBCXX	:= yes
endif
endif

#-----------------------------------
#
ifdef   SDK_CW_WA_OPT_BLX
ifdef	NITRO_BLXCHECKED
#	workaround by pragma
MACRO_FLAGS	+= -DSDK_CW_WA_OPT_BLX
else
#	workaround by option
SDK_CW_AVOID_ARM_ARCH5	:= yes
endif
endif

ifdef	SDK_CW_WARNOFF_SAFESTRB
MACRO_FLAGS	+= -DSDK_CW_WARNOFF_SAFESTRB
endif

ifdef   SDK_CW_WA_OPT4
ifeq	($(NITRO_CODEGEN),ARM)
ifneq	($(NITRO_BUILD_TYPE),DEBUG)
MACRO_FLAGS	+= -DSDK_CW_WA_OPT4
endif
endif
endif

ifdef	SDK_CW_WA_CONSTPOOLS
ifeq	($(NITRO_CODEGEN),THUMB)
ifneq	($(NITRO_BUILD_TYPE),DEBUG)
MACRO_FLAGS	+= -DSDK_CW_WA_CONSTPOOLS
endif
endif
endif

#----------------------------------------------------------------------------
# SDK small build

ifdef	SDK_SMALL_BUILD
MACRO_FLAGS	+=	-DSDK_SMALL_BUILD
endif

#----------------------------------------------------------------------------
#  Workaround flags
#	SDK_TEG_WA_VBLANK	: workaround TEG vblank problems
#

ifeq	($(NITRO_PLATFORM),TEG)
MACRO_FLAGS	+= -DSDK_TEG_WA_VBLANK
endif


#----------------------------------------------------------------------------
ifneq	(,$(findstring $(SDK_CW_BUILD_NUMBER_LD),0050 0056 0057))
######## IRIS  V0.2 Hotfix 1
######## NITRO V0.3
######## NITRO V0.4
CW_LIBNAME_RULE_A   := ARM
CW_LIBNAME_RULE_T   := Thumb
CW_LIBNAME_RULE_AI  := ARM_i
CW_LIBNAME_RULE_RA  := ARM_Runtime
CW_LIBNAME_RULE_RT  := Thumb_Runtime
CW_LIBNAME_RULE_RAI := ARM_Runtime_i
#
else
######## NITRO V0.5 or other
CW_LIBNAME_RULE_A   := NITRO_A
CW_LIBNAME_RULE_T   := NITRO_T
CW_LIBNAME_RULE_AI  := NITRO_Ai
CW_LIBNAME_RULE_RA  := NITRO_Runtime_A
CW_LIBNAME_RULE_RT  := NITRO_Runtime_T
CW_LIBNAME_RULE_RAI := NITRO_Runtime_Ai
#
endif

CW_INCDIRS	= $(CW_ARMDIR)/msl/MSL_C/MSL_ARM/Include		\
		  $(CW_ARMDIR)/msl/MSL_C/MSL_Common/Include		\
		  $(CW_ARMDIR)/msl/MSL_C/MSL_Common_Embedded/Math/Include \
		  $(CW_ARMDIR)/msl/MSL_C++/MSL_ARM/Include		\
		  $(CW_ARMDIR)/msl/MSL_C++/MSL_Common/Include		\
		  $(CW_ARMDIR)/msl/MSL_Extras/MSL_Common/Include	\
		  $(CW_ARMDIR)/Profiler/include

CW_CXX		= $(if $(SDK_CW_WA_LIBCXX),CXX,CPP)
CW_LIBCXX_DIR	= $(if $(SDK_CW_WA_LIBCXX),$(ROOT)/lib/CodeWarrior,$(CW_ARMDIR)/msl/MSL_C++/MSL_ARM/Lib)
CW_LIBDIRS	= $(CW_ARMDIR)/msl/MSL_C/MSL_ARM/Lib			\
		  $(CW_LIBCXX_DIR)					\
		  $(CW_ARMDIR)/msl/MSL_Extras/MSL_ARM/Lib 		\
		  $(CW_ARMDIR)/Runtime/Lib				\
		  $(CW_ARMDIR)/Mathlib/lib

ifeq		($(CODEGEN_PROC)-$(NITRO_PLATFORM),ARM9-TEG)
CW_SURFFIX	= _LE_strb.a
else
CW_SURFFIX	= _LE.a
endif
ifeq		($(CODEGEN_PROC),ARM9)
CW_LIBFP	= FP_fullI_v5t_LE.a
else
CW_LIBFP	= FP_fullI_v4t_LE.a
endif

CW_LIBCXX_ARM	= MSL_$(CW_CXX)_$(CW_LIBNAME_RULE_AI)$(CW_SURFFIX)

CW_LIBS_ARM	= MSL_C_$(CW_LIBNAME_RULE_AI)$(CW_SURFFIX)		\
		  MSL_Extras_$(CW_LIBNAME_RULE_AI)$(CW_SURFFIX)		\
		  $(CW_LIBCXX_ARM)					\
		  $(CW_LIBFP)						\
		  $(CW_LIBNAME_RULE_RAI)$(CW_SURFFIX)

# Workaround for Byte Access: Don't use thumb libraries if ARM9-TEG
ifeq		($(CODEGEN_PROC)-$(NITRO_PLATFORM),ARM9-TEG)

CW_LIBCXX_THUMB = $(CW_LIBCXX_ARM)

CW_LIBS_THUMB	= $(CW_LIBS_ARM)

else

CW_LIBCXX_THUMB = MSL_$(CW_CXX)_$(CW_LIBNAME_RULE_T)_LE.a

CW_LIBS_THUMB	= MSL_C_$(CW_LIBNAME_RULE_T)_LE.a			\
		  MSL_Extras_$(CW_LIBNAME_RULE_T)_LE.a			\
		  $(CW_LIBCXX_THUMB)					\
		  $(CW_LIBFP)						\
		  $(CW_LIBNAME_RULE_RT)_LE.a
endif

ifeq	($(CODEGEN_PROC),ARM9)
STUBS_LIBS	+= libstubscw$(NITRO_LIBSUFFIX).a
else #	($(CODEGEN_PROC),ARM7)
STUBS_LIBS	+= libstubscw_sp$(NITRO_LIBSUFFIX).a
endif


#----------------------------------------------------------------------------
#  switch by codegen target
#    NITRO_PLATFORM  TEG/TS
#    NITRO_MEMSIZE   4M/8M
#    CODEGEN_PROC    ARM7/ARM9
#    CODEGEN_CC      ARM/THUMB
#    CODEGEN_AS      ARM/THUMB
#

MACRO_FLAGS	+= -DSDK_$(NITRO_PLATFORM)  \
		   -DSDK_$(NITRO_MEMSIZE)   \
		   -DSDK_$(CODEGEN_PROC)

MACRO_FLAGS_CC	+= -DSDK_CODE_$(CODEGEN_CC)
MACRO_FLAGS_AS	+= -DSDK_CODE_$(CODEGEN_AS)


#-------------------------------------- CODEGEN_PROC ARM9/ARM7
ifeq		($(CODEGEN_PROC),ARM9)

CCFLAGS_PROC	:= -proc $(if $(SDK_CW_AVOID_ARM_ARCH5),arm7tdmi,arm946e)
ASFLAGS_PROC	:= -proc arm5TE

ifeq		($(NITRO_PLATFORM),TEG)
CCFLAGS_PROC	+= $(CW_AVOID_STRB)
endif

else	#	($(CODEGEN_PROC),ARM7)

CCFLAGS_PROC	:= -proc arm7tdmi
ASFLAGS_PROC	:= -proc arm4T

endif	#	($(CODEGEN_PROC))

#-------------------------------------- NITRO_CODEGEN ARM/THUMB

ifeq		($(NITRO_CODEGEN),ARM)
CW_LIBS		?= $(CW_LIBS_ARM)
else	#	($(NITRO_CODEGEN),THUMB)
CW_LIBS		?= $(CW_LIBS_THUMB)
endif


#-------------------------------------- CODEGEN_CC  ARM/THUMB

ifeq		($(CODEGEN_CC),THUMB)
CCFLAGS_ISET	:= -thumb
else
CCFLAGS_ISET	:= -nothumb
endif


#-------------------------------------- CODEGEN_AS  ARM/THUMB

ifeq		($(CODEGEN_AS),THUMB)
ASFLAGS_ISET	:= -16
else
ASFLAGS_ISET	:= -32
endif


CCFLAGS_ARCH	?= $(CCFLAGS_PROC) $(CCFLAGS_ISET) -nopic -nopid -interworking
ASFLAGS_ARCH	?= $(ASFLAGS_PROC) $(ASFLAGS_ISET)
LDFLAGS_ARCH	?= $(CCFLAGS_PROC) $(CCFLAGS_ISET) -nopic -nopid -interworking
ARFLAGS_ARCH	?=

#----------------------------------------------------------------------------
#  standard includes/libraries for CodeWarrior
#

export	MWCIncludes    := $(subst \;, ,$(subst $(SPACE),;,$(CW_INCDIRS)))
export	MWLibraries    := $(subst \;, ,$(subst $(SPACE),;,$(CW_LIBDIRS)))
export	MWLibraryFiles := $(subst \;, ,$(subst $(SPACE),;,$(CW_LIBS)))

#----------------------------------------------------------------------------
#  switch by C Compiler CW/ARM/GCC
#

MACRO_FLAGS	+= -DSDK_$(NITRO_CCTYPE)


#----------------------------------------------------------------------------
#  switch by DEBUG/RELEASE/FINALROM
#

MACRO_FLAGS	+= -DSDK_$(NITRO_BUILD_TYPE)

ifeq		($(NITRO_BUILD_TYPE),DEBUG)

CCFLAGS_OPT	?= -O0 -inline off
ASFLAGS_OPT	?=
LDFLAGS_OPT	?=
ARFLAGS_OPT	?=

else

ifdef		NITRO_CONSERVATIVE
CCFLAGS_OPT_O_	= -O1 -inline on,noauto
else
CCFLAGS_OPT_O_	= -O4 -inline on,noauto
endif

ifeq		($(CODEGEN_PROC),ARM9)
CCFLAGS_OPT_O_	+= -opt speed
else
CCFLAGS_OPT_O_	+= -opt space
endif

ifeq		($(NITRO_BUILD_TYPE),FINALROM)
CCFLAGS_OPT	?= $(CCFLAGS_OPT_O_)
ASFLAGS_OPT	?=
LDFLAGS_OPT	?=
ARFLAGS_OPT	?=
else 	#	($(NITRO_BUILD_TYPE),RELEASE)	# (default)
CCFLAGS_OPT	?= $(CCFLAGS_OPT_O_)
ASFLAGS_OPT	?=
LDFLAGS_OPT	?=
ARFLAGS_OPT	?=
endif

endif

ifndef		NITRO_NO_OPT_G
CCFLAGS_OPT	+= -g
LDFLAGS_OPT	+= -g
endif


#----------------------------------------------------------------------------
#  switch for code profiling
#

ifdef		NITRO_PROFILE
CCFLAGS_OPT	+= -profile
endif

ifdef		NITRO_PROFILE_TYPE
CCFLAGS_OPT	+= -DSDK_PROFILE_$(NITRO_PROFILE_TYPE)
endif


#----------------------------------------------------------------------------
#  switch for anti-thread policy
#

ifdef		NITRO_NO_THREAD
MACRO_FLAGS	+= -DSDK_NO_THREAD
endif


#----------------------------------------------------------------------------
#  switch for AUTOTEST
#
ifdef		NITRO_AUTOTEST
MACRO_FLAGS	+= -DSDK_AUTOTEST
endif


#----------------------------------------------------------------------------
#  switch for TS board
#
#       Default value of NITRO_TS_VERSION is defined in <nitro/spec.h>
#
#	NITRO_TS_VERSION = [0/100/200]
#
#      0 : Prototype breadboard ~ ISD-BOX Ver.C
#    100 : ISD-BOX Ver.D
#    200 : ISD-BOX Ver.E
#
#
ifdef		NITRO_TS_VERSION
MACRO_FLAGS	+= -DSDK_TS_VERSION=$(NITRO_TS_VERSION)
endif


#----------------------------------------------------------------------------
#  my macro flags
#
MACRO_FLAGS	+= $(LMACRO_FLAGS)


#----------------------------------------------------------------------------

CCFLAGS_MSGSTYLE	?= -msgstyle std

CCFLAGS_WARNING		?= -w all
LDFLAGS_WARNING		?= -w on
ARFLAGS_WARNING		?= -w on

ifeq	($(NITROSDK_LANG),en)
CCFLAGS_ENCODING	?= -enc ascii
else
CCFLAGS_ENCODING	?= -enc SJIS
endif
CCFLAGS_CHARTYPE	?= -char signed

CCFLAGS_MISC	= $(CCFLAGS_MSGSTYLE) $(CCFLAGS_WARNING) $(CCFLAGS_ENCODING) $(CCFLAGS_CHARTYPE)
ASFLAGS_MISC	= $(CCFLAGS_MSGSTYLE)
LDFLAGS_MISC	= $(CCFLAGS_MSGSTYLE) $(LDFLAGS_WARNING)
ARFLAGS_MISC	= $(CCFLAGS_MSGSTYLE) $(ARFLAGS_WARNING)


#----------------------------------------------------------------------------

CCFLAGS_SYS	?= -stdinc -enum int -stdkeywords off -Cpp_exceptions off
ASFLAGS_SYS	?= -nostdinc -DSDK_ASM
LDFLAGS_SYS	?= -stdlib -map closure -main _start
ARFLAGS_SYS	?= -library


CCFLAGS		= -lang c $(CCFLAGS_ARCH) $(CCFLAGS_OPT) $(CCFLAGS_MISC) \
		  $(CCFLAGS_SYS)  $(MACRO_FLAGS) $(MACRO_FLAGS_CC)

CXXFLAGS	= -lang c++ $(CCFLAGS_ARCH) $(CCFLAGS_OPT) $(CCFLAGS_MISC) \
		  $(CCFLAGS_SYS)  $(MACRO_FLAGS) $(MACRO_FLAGS_CC)

ASFLAGS		= $(ASFLAGS_ARCH) $(ASFLAGS_OPT) $(ASFLAGS_MISC) \
		  $(ASFLAGS_SYS)  $(MACRO_FLAGS) $(MACRO_FLAGS_AS)

LDFLAGS		= $(LDFLAGS_ARCH) $(LDFLAGS_OPT) $(LDFLAGS_MISC) \
		  $(LDFLAGS_SYS)

ARFLAGS		= $(ARFLAGS_ARCH) $(ARFLAGS_OPT) $(ARFLAGS_MISC) \
		  $(ARFLAGS_SYS)


#----- End of commondefs.cctype.CW -----
