# -*-makefile-*-
# configuration variables
PREFIX = /usr/local

# font file is stored here
LIBDIR = $(PREFIX)/games/lib

# high scores file is stored here
SCOREDIR = $(PREFIX)/games/lib

# tetris binary is stored here
BINDIR = $(PREFIX)/games

# This is the name tetris will be compiled under.  If you already have another
# tetris game called tetris, you should change this to something else.
TETRIS = tetris

# set MOUSE_DEV to the mouse device; usually /dev/mouse works.
MOUSE_DEV = /dev/mouse

## You shouldn't need to change anything below this line
#
CXX = g++
DEBUG = -DDEBUG
OPTIMIZE = -O2 -fomit-frame-pointer -ffast-math -funroll-loops -s
OPTS = -Wall -pipe
INCLUDE = -I./gamelib
DEFINES = -DMOUSE_DEV=\"$(MOUSE_DEV)\" -DSCOREDIR=\"$(SCOREDIR)\" \
-DLIBDIR=\"$(LIBDIR)\"
CXXFLAGS =  $(OPTS) $(INCLUDE) $(DEFINES) $(OPTIMIZE)


OBJS = Square.o Board.o Pieces.o Game.o utils.o tetris.o
LIBS = -L./gamelib -lgame -lvga -lvgagl

$(TETRIS): $(OBJS) libgame
	$(CXX) -o $@ $(CXXFLAGS) $(OBJS) $(LIBS)

testBoard: testBoard.o Board.o Square.o Pieces.o
	$(CXX) -o $@ $(CXXFLAGS) $^ $(LIBS)

testSquare: Square.o testSquare.o
	$(CXX) -o $@ $(CXXFLAGS) $^ $(LIBS)

libgame:
	$(MAKE) -C gamelib

.PHONY: tags TAGS install clean

dep: .depend

.depend:
	rm -f .depend
	$(CXX) -MM $(INCLUDE) *.cc >.depend

tags:
	rm -f tags
	ctags -S -t -v *.cc *.h

TAGS:
	rm -f TAGS
	etags -C *.cc *.h

install: $(TETRIS)
	install -m 555 -d $(LIBDIR)
	install -m 644 8x16font $(LIBDIR)
	install -m 555 -d $(BINDIR)
	install -o root -m 4511 $(TETRIS) $(BINDIR)
	 

clean:
	rm -f *.o $(TETRIS) core .depend

include .depend
