#marat=1
cc = gcc
ld = gcc
sdllibs = -lz `sdl-config --libs`

sdldirs = -I. -Iunzip `sdl-config --cflags`

objs = unes.o unes_apu.o unes_ppu.o unes_io.o unes_mapper.o snss.o unes_loadzip.o unzip/unzip.o unzip/explode.o unzip/unreduce.o unzip/unshrink.o

ifdef marat
ofiles = $(objs) m6502/M6502.o
ccopts = -O6 -fomit-frame-pointer -mpentium -fno-exceptions -D__marat__ -Im6502
else
ofiles = $(objs) n6502/6502.o
ccopts = -O6 -fomit-frame-pointer -mpentium -fno-exceptions -In6502
endif

.SUFFIXES: .o .c .h

all: ljohn.exe

ljohn.exe: $(ofiles)
	$(ld) $(sdldirs) -o $@ $(ofiles) $(sdllibs)

.c.o:	
	$(cc) $(ccopts) -c $(sdldirs) $*.c -o $@


clean:
	rm -f $(ofiles)

cleanall:
	rm -f $(ofiles)
	rm -f ljohn.exe

unes.o: unes.h unes_apu.h unes_mapper.h unes_ppu.h unes_io.h snss.h font.h unes_pal.h
unes_apu.o: unes.h unes_apu.h
unes_ppu.o: unes.h unes_ppu.h
unes_io.o: unes.h unes_io.h unes_mapper.h unes_apu.h
unes_mapper.o: unes.h unes_mapper.h
unes_loadzip.o: unes.h
m6502/M6502.o: m6502/M6502.h
n6502/6502.o: n6502/6502.h
