CC = gcc
CFLAGS = -O2 -fomit-frame-pointer -ffast-math -march=pentium -funroll-loops -mwindows
LIBS = -laldmb -ldumb -lalleg
ELIBS = -lalleg

GAMEOBJECTOFILES = objects/goomba.o objects/turtle.o objects/thwomp.o objects/bulletgun.o objects/bullet.o objects/flame.o objects/beetle.o objects/rturtle.o objects/mario.o
GAMEOFILES = $(GAMEOBJECTOFILES) script.o icon.o main.o game.o title.o lselect.o character.o data.o warp.o sprite.o modules/colormap.o modules/animate.o modules/collide.o modules/tilemap.o level.o control.o modules/joy.o modules/ncds.o modules/gametime.o
GAMEEXENAME = vg.exe
LEVEDOFILES = sprite.o licon.o levedit.o modules/gametime.o modules/tilemap.o modules/itools.o level.o modules/animate.o modules/collide.o modules/mygui.o
LEVEDEXENAME = levedit.exe
SPRITEEDITOFILES = spriteedit.o modules/gametime.o modules/itools.o modules/animate.o modules/mygui.o modules/wincb.o modules/ncds.o sprite.o
SPRITEEDITEXENAME = spriteedit.exe

all : ../bin/$(GAMEEXENAME) ../bin/$(LEVEDEXENAME) ../bin/$(SPRITEEDITEXENAME)
	@echo All targets built!

../bin/$(GAMEEXENAME) : $(GAMEOFILES)
	gcc $(GAMEOFILES) $(CFLAGS) $(LIBS) -o ../bin/$(GAMEEXENAME)

../bin/$(LEVEDEXENAME) : $(LEVEDOFILES)
	gcc $(LEVEDOFILES) -o ../bin/$(LEVEDEXENAME) -O2 $(ELIBS) -mwindows

../bin/$(SPRITEEDITEXENAME) : $(SPRITEEDITOFILES)
	gcc $(SPRITEEDITOFILES) -o ../bin/$(SPRITEEDITEXENAME) -O2 $(LIBS) -mwindows

icon.o : vg.rc
	windres -o icon.o vg.rc

licon.o : levedit.rc levedit.ico
	windres -o licon.o levedit.rc

clean:
	@del *.o
	@del modules\*.o
	@del objects\*.o
	@echo Cleanup complete!

run: ../bin/$(GAMEEXENAME)
	../bin/$(GAMEEXENAME)