#
# Makefile for Sofie
#


#if you have a Pentium computer, then tell me how fast it is
MHZ=133000000

# PATH for -X11 -Xext
LIB_PATH=-L/usr/X11R6/lib


# if you do not have a pentium comment that out !!
# MHZ is necessary for correct timing. 
# Assign the value 1.0/133000000.0 for a 133 MHZ Pentium
RDTSC= -DPENTIUM -DMHZ=1.0/133000000.0

# what compiler ?
CCPP=g++ 

#### compiler switches
CPPFLAGS= -O6 -m486 -felide-constructors -fnonnull-objects 
#CPPFLAGS= -g -m486 
#CPPFLAGS= -pg -g -m486  

JOYSTICK= #-DJOYSTICK 
COLORS= -DHICOLOR


# below there is no need to change

TIMER= #-DTIMER -DCPS="1.0/($(MHZ))"  #-DPLAY
# Timer uses RDTSC (Intel specific!), therefore it is only available for Pentium or higher computers

all: demo3


demo3.o: graphics.h sofie.h demo3.cc Makefile world3.cc pilots3.cc points.h texture.h scrman.h input.h cockpit.h pilot.h
	$(CCPP) $(CPPFLAGS) $(JOYSTICK) $(COLORS) $(TIMER) -c demo3.cc -o demo3.o 

graphics.o: graphics.cc graphics.h input.h globals.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c graphics.cc -o graphics.o

console.o: console.cc console.h input.h
	$(CCPP) $(CPPFLAGS) $(JOYSTICK) -c console.cc -o console.o

input.o: input.cc input.h
	$(CCPP) $(CPPFLAGS) $(JOYSTICK) -c input.cc -o input.o

points.o: points.cc points.h 
	$(CCPP) $(CPPFLAGS) -c points.cc -o points.o

frustrum.o: frustrum.cc frustrum.h points.h 
	$(CCPP) $(CPPFLAGS) -c frustrum.cc -o frustrum.o

tpointset.o: points.h tpointset.h tpointset.cc
	$(CCPP) $(CPPFLAGS) -c tpointset.cc -o tpointset.o

scrman.o: scrman.cc scrman.h globals.h texture.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c scrman.cc -o scrman.o

texture.o: texture.cc texture.h globals.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c texture.cc -o texture.o

polygon.o: polygon.cc polygon.h points.h texture.h scrman.h globals.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c polygon.cc -o polygon.o

bsp.o: bsp.cc bsp.h polygon.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c bsp.cc -o bsp.o

objects.o: objects.cc objects.h points.h tpointset.h polygon.h bsp.h
	$(CCPP) $(CPPFLAGS) -c objects.cc -o objects.o

objman.o: objman.cc objman.h 
	$(CCPP) $(CPPFLAGS) -c objman.cc -o objman.o

cockpit.o: cockpit.cc cockpit.h texture.h scrman.h globals.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c cockpit.cc -o cockpit.o

radar.o: radar.cc radar.h 
	$(CCPP) $(CPPFLAGS) $(COLORS) -c radar.cc -o radar.o

pilot.o: pilot.cc pilot.h 
	$(CCPP) $(CPPFLAGS) $(COLORS) -c pilot.cc -o pilot.o

stars.o: stars.cc stars.h points.h
	$(CCPP) $(CPPFLAGS) $(COLORS) -c stars.cc -o stars.o

timer.o: timer.cc timer.h Makefile
	$(CCPP) $(CPPFLAGS) $(COLORS) $(TIMER) -c timer.cc -o timer.o

demo3: demo3.o graphics.o console.o input.o points.o frustrum.o tpointset.o scrman.o texture.o \
	polygon.o bsp.o objects.o objman.o cockpit.o radar.o pilot.o stars.o timer.o
	$(CCPP) $(CPPFLAGS) timer.o stars.o pilot.o radar.o cockpit.o objman.o \
	objects.o bsp.o polygon.o texture.o scrman.o tpointset.o frustrum.o points.o input.o console.o \
	graphics.o demo3.o -o demo3 $(LIB_PATH) -lX11 -lXext 


clean:
	rm -r -f *.o $(NAME); rm -r -f html

doc++:
	rm -r -f html
	doc++ -d html sofie.dxx

