baseDir=../../
nesPath=$(baseDir)nes/
blarggPath=$(nesPath)blargg/
emuPath=$(baseDir)emu/
sdlPath=$(baseDir)api_specific/7ps2/
ps2sdlPath=$(baseDir)api_specific/7ps2/
mapPath=$(baseDir)mapperSrc/

SBVLITE = $(PS2DEV)/sbv-1.0-lite

PreProcessor = -DnoSoundPlz -DPS2dev -DbinaryApuReflector -DstaticMapper -DBLARGG_COMPILER_HAS_BOOL -Dno__Int

INCDIRS=  -I. -I$(PS2SDK)/sbv/include -I$(sdlPath)gfxpipe/ -I$(PS2SDK)/ee/include/ -I$(PS2SDK)/iop/include/ -I$(PS2SDK)/common/include/
#LIBDIRS= -lstdc++ $(PS2SDK)/sbv/lib/libsbv_patches.a -L$(PS2SDK)/ee/lib  
LIBDIRS= -lstdc++ -L$(PS2SDK)/ee/lib $(PS2SDK)/sbv/lib/libpatches.a

LIBFILES= -lgcc -lpad -lm -lc -lsyscall -lc 
ASFLAGS += -G0

EE_CFLAGS += -g -D_EE -DnoSoundPlz -DPS2dev -DbinaryApuReflector -DonotExternC -DstaticMapper -DBLARGG_COMPILER_HAS_BOOL -Dno__Int -O2 -G0 -Wall $(INCDIRS)
EE_CXXFLAGS += -g -D_EE -DnoSoundPlz -DPS2dev -DbinaryApuReflector -DonotExternC -DstaticMapper -DBLARGG_COMPILER_HAS_BOOL -Dno__Int -O2  -Wall $(INCDIRS)

CTAGS= ctags -x >tags
EE_LIBS =   $(LIBDIRS) $(LIBFILES)

nesFiles = apu.cpp cpu.cpp cpu2.cpp nes.cpp ppu.cpp ppuRegs.cpp ppuRender.cpp registers.cpp runNes.cpp
blarggFiles = Blip_Buffer.cpp Nes_Apu.cpp Nes_Apu_Reflector.cpp Nes_Oscs.cpp
emuFiles = emuFileHandling.cpp emuPalette.cpp emuMapper.cpp nestenMappers.cpp emuQuickStates.cpp
sdlFiles =	gui.cpp input.cpp  main.cpp sdlFrames.cpp \
		 sound.cpp video.cpp ps2FileHandling.cpp ps2QuickStates.cpp

VARB = $(sdlPath)
SRCSPS2= $(VARB)ps2input.o $(VARB)ps2init.o $(VARB)sjpcm.o $(VARB)hw.o  $(VARB)gs.o $(VARB)sjpcm_rpc.o $(VARB)fontmsx.o  $(VARB)gfxpipe/gfxpipe.o 

SRCS1 = $(addprefix $(nesPath), $(nesFiles))
SRCS3 = $(addprefix $(emuPath),$(emuFiles))
SRCS4 = $(addprefix $(sdlPath),$(sdlFiles))
SRCS5 = $(addprefix $(ps2sdlPath),$(ps2sdlFiles))

#mappers
include ines.in
mapFiles = $(OBJS_Map)
SRCSmap = $(addprefix $(mapPath), $(mapFiles))
SRCS_2= $(SRCSmap) 

SRCS = $(SRCS1) $(SRCS3) $(SRCS5)  $(SRCS4) 

EE_OBJS= $(SRCS:.cpp=.o) $(SRCSPS2) $(SRCS_2:.c=.o)

EE_BIN = demo.elf
all:     $(EE_BIN)

sjpcm.s:
	$(VARB)bin2s $(VARB)sjpcm.irx $(VARB)sjpcm.s $(VARB)sjpcm_irx

cleanall:
	rm $(nesPath)*.o $(emuPath)*.o $(sdlPath)*.o

cleanmap:
	rm $(mapPath)*.o $(mapPath)DLL/*.o $(mapPath)Hardware/*.o $(mapPath)Hardware/Sound/*.o $(mapPath)iNES/*.o

clean:
	-rm main *~ *.o *.bak core tags shar
	
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
