CC = gcc
#CFLAGS = -DUSE_GTK `sdl-config --cflags` `gtk-config --cflags` -Iwrapper/ -g -mmmx -msse
#CFLAGS = -DUSE_GTK `sdl-config --cflags` `gtk-config --cflags` -Iwrapper/ -O3 -mcpu=athlon -ffast-math -funroll-loops -fomit-frame-pointer -msse -mmmx
CFLAGS = -DUSE_GTK `sdl-config --cflags` `gtk-config --cflags` -Iwrapper/ -O3 -mcpu=athlon -ffast-math -funroll-loops -fomit-frame-pointer -msse -mmmx
CXX = g++
CPPFLAGS = $(CFLAGS)
LD = g++
LDFLAGS = -lGL -lGLU -L/usr/X11R6/lib -lSDL

OBJECTS = Main.o \
	rdp.o \
	Ini.o \
	wrapper/textures.o \
	wrapper/main.o \
	messagebox.o \
	wrapper/geometry.o \
	TexCache.o \
	Debugger.o \
	Util.o \
	Combine.o \
	wrapper/combiner.o \
	TexBuffer.o \
	Tmem_nasm.o \
	wrapper/config.o \
	wrapper/filter.o \
	support.o \
	wrapper/2xsai.o \
	Config.o

all: Glide64.so instruction

Glide64.so: font.h cursor.h $(OBJECTS)
	$(LD) -shared -Wl,-Bsymbolic `gtk-config --libs` $(LDFLAGS) -o $@ $(OBJECTS)
	strip --strip-all $@

font.h:	compiletex
	./compiletex font.tex font.h font

cursor.h: compiletex
	./compiletex cursor.tex cursor.h cursor

compiletex: compiletex.o
	$(LD) -o $@ compiletex.o

Tmem_nasm.o: Tmem_nasm.asm
	    nasm -f elf $<

instruction:
	$(warning please copy Glide64.so AND Glide64.ini in the plugins/ folder of the emulator)

clean:
	rm -rf $(OBJECTS) $(ALL) compiletex font.h cursor.h

rebuild: clean $(ALL)
