baseDir=../../../
nesPath=$(baseDir)nes/
blarggPath=$(nesPath)blargg/
emuPath=$(baseDir)emu/
pcPath=$(baseDir)api_specific/pc/
sdlPath=$(baseDir)api_specific/sdl/
mapPath=$(baseDir)mapperSrc/

SDL_Path=C:/unzipped/SDL-1.2.8/SDL-1.2.8/
PreProcessor = -DbinaryApuReflector -DstaticMapper -DBLARGG_COMPILER_HAS_BOOL -Dno__Int \
		-DnotExternC -DuseBlarggQueue #-DnoSoundPlz

#fix these
INCDIRS= -I$(SDL_Path)include/ -I. -I../../
LIBDIRS= -L$(SDL_Path)/src/.libs
LIBFILES= -lSDL #-lSDL.dll#-lSDLmain

OWNER=bin
GROUP=bin
CTAGS= ctags -x >tags
CFLAGS= $(PreProcessor) $(INCDIRS) 
LDFLAGS= -s -w $(LIBDIRS) $(LIBFILES)
CC = g++
CC2 = g++
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 emuQuickStates.cpp nestenMappers.cpp
pcFiles = pcFileHandling.cpp pcQuickStates.cpp
sdlFiles =	gui.cpp input.cpp main.cpp sdlFileHandling.cpp sdlFrames.cpp \
		sound.cpp video.cpp

SRCS1 = $(addprefix $(nesPath), $(nesFiles))
SRCS2 = $(addprefix $(blarggPath),$(blarggFiles))
SRCS3 = $(addprefix $(emuPath),$(emuFiles))
SRCS4 = $(addprefix $(sdlPath),$(sdlFiles))
SRCS5 = $(addprefix $(pcPath),$(pcFiles))

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

SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) $(SRCS5)
SRCS_2= $(SRCSmap) 
#$(SRCSmap:.c=.cpp) 

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

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

# To make an executable
main: $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS)
 
# To install things in the right place
install: main main.man
	$(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 main $(BINDIR)
	$(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 644 main.man $(MANDIR)
 
# 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)
 
# to make a shar distribution
shar:   clean
	$(SHAR) README Makefile main.man $(SRCS) >shar
 
# clean out the dross
clean:
	@echo code the clean ...
	rm -fr $(OBJS)
