#############################################################################
# Makefile for new 3D package demo & now also the TNG demo from MR SPOCK
#
#############################################################################

#############################################################################
# location of various directories
#############################################################################
INC=include
LIB=lib

#############################################################################
# names of various commands
# (Change 'erase' to 'rm' if running under GULAM or similar shell on Atari.)
#############################################################################
RM=rm -f
CC= gcc -B/jaguar/bin/

#############################################################################
# Flags for commands
#############################################################################
CFLAGS= -V2.6 -b m68k -mshort -O2 -Wall -nostdinc -I$(INC)
MACFLAGS = -fb -g -rd -i$(MACPATH)
ALNFLAGS = -s -e -a 4000 x x 

#############################################################################
# rules for making things
# (Change 'docry' to 'tga2cry -binary' if using GULAM or similar shell on Atari.)
#############################################################################
.SUFFIXES: .o .s .3ds .c
.SUFFIXES: .cry .tga

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

.3ds.o:
	3dsconv -o $*.s $<
	mac $(MACFLAGS) $*.s
	$(RM) $*.s

.s.o:
	mac $(MACFLAGS) $<

.tga.cry:
	docry $<

#############################################################################
# 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)/ctype.o $(LIB)/gpulib.o \
	$(LIB)/memset.o $(LIB)/olist.o \
	$(LIB)/util.o $(LIB)/video.o

SRCOBJS = demo.o trig.o mkmat.o miscasm.o gstex.o texrend.o wfrend.o gourrend.o flattex.o play.o q_sincos.o init.o list.o scrtxt.o font8x8.o

MODELS = fuji_3d.o tng.o

#############################################################################
demo.cof: demo.lnk $(CRT0) $(SRCOBJS) $(TEXTURES) $(LIBOBJS) $(MODELS)
	aln $(ALNFLAGS) -o demo.cof -c demo.lnk

clean:
	$(RM) $(SRCOBJS) $(TEXTURES) $(MODELS) $(LIBOBJS) $(CRT0) demo.cof

#############################################################################

gstex.o: gstex.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc gourdraw.inc texdraw2.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
gourrend.o: gourrend.s draw.inc load.inc loadxpt.inc clip.inc init.inc dotri.inc gourdraw.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