

########################
# GameLib Declarations #
########################
CFLAGS += -IGameLib
HEADS= \
	GameLib/Time.h \
	GameLib/Util.h \
	GameLib/QuadArray2D.h \
	GameLib/Draw.h \
	GameLib/Input.h \
	GameLib/Audio.h \
	GameLib/Anim.h \
	GameLib/Entity.h \
	GameLib/GameLib.h
OBJS= \
	$(BUILDDIR)/GameLib/Time.o \
	$(BUILDDIR)/GameLib/Util.o \
	$(BUILDDIR)/GameLib/QuadArray2D.o \
	$(BUILDDIR)/GameLib/Draw.o \
	$(BUILDDIR)/GameLib/Input.o \
	$(BUILDDIR)/GameLib/Audio.o \
	$(BUILDDIR)/GameLib/Anim.o \
	$(BUILDDIR)/GameLib/Entity.o \
	$(BUILDDIR)/GameLib/GameLib.o \


#####################
# Game Declarations #
#####################
HEADS+= GameEnts.h GameMap.h

OBJS+= \
	$(BUILDDIR)/GameEnts.o \
	$(BUILDDIR)/GameMap.o \
	$(BUILDDIR)/main.o


#################
# General Rules #
#################
all: $(BUILDDIR) $(BUILDDIR)/$(RESULT)

$(BUILDDIR):
	mkdir $(BUILDDIR)
	mkdir $(BUILDDIR)/GameLib

clean:
	rm -f $(OBJS) $(BUILDDIR)/$(RESULT)

run: $(BUILDDIR)/$(RESULT)
	$(LAUNCHER) ./$(BUILDDIR)/$(RESULT) debug

rebuild: clean all

#################
# GameLib Rules #
#################
$(BUILDDIR)/GameLib/Time.o: GameLib/Time.c $(HEADS)
	$(CC) -c GameLib/Time.c -o $(BUILDDIR)/GameLib/Time.o $(CFLAGS)
$(BUILDDIR)/GameLib/Util.o: GameLib/Util.c $(HEADS)
	$(CC) -c GameLib/Util.c -o $(BUILDDIR)/GameLib/Util.o $(CFLAGS)
$(BUILDDIR)/GameLib/QuadArray2D.o: GameLib/QuadArray2D.c $(HEADS)
	$(CC) -c GameLib/QuadArray2D.c -o $(BUILDDIR)/GameLib/QuadArray2D.o $(CFLAGS)
$(BUILDDIR)/GameLib/Draw.o: GameLib/Draw.c $(HEADS)
	$(CC) -c GameLib/Draw.c -o $(BUILDDIR)/GameLib/Draw.o $(CFLAGS)
$(BUILDDIR)/GameLib/Input.o: GameLib/Input.c $(HEADS)
	$(CC) -c GameLib/Input.c -o $(BUILDDIR)/GameLib/Input.o $(CFLAGS)
$(BUILDDIR)/GameLib/Audio.o: GameLib/Audio.c $(HEADS)
	$(CC) -c GameLib/Audio.c -o $(BUILDDIR)/GameLib/Audio.o $(CFLAGS)
$(BUILDDIR)/GameLib/Entity.o: GameLib/Entity.c $(HEADS)
	$(CC) -c GameLib/Entity.c -o $(BUILDDIR)/GameLib/Entity.o $(CFLAGS)
$(BUILDDIR)/GameLib/Anim.o: GameLib/Anim.c $(HEADS)
	$(CC) -c GameLib/Anim.c -o $(BUILDDIR)/GameLib/Anim.o $(CFLAGS)
$(BUILDDIR)/GameLib/GameLib.o: GameLib/GameLib.c $(HEADS)
	$(CC) -c GameLib/GameLib.c -o $(BUILDDIR)/GameLib/GameLib.o $(CFLAGS)


##############
# Game Rules #
##############

$(BUILDDIR)/GameEnts.o: GameEnts.c $(HEADS)
	$(CC) -c GameEnts.c -o $(BUILDDIR)/GameEnts.o $(CFLAGS)

$(BUILDDIR)/GameMap.o: GameMap.c $(HEADS)
	$(CC) -c GameMap.c -o $(BUILDDIR)/GameMap.o $(CFLAGS)

$(BUILDDIR)/main.o: main.c $(HEADS)
	$(CC) -c main.c -o $(BUILDDIR)/main.o $(CFLAGS)


################
# Result Rules #
################

$(BUILDDIR)/$(RESULT): $(OBJS)
	$(CC) -o $(BUILDDIR)/$(RESULT) $(OBJS) $(LIBS) $(CFLAGS) $(LDFLAGS)




