#Makefile MUPEN64 for Linux

#CC  		=gcc -O3 -mpentium -Wall -DEMU64_DEBUG
CC		=gcc -O3 -fomit-frame-pointer -funroll-loops -ffast-math -mcpu=pentium -Wall -pipe
#CC		=gcc -O3 -mpentium -Wall -g -pg
#CC 		=gcc -Wall -pipe -g -DEMU64_DEBUG
#CC		=gcc -Wall -pipe -g -DEMU64_DEBUG -DCOMPARE_CORE
#CC		=icc -O3 -unroll -axM -vec_report3 -Dinline=

GL_PATH		=-I/usr/X11R6/include

OBJ		=main/rom.o \
		r4300/r4300.o \
		r4300/cop0.o \
		r4300/special.o \
		r4300/regimm.o \
		r4300/exception.o \
		memory/tlb.o \
		memory/memory.o \
		memory/dma.o \
		r4300/interupt.o \
		r4300/cop1.o \
		r4300/tlb.o \
		r4300/cop1_w.o \
		r4300/cop1_s.o \
		r4300/cop1_d.o \
		r4300/recomp.o \
		memory/pif.o \
		r4300/bc.o \
		r4300/cop1_l.o \
		r4300/pure_interp.o \
		r4300/compare_core.o \
		main/plugin.o \
		sound/sdl/sound.o

OBJ_X86         =r4300/x86/gr4300.o \
		r4300/x86/gcop0.o \
		r4300/x86/assemble.o \
		r4300/x86/gcop1.o \
		r4300/x86/gcop1_s.o \
		r4300/x86/gcop1_d.o \
		r4300/x86/gtlb.o \
		r4300/x86/gregimm.o \
		r4300/x86/gspecial.o \
		r4300/x86/gcop1_w.o \
		r4300/x86/debug.o \
		r4300/x86/rjump.o \
		r4300/x86/gbc.o \
		r4300/x86/gcop1_l.o

HEADER		=main/rom.h \
		r4300/r4300.h \
		r4300/ops.h \
		r4300/macros.h \
		r4300/exception.h \
		memory/memory.h \
		memory/tlb.h \
		memory/dma.h \
		r4300/interupt.h \
		r4300/recomp.h \
		memory/pif.h \
		sound/sound.h

LIB		=-lz

all:	mupen64

main/main.o:	main/main.c
		$(CC) -c -o main/main.o main/main.c

main/main_gtk.o:	main/main_gtk.c
			$(CC) -c -o main/main_gtk.o main/main_gtk.c `gtk-config --cflags`

mupen64_nogui:	$(OBJ) $(OBJ_X86) $(HEADER) main/main.o
		$(CC) $(OBJ) $(OBJ_X86) $(LIB) -Wl,-export-dynamic main/main.o -lSDL -lGL -ldl -o $@
#		strip --strip-all $@

mupen64:	$(OBJ) $(OBJ_X86) $(HEADER) main/main.o
		$(CC) $(OBJ) $(OBJ_X86) $(LIB) -Wl,-export-dynamic main/main.o -lSDL -lGL -ldl -o $@
#		strip --strip-all $@

clean:
	find . -name '*.o' -print0 | xargs -0r rm -f
	rm mupen64
	
clean_jed:
	find . -name '*~' -print0 | xargs -0r rm -f

gprof:
	gprof mupen64_nogui > stat.txt
