baseDir=../../
nesPath=$(baseDir)nes/
blarggPath=$(nesPath)blargg/
emuPath=$(baseDir)emu/
cubePath=$(baseDir)api_specific/gamecube/
mapPath=$(baseDir)mapperSrc/
 
TARGET	:=	ReminesceGC
 
PreProcessor = -DnotExternC -Dsound48000 -DbinaryApuReflector -DstaticMapper -DBLARGG_COMPILER_HAS_BOOL -Dno__Int -DgcDev
MACHDEP = -DGEKKO -mcpu=750 -meabi

devPath= C:/unzipped/gcDevStuff/devkitPPC_r11/
INCDIRS= -I$(devPath)include/ -I$(devPath)include/c++/3.4.3/bits -I.

LIBFILES= -logc -lm

OWNER=bin
GROUP=bin
CTAGS= ctags -x >tags
CFLAGS= -O2 -w -fpermissive $(MACHDEP) $(PreProcessor) $(INCDIRS)
LDFLAGS= $(MACHDEP) -mogc -s -w $(LIBDIRS) $(LIBFILES)
CC = powerpc-gekko-g++
CC2 = powerpc-gekko-gcc
OBJCOPY = powerpc-gekko-objcopy
GET=co
 
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
cubeFiles =	gcFileHandling.cpp general.cpp input.cpp main.cpp \
		sound.cpp video.cpp
asmFiles = incbin.S

SRCS1 = $(addprefix $(nesPath), $(nesFiles))
SRCS2 = $(addprefix $(blarggPath),$(blarggFiles))
SRCS3 = $(addprefix $(emuPath),$(emuFiles))
SRCS4 = $(addprefix $(cubePath),$(cubeFiles))
SRCS5 = $(addprefix $(cubePath),$(asmFiles))

#mappers
include ines.in
mapFiles = $(OBJS_Map)
SRCSmap = $(addprefix $(mapPath), $(mapFiles))
 
SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4)
SRCS_2= $(SRCSmap) 
SRCS_3= $(SRCS5)

#$(SRCSmap:.c=.cpp) 
 
#OBJS= $(SRCS)
OBJS= $(SRCS:.cpp=.o) $(SRCS_2:.c=.o) $(SRCS_3:.S=.o)

MANDIR=/usr/man/manl/main.l
BINDIR=/usr/local/bin
DEPEND= makedepend $(CFLAGS)
all:    $(TARGET).dol
 
# To get things out of the revision control system
$(SRCS):
%.o : %.cpp
	$(CC) -c $(CFLAGS) $< -o $@
"%.o : %.c"
	$(CC2) -c $(CFLAGS) $< -o $@"
%.o : %.S
	$(CC) -c $(CFLAGS) $< -o $@

# To make an executable
$(TARGET).elf: $(OBJS)
	$(CC) $^ $(LDFLAGS) -o $@
 
$(TARGET).dol: $(TARGET).elf
	@echo output ... $(notdir $@)
	@$(OBJCOPY)  -O binary $< $@
 
 
# where are functions/procedures?
tags: $(SRCS)
	$(CTAGS) $(SRCS)
 
# what have I done wrong?
lint: $(SRCS)
	lint $(CFLAGS) $(SRCS)
 
# what are the source dependencies
depend: $(SRCS)
	$(DEPEND) $(SRCS)
 
clean:
	@echo code the clean ...
	rm -fr $(OBJS)
