#
# A complicated makefile for making and installing objects for the
# ray-tracer to play with.  Gotta make 'express', and all the programs
# which generate data.
#

include ${ROOT}/usr/include/make/commondefs

IDBTAG = -idb "std.sw.demos"
DATAIDB = -idb "demos.data.rayobj"
ECFILES = express.c geom.c
ETARGETS = express

DCFILES = mobius.c trip.c crystal.c cubes.c polyhedra.c wild.c
CFILES = ${ECFILES} ${DCFILES} model.c

# The temporary things that have to get made
TTARGETS= mobius trip crystal cubes polyhedra wild

# The data files that get installed
DTARGETS= mobius.m trip.m crystal.m cubes.m polyhedra.m wild.m

TARGETS= ${ETARGETS} ${DTARGETS} ${TTARGETS}

LCINCS= -I../include
LLDLIBS = ../modlib/prim.a ../modlib/model.a -lm
LCOPTS=  

default:  model.o ${DTARGETS}

include ${COMMONRULES}

install: default
	${INSTALL} -F /usr/demos/data/models -m 755 -u demos -g demos \
		${IDBTAG} ${DTARGETS} direct

sales: default
	${INSTALL} -F /usr/demos/data/models -m 755 -u demos -g demos \
		${DATAIDB} ${DTARGETS} direct

${TTARGETS}: ${ETARGETS} ${DCFILES:.c=.o} model.o
	${CCF} $@.o model.o ${LDFLAGS} -o $@

${ETARGETS}: ${ECFILES:.c=.o}
	${CCF} ${ECFILES:.c=.o} ${LDFLAGS} -o $@

mobius.m: mobius
	./mobius 25 .3 | ./express > $@

trip.m: trip
	./trip  | ./express > $@

crystal.m: crystal
	./crystal  | ./express > $@

cubes.m: cubes
	./cubes 4.  | ./express > $@

polyhedra.m:  polyhedra
	./polyhedra | ./express > $@

wild.m:  wild
	./wild | ./express > $@

# DO NOT DELETE THIS LINE -- make depend uses it
crystal.o: crystal.c model.h
cubes.o: $(INCLDIR)/math.h $(INCLDIR)/sgimath.h $(INCLDIR)/values.h \
	 cubes.c
express.o: $(INCLDIR)/math.h $(INCLDIR)/sgimath.h $(INCLDIR)/stdio.h \
	 $(INCLDIR)/values.h express.c model.h
geom.o: $(INCLDIR)/math.h $(INCLDIR)/sgimath.h $(INCLDIR)/stdio.h \
	 $(INCLDIR)/values.h geom.c
mobius.o: $(INCLDIR)/math.h $(INCLDIR)/sgimath.h $(INCLDIR)/stdio.h \
	 $(INCLDIR)/values.h mobius.c model.h
model.o: $(INCLDIR)/math.h $(INCLDIR)/sgimath.h $(INCLDIR)/stdio.h \
	 $(INCLDIR)/values.h model.c
polyhedra.o: model.h polyhedra.c
trip.o: model.h trip.c
wild.o: model.h wild.c
# DO NOT DELETE THIS 2nd LINE -- make depend uses it
