# RCSid: $Id: Rmakefile,v 2.36 2018/08/31 16:01:45 greg Exp $
#
# Makefile for object generation programs
#

OPT = -O
MACH = -DBSD
CFLAGS = -I../common -I../rt -L../lib $(OPT) $(MACH)
CC = cc
MLIB = -lm

INSTDIR = /usr/local/bin

LIBDIR = /usr/local/lib/ray

PROGS = genbox gensky xform genblinds genrev genworm gendaylit gendaymtx \
		gensurf genprism replmarks mkillum mksource genclock

LIBFILES = illum.cal rev.cal skybright.cal surf.cal clockface.hex \
		glaze1.cal glaze2.cal perezlum.cal perezlum_c.cal

all:	$(PROGS)

install:	$(PROGS) $(LIBFILES) glaze.csh
	cp $(PROGS) $(INSTDIR)
	cp glaze.csh $(INSTDIR)/glaze
	chmod 755 $(INSTDIR)/glaze
	cd $(LIBDIR) && rm -f $(LIBFILES)
	cp $(LIBFILES) $(LIBDIR)

clean:
	set nonomatch; rm -f $(PROGS) *.o

genbeads:	genbeads.o hermite3.o
	$(CC) $(CFLAGS) -o genbeads genbeads.o hermite3.o $(MLIB)

genbox:	genbox.o
	$(CC) $(CFLAGS) -o genbox genbox.o

genmarble:	genmarble.o ../common/random.h
	$(CC) $(CFLAGS) -o genmarble genmarble.o $(MLIB)

gensky:	gensky.o sun.o
	$(CC) $(CFLAGS) -o gensky gensky.o sun.o $(MLIB)

gendaylit:	gendaylit.o sun.o
	$(CC) $(CFLAGS) -o gendaylit gendaylit.o sun.o -lrtrad $(MLIB)

gendaymtx:	gendaymtx.o sun.o
	$(CC) $(CFLAGS) -o gendaymtx gendaymtx.o sun.o -lrtrad $(MLIB)

genblinds:	genblinds.o
	$(CC) $(CFLAGS) -o genblinds genblinds.o $(MLIB)

genprism:	genprism.o
	$(CC) $(CFLAGS) -o genprism genprism.o $(MLIB)

xform:	xform.o
	$(CC) $(CFLAGS) -o xform xform.o -lrtrad $(MLIB)

replmarks:	replmarks.o
	$(CC) $(CFLAGS) -o replmarks replmarks.o -lrtrad $(MLIB)

mkillum:	mkillum.o mkillum2.o mkillum3.o
	$(CC) $(CFLAGS) -o mkillum mkillum.o mkillum2.o mkillum3.o \
-lraycalls -lradiance -lrtrad $(MLIB)

mksource:	mksource.o
	$(CC) $(CFLAGS) -o mksource mksource.o \
-lraycalls -lradiance -lrtrad $(MLIB)

genrev:	genrev.o 
	$(CC) $(CFLAGS) -o genrev genrev.o -lrtrad $(MLIB)

gencatenary: gencat.o
	$(CC) $(CFLAGS) -o gencatenary gencat.o -lrtrad $(MLIB)

genworm:	genworm.o
	$(CC) $(CFLAGS) -o genworm genworm.o -lrtrad $(MLIB)

gensurf:	gensurf.o
	$(CC) $(CFLAGS) -o gensurf gensurf.o -lrtrad $(MLIB)

genclock:	genclock.o
	$(CC) $(CFLAGS) -o genclock genclock.o $(MLIB)

genbranch:	genbranch.o
	$(CC) $(CFLAGS) -o genbranch genbranch.o $(MLIB)

mksource.o:	../common/random.h ../rt/ray.h ../common/octree.h \
../common/object.h ../common/color.h \
../common/standard.h ../common/rtmisc.h ../common/rtio.h \
../common/rtmath.h ../common/mat4.h ../common/fvect.h \
../common/rterror.h

genworm.o replmarks.o:	../common/fvect.h

gensurf.o xform.o:	../common/standard.h \
../common/rtmisc.h ../common/rtio.h \
../common/rtmath.h ../common/rterror.h \
../common/mat4.h ../common/fvect.h

genworm.o genrev.o gensurf.o:	../common/resolu.h ../common/rterror.h

xform.o:	../common/otypes.h ../common/object.h

mkillum.o mkillum2.o mkillum3.o:	mkillum.h \
../common/otypes.h ../rt/ray.h ../common/octree.h \
../common/object.h ../common/color.h \
../common/standard.h ../common/rtmisc.h ../common/rtio.h \
../common/rtmath.h ../common/mat4.h ../common/fvect.h \
../common/rterror.h ../common/random.h

mkillum2.o:	../rt/source.h ../common/face.h ../common/cone.h

mkillum2.o mkillum3.o:	../common/paths.h

gensky.o:	../common/color.h

gensurf.o genworm.o genrev.o:	../common/calcomp.h

gendaylit.o gensky.o sun.o:	sun.h

gendaymtx.o:	../common/platform.h ../common/rtmath.h \
../common/mat4.h ../common/fvect.h ../common/color.h
