COMPILER := ido
AS := tools/ido/cc
CC := tools/ido/cc
AR_OLD := tools/ar.py
PATCH_AR_FLAGS := 40001 110 100644
STRIP =

ifeq ($(COLOR),1)
NO_COL  := \033[0m
RED     := \033[0;31m
GREEN   := \033[0;32m
BLUE    := \033[0;34m
YELLOW  := \033[0;33m
BLINK   := \033[33;5m
endif

# Common build print status function
define print
  @$(PRINT) "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)\n"
endef

export COMPILER_PATH := $(WORKING_DIR)/tools/ido

CFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -Xcpluscomm -fullwarn -woff 516,649,838,712
ASFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -woff 516,649,838,712
CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(VERSION_DEFINE) $(PICFLAGS) $(DEBUGFLAG)
IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/ido -I $(WORKING_DIR)/include/PR
MIPS_VERSION := -mips2 -o32
PICFLAGS := -non_shared

ifeq ($(findstring _d,$(TARGET)),_d)
OPTFLAGS := -O1 -g2
ASOPTFLAGS := -O0 -g2
else
ifneq ($(filter $(VERSION),D E F G H I I_P),)
OPTFLAGS := -O1
else
OPTFLAGS := -O2
endif
ASOPTFLAGS := -O1
endif

ifneq ($(findstring _d,$(TARGET)),_d)
$(BUILD_DIR)/src/debug/%.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/host/%.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/os/%.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/rmon/%.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/libc/ll.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/libc/llbit.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/libc/llcvt.marker: OPTFLAGS := -O1
$(BUILD_DIR)/src/log/%.marker: OPTFLAGS := -O1

$(BUILD_DIR)/src/libc/%.marker: ASOPTFLAGS := -O2
$(BUILD_DIR)/src/mgu/%.marker: ASOPTFLAGS := -O2
endif

$(BUILD_DIR)/src/os/initialize_isv.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/libc/ll.marker: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/libc/llbit.marker: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/libc/llcvt.marker: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/os/exceptasm.marker: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/log/delay.marker: MIPS_VERSION := -mips1 -o32
$(BUILD_DIR)/src/log/delay.marker: PICFLAGS := -KPIC

ifneq ($(filter $(VERSION),D E F G H I I_P),)
$(BUILD_DIR)/src/libc/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/sched/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/gu/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/mgu/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/sp/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/audio/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/rg/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/gt/%.marker: OPTFLAGS := -O3
endif

ifneq ($(filter $(VERSION),I_P),)
$(BUILD_DIR)/src/audio/reverb.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/audio/synthesizer.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/audio/drvrnew.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/audio/env.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/audio/save.marker: OPTFLAGS := -O2

$(BUILD_DIR)/src/io/gbpakgetstatus.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/gbpakcheckconnector.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/gbpakpower.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/contreaddata.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/gbpakinit.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/pfsgetstatus.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/pimgr.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/devmgr.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/pirawdma.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/conteepprobe.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/conteepwrite.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/contpfs.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/epirawread.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/epirawdma.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/aisetfreq.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/viswapcontext.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/visetspecial.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/gbpakreadid.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/cartrominit.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/pfsselectbank.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/contramwrite.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/contramread.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/crc.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/epirawwrite.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/vimgr.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/gbpakreadwrite.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/gbpaksetbank.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/conteepread.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/sprawdma.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/sirawdma.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/sirawread.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/epiread.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/epiwrite.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/io/sirawwrite.marker: OPTFLAGS := -O2


$(BUILD_DIR)/src/libc/syncprintf.marker: OPTFLAGS := -O2


endif
