#  wt -- a 3d game engine
#
#  Copyright (C) 1994 by Chris Laurel
#  email:  claurel@mr.net
#  snail mail:  Chris Laurel, 5700 W Lake St #208,  St. Louis Park, MN  55416
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


########### Front ends -- uncomment one of these ###########
#### Old style world format
FRONTENDLIBS=
FRONTENDOBJS=wt.o worldfile.o
BASENAME=wt

##### New Tcl world format (requires Tcl)
# FRONTENDLIBS=-ltcl
# FRONTENDOBJS=tclwt.o tclworld.o tclupdate.o tclobject.o
# BASENAME=tclwt


# Define TRUECOLOR if you want to use a true color (16bpp) frame buffer.  This
# will slow wt down a bit, especially if you need to dither the frame
# buffer to display it on an 8 bpp device.

############ Graphics systems -- uncomment one of these ##########
#### Linux with svgalib
# GRAPHICLIBS=-lvgagl -lvga
# GRAPHOBJS=linuxvga.o
# uncomment only one of the next two lines
# INPUTDEVOBJS=linux-console.o
# INPUTDEVOBJS=linux-mouse.o
# GRAPHDEFS=-DLINUXVGA # -DTRUECOLOR
# NAME=$(BASENAME)

#### X11 
# If your server does not support the shared memory extension, add
#   -DNO_XSHM to the GRAPHDEFS line
#GRAPHICLIBS=-lXext -lX11
#GRAPHOBJS=x11graphics.o
#INPUTDEVOBJS=x11input.o
#GRAPHDEFS=-DX11GRAPHICS -DTRUECOLOR
#NAME=x$(BASENAME)


#### TAGL

TAGL_ROOT=../../tagl++
TAGL_LIB=$(TAGL_ROOT)/lib
TAGL_INC=$(TAGL_ROOT)/include


TAGL_LIB_O=$(TAGL_LIB)/Xgport.o $(TAGL_LIB)/SVGAgport.o \
           $(TAGL_LIB)/polyeng_24.o $(TAGL_LIB)/polyeng_555.o $(TAGL_LIB)/polyeng_8.o

GRAPHICLIBS= $(TAGL_LIB_O) -L$(TAGL_LIB) -ltagl -lvga -lX11 -lXext
GRAPHOBJS= tagl-graphics.o 
INPUTDEVOBJS=tagl-input.o
GRAPHDEFS= -DTRUECOLOR
NAME=g$(BASENAME)



.SUFFIXES= .o .c .C


OPTFLAGS=-fomit-frame-pointer

#### standard version
 CFLAGS=-O2 -m486 -Wall -Winline $(OPTFLAGS) $(GRAPHDEFS) $(ARCH_DEFS)
 BASELIBS=-lm


CC=gcc 

CXXFLAGS= -O2 -m486 -Wall -Winline $(OPTFLAGS) $(GRAPHDEFS) $(ARCH_DEFS) -I$(TAGL_INC)
CXX=g++ 
LD=g++

.c.o:
	$(CC) -c $(CFLAGS) $<
.C.o:
	$(CXX) -c $(CXXFLAGS) $<



### Architecture ###
ARCH=ARCH_i86
# ARCH= ARCH_SUN
# ARCH=ARCH_OTHER
ARCH_DEFS=-D$(ARCH)

#### debugging version
# CFLAGS=-g -m486 -Wall -Winline -DDEBUG $(GRAPHDEFS) $(ARCH_DEFS)
# BASELIBS=-lm

#### profiling version
# CFLAGS=-pg -m486 -Wall -Winline $(OPTFLAGS) $(GRAPHDEFS) $(ARCH_DEFS)
# BASELIBS=-lm

#### profiling version -- bprof
# CFLAGS=-pg -O2 -m486 -Wall -Winline $(OPTFLAGS) $(GRAPHDEFS) $(ARCH_DEFS)
# BASELIBS=-lbmon -lm

#### demo version
# CFLAGS=-O2 -static -m486 -Wall -Winline $(OPTFLAGS) $(GRAPHDEFS) $(ARCH_DEFS)
# BASELIBS=-lm



LIBS=$(FRONTENDLIBS) $(GRAPHICLIBS) $(BASELIBS)


OBJECTS=error.o \
	dither.o \
	fixed.o \
	framebuf.o \
	gifload.o \
	graphfile.o \
	list.o \
	object.o \
	ppmload.o \
	render.o \
	table.o \
	texture.o \
	view.o \
	world.o \
	wtmem.o \
	timer.o \
	collision.o \
	$(INPUTDEVOBJS) $(GRAPHOBJS) $(FRONTENDOBJS)

$(NAME): $(OBJECTS)
	$(LD) $(OBJECTS) $(LIBS) -o $(NAME)

clean:
	rm *.o $(NAME)


error.o: framebuf.h graphics.h error.h

dither.o: wt.h

fixed.o: error.h fixed.h 

framebuf.o: wt.h error.h graphics.h wtmem.h framebuf.h

gifload.o: wt.h error.h texture.h

graphfile.o: wt.h error.h wtmem.h graphfile.h

linux-console.o: wt.h error.h input.h

linux-mouse.o: wt.h error.h input.h

linuxvga.o: wt.h error.h framebuf.h graphics.h

list.o: wt.h wtmem.h list.h

object.c: wt.h error.h wtmem.h fixed.h object.h

ppmload.o:  wt.h error.h graphfile.h

render.o: wt.h error.h fixed.h wtmem.h table.h view.h texture.h \
	framebuf.h graphics.h world.h slice.h render.h \
	slice.c

table.o: wtmem.h table.h

texture.o: wt.h wtmem.h error.h texture.h

timer.o: timer.h

view.o: fixed.h wtmem.h view.h

world.o: wt.h fixed.h error.h wtmem.h texture.h table.h world.h

worldfile.o: wt.h error.h fixed.h wtmem.h list.h table.h texture.h world.h \
	 worldfile.h

wt.o: wt.h fixed.h  view.h texture.h table.h world.h worldfile.h framebuf.h \
	render.h graphics.h input.h timer.h

wtmem.o: error.h wtmem.h

x11graphics.o: wt.h error.h framebuf.h graphics.h

x11input.o: wt.h error.h input.h x11graphics.h

tclwt.o: wt.h error.h fixed.h timer.h

tclworld.o: tclworld.h world.h

tclupdate.o: tclupdate.h 

tclobject.o: tclobject.h object.h

