#
#	openuniverse 1.0 Makefile for gcc compilers
#
#       Remove -DLINUXJOY if your linux kernel doesn't support joysticks or
#       you're running other OS             
#
#       Even if you're running Linux, make sure your joystick driver is v1.x
#
#	Add -DHAVE_GLUI if you have GLUI installed and want GUI
#
CC= g++

# Your Mesa base directory
MESADIR=/usr/local/Mesa-3.2

#GLUIDIR=/root/glui_v2
GLUIDIR=.

#OU data directory
TEXTURE_DIR=./textures
FONT_DIR=./fonts
MODEL_DIR=./3dmodels
DATA_DIR=./data
CONF_DIR=./conf
SHOTS_DIR=./scrnshots
EVENTS_DIR=./events

CFLAGS = -Wall -O3 -I$(MESADIR)/include -DLINUXJOY \
	-DTEXTURE_DIR=\"$(TEXTURE_DIR)\" -DFONT_DIR=\"$(FONT_DIR)\" \
	-DMODEL_DIR=\"$(MODEL_DIR)\" -DDATA_DIR=\"$(DATA_DIR)\" \
	-DCONF_DIR=\"$(CONF_DIR)\" -DSHOTS_DIR=\"$(SHOTS_DIR)\" \
	-DEVENTS_DIR=\"$(EVENTS_DIR)\" -I$(GLUIDIR)

LDFLAGS= -L/usr/X11R6/lib -L$(MESADIR)/lib -ljpeg -lglut -lGLU -lGL \
	  -lXext -lXmu -lX11 -lXi -lm

#LIBS= $(GLUIDIR)/lib/libglui.a

OBJ = astrolib.o      gravity.o   keyboard.o  ou.o         sun.o \
camera.o        gui.o       lex.cfg.o   positions.o  texfont.o \
cfgparse.tab.o  info.o      loadbmf.o   radar.o      texture.o \
cmdline.o       init.o      messier.o   rings.o      timer.o \
comet.o         joystick.o  milkyway.o  scrnshot.o   util.o \
font.o          jpeg.o      mouse.o     stars.o	     flares.o \
mp3.o		events.o
 

all: openuniverse

clean:
	rm -f *.o *~ openuniverse .depend cfgparse.tab.* cfgparse.output lex.cfg.cpp

openuniverse: $(OBJ)
	$(CC) -o openuniverse $(OBJ) $(LDFLAGS) $(LIBS) 

lex.cfg.cpp: cfglex.l cfgparse.tab.cpp cfgparse.tab.h
	flex -i -Pcfg cfglex.l
	mv lex.cfg.c lex.cfg.cpp

cfgparse.tab.cpp: cfgparse.y
	bison -d -v -p cfg cfgparse.y
	mv cfgparse.tab.c cfgparse.tab.cpp

.cpp.o:
	$(CC) -c $(CFLAGS) $< 

