##########################################
# These are for gcc in the sky cross env #
# See
# o GCC homepage
#   http://www.gnu.org/software/gcc
# o GCC compilations flags
#   http://www.gnu.org/software/gcc/onlinedocs/gcc_2.html
##########################################

ifeq ($(SMALLCODE), 1)
C_OPT = -Os
else
C_OPT = -O3
endif

ifeq ($(COPTIMIZE), 1)
CFLAGS += $(C_OPT)
else
CFLAGS += -O0
#------------
# # gcc requires the generation of a dependency tree, and hence at least -O1,
# # to detect any use of uninitialized variables
# so build optimised then. Code generation options take priority
#------------
endif

ifeq ($(CDEBUG), 1)
CFLAGS += -g
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__

# 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 = \
    -Wall \
    -W \
    -Wcast-qual \
    -Wchar-subscripts \
    -Wcomment \
    -Wformat \
    -Wid-clash-31 \
    -Wimplicit \
    -Wimplicit-function-declaration \
    -Wimplicit-int \
    -Winline \
    -Wlong-long \
    -Wmain \
    -Wmissing-noreturn \
    -Wmultichar \
    -Wnested-externs \
    -Wparentheses \
    -Wpointer-arith \
    -Wreturn-type \
    -Wsign-compare \
    -Wswitch \
    -Wtrigraphs \
    -Wunknown-pragmas \
    -Wunused \
    -Wwrite-strings 

ifeq ($(COPTIMIZE), 1)
CWARNINGS += -Wuninitialized
endif

#    -ansi
#    -pedantic
#    -Waggregate-return
#    -Wbad-function-cast
#    -Wcast-align
#    -Wconversion
#    -Werror
#    -Wlarger-than-len 
#    -Wmissing-declarations /* sce include files fire these warnings*/
#    -Wmissing-prototypes   /* sce include files fire these warnings*/
#    -Wredundant-decls
#    -Wshadow 
#    -Wstrict-prototypes    /* sce include files fire these warnings */
#    -Wtraditional
#    -Wundef
#    -Wuninitialized

CC        = ee-gcc
CPP       = $(CC)
COUT      = -o
LOUT      = -e
SOUT      = -S -o $(@F)
CPPOPT    = -E -P
CFLAGS   += $(CWARNINGS) -fno-common
CFLAGS   += -Wa,-I$(DEVDIR)/$(RWTARGET)
CFLAGS   += -Wa,-al=$(OBJDIR)/$(basename $(notdir $<)).lsc
CFLAGS   += -c

AS        = ee-gcc
AOUT      = -o
ASFLAGS   = -c -xassembler-with-cpp
ASFLAGS  += -Wa,-al=$(OBJDIR)/$(basename $(notdir $<)).lsa

DVPASM        = ee-dvp-as
DVPAOUT       = -o

NM        = ee-nm

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

# Librarian options (for append, we include the source lib again)
AR		= ee-ar -r
ARCREATEFLAGS   = $@ $^
ARAPPENDFLAGS	= -out:$@ $@

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

# We do want assembler

CFLAGS += -I/usr/local/sce/ee/include -I/usr/local/sce/gsb/include
CFLAGS += -fno-exceptions
