#########################################
# These are for CodeWarrior -- in C++ mode
#########################################

ifeq ($(SMALLCODE), 1)
C_OPT = -O4,s
else
C_OPT = -O4,p
endif

ifeq ($(COPTIMIZE), 1)
CFLAGS += $(C_OPT)
else
CFLAGS += -O0
endif

ifeq ($(CDEBUG), 1)
CFLAGS += -g -prefix PREFIX_PS2_DEBUG.h
else
CFLAGS += -prefix PREFIX_PS2.h
endif

ifeq ($(PG), 1)
CFLAGS += -pg -DPG
ifeq ($(PGA), 1)
CFLAGS += -DPGA
endif
endif

ifeq ($(SCE_11), 1)
CFLAGS += -DSCE_11
endif

# These seem to be platform specific, not compiler specific

ifeq ($(NOASM), 1)
CFLAGS += -DNOASM
endif

CFLAGS += -DRW_USE_SPF -D__FAST_MATH__

# Work around for getpass() prototype in
# /usr/local/sce/ee/gcc/ee/include/sys/unistd.h
CFLAGS += -D__const=const

# flag that we're building a PS2 build
CFLAGS += -DSKY

ifeq ("$(COMPILER)", "")
COMPILER=cc
endif

ifeq ("$(LINKER)", "")
# It should be this, but we have a rather strange idea of LINKER
LINKER=link.exe
endif

CWARNINGS = \

# 	-warn all \
# 	-warn notinlined \
# 	-warn pedantic  \
# 	-warn unused \
# 	-warn unusedvar \
# 	-warn noimplicit \
# 	-warn nounusedarg
# 	-warn dump

CC        = mwccps2 -dialect ec++ -msgstyle gcc -strict on -gccincludes 

CPP       = $(CC)
COUT      = -o 
LOUT      = -e 
SOUT      = -S -o $(@F) 
CPPOPT    = -EP
# Workaround for issues with Metrowerks/CodeWarrior/PS2 Support/PREFIX_PS2.h
CPPOPT    += -D__PREFIX_PS2__

CFLAGS   += $(CWARNINGS)

AS        = asm_r5900_elf
AOUT      = -o
ASFLAGS   = -c_preprocess -gnu # -w
ASFLAGS  += -list $(OBJDIR)/$(basename $(notdir $<)).lsa

DVPASM        = ee-dvp-as
DVPASMFLAGS  += -I$(SRCDIR) -I$(DEVDIR)/$(RWTARGET)
DVPAOUT       = -o

ifeq ($(CDEBUG), 1)
#DVPASMFLAGS += --gstabs
else
ASFLAGS     += -nodebug
endif

# Librarian options (for append, we include the source lib again)
AR		= mwldps2 -library
ARCREATEFLAGS	= -o $@ $^
ARAPPENDFLAGS	= -o $@ $@

# How to run programs (no need for shell/simulator)
RUNIT		=

# We do want assembler

ifeq ("$(PS2_DRIVE)", "")
CFLAGS += -I/usr/local/sce/ee/include -I/usr/local/sce/ee/include
else
CFLAGS += -I$(PS2_DRIVE):/usr/local/sce/ee/include
endif

