# -*-makefile-*-
# Game development library v 0.1
CPU_IS_386=NO

CXX	 = g++
INC      = -I/usr/local/include
DEBUG    = -ggdb
OPTS	 = -Wall -pipe
OPTIMIZE = -fomit-frame-pointer -O2 -ffast-math -funroll-loops -s
INSTALLDIR = /usr/local/lib

ifeq ($(CPU_IS_386),NO)
OPTS := -m486 $(OPTS)
endif

DEFINES  =

# regular use
CXXFLAGS = $(DEFINES) $(INC) $(OPTIMIZE) $(OPTS)

# for debugging
#CXXFLAGS = $(DEFINES) $(INC) $(DEBUG) $(OPTS)

#LFLAGS   = -static

GAMELIB    = libgame.a
GAMELIB_O  =  HiScore.o Bitmap.o SBitmap.o \
	Timer.o Ui.o ObjTools.o FastMath.o Explosion.o \
	Sprite.o Joystick.o Keyboard.o fonts.o \
	RawImageLoader.o cfclass.o Mouse.o Button.o DisplayBox.o \
	Menu.o InfoBox.o MsgBox.o DIBImageLoader.o CPalette.o

$(GAMELIB): $(GAMELIB_O)
	ar -rc $(GAMELIB) $(GAMELIB_O)	
	@echo 
	@echo \"$(GAMELIB)\" has successfully compiled.
	@echo 


demo: demo.o $(GAMELIB)
	$(CXX) $(CXXFLAGS) -o $@ $^ -lvga -lvgagl

testMenu: testMenu.o $(GAMELIB)
	$(CXX) $(CXXFLAGS) -o $@ $^ -lvga -lvgagl

testInfoBox: testInfoBox.o $(GAMELIB)
	$(CXX) $(CXXFLAGS) -o $@ $^ -lvga -lvgagl

testMsgBox: testMsgBox.o $(GAMELIB)
	$(CXX) $(CXXFLAGS) -o $@ $^ -lvga -lvgagl

testbmp: testbmp.o $(GAMELIB)
	$(CXX) $(CXXFLAGS) -o $@ $^ -lvga -lvgagl

install: $(GAMELIB)
	install -m 0644 $(GAMELIB) /usr/local/lib

.PHONY:	dep depend clean cleanall tags TAGS

cleanall: clean
	rm -f $(GAMELIB)

clean:
	rm -f *.o *~

dep:	depend
depend:	
	rm -rf depend
	$(CXX) -MM $(INC) *.cc > dependancies

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

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

include dependancies






