#
# Makefile for new 3D package demo
# TOS/Unix version
#

#
# names of various commands
#
RM=rm -f
CC= gcc
CFLAGS= -mshort -O2 -Wall -fno-builtin -nostdinc -I$(INC)

#
# location of various directories
# These should not change; use the directories
# here rather than system directories.
#
INC=./include
LIB=./lib
FONTDIR=./fonts

#
# rules for making things
#
.SUFFIXES: .o .s .3ds .c
.SUFFIXES: .cry .tga

.c.o:
	$(CC) $(CFLAGS) -o $*.o -c $<
.3ds.o:
	3dsconv -o $*.s $<
	mac -fb -I$(INC) $*.s
	$(RM) $*.s
.s.o:
	mac -fb -I$(INC) $<
.tga.cry:
	tga2cry -binary $<

#
# C library objects
# Normally we would put these into an archive (a .a file) and let the linker sort out
# which ones we need; for demo purposes, though, here they all are explicitly
#
CRT0= $(LIB)/jagrt.o
LIBOBJS = $(LIB)/alloc.o $(LIB)/clock.o $(LIB)/ctype.o $(LIB)/font.o $(LIB)/gpulib.o \
	$(LIB)/joyinp.o $(LIB)/joypad.o $(LIB)/memset.o $(LIB)/olist.o \
	$(LIB)/sprintf.o $(LIB)/strcat.o $(LIB)/strcmp.o $(LIB)/strcpy.o $(LIB)/strdup.o \
	$(LIB)/strncmp.o $(LIB)/util.o $(LIB)/video.o

SRCOBJS = miscasm.o demo.o trig.o mkmat.o \
	jag2.o wfrend.o gourrend.o \
	gstex.o texrend.o flattex.o phrrend.o noshade.o testrend.o\


MODELS = radar.o globe.o torus.o cube.o birdwlk4.o

TEXTURES = c1.cry c2.cry c3.cry u1.cry u2.cry u3.cry l1.cry l2.cry l3.cry \
	radar1a.cry radar1b.cry radar1d.cry radar1e.cry turret1b.cry

#
# the textures are arranged in decreasing order of size
#
FIXDATA = -ii c1.cry _c1 -ii c2.cry _c2 -ii c3.cry _c3 -ii u1.cry _u1 -ii u2.cry _u2 -ii u3.cry _u3 \
	-ii l1.cry _l1 -ii l2.cry _l2 -ii l3.cry _l3 \
	-ii radar1b.cry _radar1b -ii radar1d.cry _radar1d \
	-ii turret1b.cry _turret1b \
	-ii radar1a.cry _radar1a -ii radar1e.cry _radar1e \
	-ii squares.cry _squares \
	-ii $(FONTDIR)/clr6x12.jft _usefnt \

demo.cof: $(CRT0) $(SRCOBJS) $(MODELS) $(TEXTURES) $(LIBOBJS)
	aln -s -e -o demo.cof -a 4000 30000 x $(FIXDATA) $(CRT0) $(SRCOBJS) $(MODELS) $(LIBOBJS)

clean:
	$(RM) $(SRCOBJS) $(TEXTURES) $(MODELS) $(LIBOBJS) $(CRT0)

gstex.o: gstex.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc gourdraw.inc texdraw2.inc clipsubs.inc
noshade.o: noshade.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc noshade.inc clipsubs.inc
flattex.o: flattex.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc gourdraw.inc texdraw1.inc clipsubs.inc
texrend.o: texrend.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc gourdraw.inc texdraw.inc clipsubs.inc
wfrend.o: wfrend.s wfdraw.inc load.inc loadxpt.inc clip.inc init.inc clipsubs.inc
gourrend.o: gourrend.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc gourdraw.inc clipsubs.inc
jag2.o: jag2.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc jag2gour.inc jag2tex.inc clipsubs.inc
phrrend.o: phrrend.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc phrdraw.inc clipsubs.inc

testrend.o: testrend.s draw.inc xxload.inc xxloadpt.inc xxclip.inc init.inc dotri.inc noshade.inc clipsubs.inc
