# RCSid: $Id: Rmakefile,v 2.83 2018/07/03 22:29:01 greg Exp $
#
# Compiles for ray tracing programs.
#

OPT = -O
MACH = -DBSD
CFLAGS = -I../common -L../lib $(OPT) $(MACH)
SPECIAL = 
CC = cc
AR = ar
MLIB = -lm
LINT = lint
LINTFLAGS = -DBSD

#
# The following are user-definable:
#
DESTDIR = .
INSTDIR = /usr/local/bin
INSTALL = cp

#
# The following paths must exist and be relative to root:
#
DEVDIR = $(INSTDIR)/dev
LIBDIR = /usr/local/lib/ray

#
# Library routines:
#
RLIB = ../lib/libradiance.a
RCLIB = ../lib/libraycalls.a
LIBS = -lrtrad $(MLIB)

#
# Device drivers for rvu (see also devtable.c):
#
DOBJS = devtable.o devcomm.o editline.o x11.o x11twind.o \
	colortab.o
DSRC = devtable.c devcomm.c editline.c x11.c x11twind.c \
	colortab.c
DLIBS = -lX11

#
# Standard object files:
#

RTOBJS = rtmain.o rtrace.o duphead.o persist.o
RTSRC = rtmain.c rtrace.c duphead.c persist.c

RPOBJS = rpmain.o rpict.o srcdraw.o duphead.o persist.o
RPSRC = rpmain.c rpict.c srcdraw.c duphead.c persist.c

RVOBJS = rvmain.o rview.o rv2.o rv3.o $(DOBJS)
RVSRC = rvmain.c rview.c rv2.c rv3.c $(DSRC)

RCOBJS = rcmain.o rcontrib.o rc2.o rc3.o
RCSRC = rcmain.c rcontrib.c rc2.c rc3.c

RLOBJS = raycalls.o raypcalls.o rayfifo.o
RLSRC = raycalls.c raypcalls.c rayfifo.c

ROBJS = $(RAYOBJS) $(SURFOBJS) $(MATOBJS) \
	$(MODOBJS) $(SUPPOBJS) $(PMOBJS)
RSRC = $(RAYSRC) $(SURFSRC) $(MATSRC) \
	$(MODSRC) $(SUPPSRC)

RAYOBJS = ambcomp.o ambient.o ambio.o freeobjmem.o initotypes.o \
	preload.o raytrace.o renderopts.o
RAYSRC = ambcomp.c ambient.c ambio.c freeobjmem.c initotypes.c \
	preload.c raytrace.c renderopts.c

SURFOBJS = source.o sphere.o srcobstr.o srcsupp.o srcsamp.o virtuals.o \
	o_face.o o_cone.o o_instance.o o_mesh.o
SURFSRC = sphere.c source.c srcobstr.c srcsupp.c srcsamp.c virtuals.c \
	o_face.c srcsamp.c o_cone.c o_instance.c o_mesh.c

MATOBJS = aniso.o normal.o dielectric.o m_clip.o glass.o m_brdf.o \
	m_mirror.o m_direct.o m_mist.o fprism.o m_alias.o m_bsdf.o \
	ashikhmin.o
MATSRC = aniso.c normal.c dielectric.c m_clip.c glass.c m_brdf.c \
	m_mirror.c m_direct.c m_mist.c fprism.c m_alias.c m_bsdf.c \
	ashikhmin.c

MODOBJS = p_func.o t_func.o p_data.o t_data.o text.o mx_func.o mx_data.o
MODSRC = p_func.c t_func.c p_data.c t_data.c text.c mx_func.c mx_data.c

SUPPOBJS = func.o noise3.o data.o
SUPPSRC = func.c noise3.c data.c

PMOBJS = pmap.o pmapsrc.o pmapmat.o pmaprand.o pmapio.o pmapdata.o \
         pmapbias.o pmapparm.o pmapcontrib.o pmapamb.o pmapray.o pmapopt.o \
         pmapdiag.o pmaptype.o oocmorton.o oococt.o oocsort.o oocbuild.o \
         oocnn.o ooccache.o pmutil.o pmcontrib2.o
PMSRC = pmap.c pmapsrc.c pmapmat.c pmaprand.c pmapio.c pmapdata.c \
        pmapbias.c pmapparm.c pmapcontrib.c pmapamb.c pmapray.c pmapopt.c \
        pmapdiag.c pmaptype.c pmapkdt.c pmapooc.c oocmorton.c oococt.c \
        oocsort.c oocbuild.c oocnn.c ooccache.c pmutil.c pmcontrib2.c

HEADERS = ambient.h ray.h data.h otspecial.h source.h

#
# What this makefile produces:
#

PROGS = $(DESTDIR)/rtrace $(DESTDIR)/rpict $(DESTDIR)/rvu $(DESTDIR)/rcontrib \
$(DESTDIR)/lookamb $(DESTDIR)/mkpmap $(DESTDIR)/pmapdump

all:	$(PROGS) $(RCLIB) $(SPECIAL)

install:	all rayinit.cal
	$(INSTALL) $(PROGS) $(INSTDIR)
	cd $(INSTDIR) ; rm -f rview ; ln -s rvu rview
	cd $(INSTDIR) ; rm -f rtcontrib ; ln -s rcontrib rtcontrib
	rm -f $(LIBDIR)/rayinit.cal
	cp rayinit.cal $(LIBDIR)

ogl:	

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

lint:	$(RVSRC)
	$(LINT) $(LINTFLAGS) -DRVIEW $(RVSRC) $(LIBS)

#
# Links:
#

$(DESTDIR)/rtrace:	$(RTOBJS) $(RCLIB) $(RLIB)
	$(CC) $(CFLAGS) -o $(DESTDIR)/rtrace $(RTOBJS) $(RCLIB) $(RLIB) $(LIBS)

$(DESTDIR)/rpict:	$(RPOBJS) $(RLIB)
	$(CC) $(CFLAGS) -o $(DESTDIR)/rpict $(RPOBJS) $(RLIB) $(LIBS)

$(DESTDIR)/rvu:	$(RVOBJS) $(RCLIB) $(RLIB)
	$(CC) $(CFLAGS) -o $(DESTDIR)/rvu $(RVOBJS) $(RCLIB) \
$(RLIB) $(LIBS) $(DLIBS)

$(DESTDIR)/rcontrib:      $(RCOBJS) $(RLIB)
	$(CC) $(CFLAGS) -o $(DESTDIR)/rcontrib $(RCOBJS) $(RLIB) $(LIBS)

$(DESTDIR)/lookamb:	lookamb.o ambio.o
	$(CC) $(CFLAGS) -o $(DESTDIR)/lookamb lookamb.o ambio.o $(LIBS)

$(DESTDIR)/mkpmap: mkpmap.o $(RLIB)
	$(CC) $(CFLAGS) -o $(DESTDIR)/mkpmap mkpmap.o $(RLIB) $(LIBS)

$(DESTDIR)/pmapdump: pmapdump.o pmaptype.o pmapparm.o
	$(CC) $(CFLAGS) -o pmapdump pmapdump.o pmaptype.o pmapparm.o $(LIBS)

$(RLIB):	$(ROBJS) Version.o
	rm -f $(RLIB)
	$(AR) rc $(RLIB) $(ROBJS) Version.o
	-ranlib $(RLIB)

$(RCLIB):	$(RLOBJS)
	rm -f $(RCLIB)
	$(AR) rc $(RCLIB) $(RLOBJS)
	-ranlib $(RCLIB)

#
# Uncomment the following to model dispersion:
#
dielectric.o:	dielectric.c source.h
	$(CC) $(CFLAGS) -DDISPERSE -c dielectric.c

# end of dispersion compiles.

devcomm.o:	devcomm.c
	$(CC) $(CFLAGS) -DDEVPATH=\"$(DEVDIR)\" -c devcomm.c

#
# Version module:
#

Version.c:	VERSION $(RSRC) $(HEADERS)
	( cat VERSION ; date ; whoami ; hostname ) > Version.c
	ed - Version.c < verscript.ed

#
# Include dependencies:
#

ambio.o colortab.o data.o devcomm.o \
devmain.o lookamb.o rview.o x11.o:	../common/color.h

freeobjmem.o o_cone.o srcsupp.o:	../common/cone.h

data.o freeobjmem.o m_brdf.o mx_data.o \
p_data.o raycalls.o t_data.o:	data.h

devcomm.o devmain.o devtable.o \
editline.o x11.o:	driver.h

freeobjmem.o o_face.o srcsupp.o:	../common/face.h

ambient.o raytrace.o rpmain.o rtmain.o \
rtrace.o rvmain.o rv2.o rv3.o:	../common/octree.h

o_instance.o:	../common/instance.h

ambient.o aniso.o ashikhmin.o dielectric.o freeobjmem.o func.o glass.o \
initotypes.o m_brdf.o m_bsdf.o m_direct.o m_mirror.o normal.o o_cone.o \
preload.o raycalls.o raytrace.o rtrace.o rv2.o source.o sphere.o \
srcsupp.o text.o srcdraw.o srcobstr.o virtuals.o:	../common/otypes.h

ambient.o ambcomp.o aniso.o ashikhmin.o normal.o raycalls.o raytrace.o \
rpict.o rvmain.o rtmain.o rpmain.o rcmain.o persist.o source.o rv3.o \
srcsamp.o virtuals.o:	../common/random.h

ambcomp.o ambient.o aniso.o ashikhmin.o dielectric.o freeobjmem.o func.o \
glass.o m_bsdf.o m_brdf.o m_clip.o m_direct.o m_mirror.o m_mist.o mx_data.o \
o_mesh.o mx_func.o normal.o o_cone.o o_face.o o_instance.o p_data.o p_func.o \
raycalls.o raypcalls.o rayfifo.o raytrace.o rpict.o rtrace.o rv2.o rv3.o rview.o \
source.o sphere.o srcdraw.o srcobstr.o srcsamp.o srcsupp.o t_data.o t_func.o \
text.o rpmain.o rtmain.o rvmain.o virtuals.o m_alias.o rcmain.o \
rcontrib.o rc2.o rc3.o:	ray.h \
../common/standard.h ../common/rtmisc.h ../common/rtio.h ../common/rtmath.h \
../common/rterror.h ../common/octree.h \
../common/mat4.h ../common/fvect.h ../common/object.h ../common/color.h

rv2.o rv3.o rview.o:	rpaint.h driver.h ../common/view.h ../common/resolu.h

m_direct.o m_mirror.o m_mist.o dielectric.o raycalls.o \
rpict.o rpmain.o rtmain.o rvmain.o rv2.o source.o srcdraw.o \
srcobstr.o srcsamp.o srcsupp.o virtuals.o:	source.h

cone.o data.o devcomm.o initotypes.o fprism.o preload.o \
duphead.o octree.o:	../common/standard.h ../common/rtmisc.h \
../common/rtio.h ../common/rtmath.h \
../common/rterror.h ../common/mat4.h ../common/fvect.h

ambio.o:	../common/fvect.h

ambient.o initotypes.o srcobstr.o raytrace.o:	otspecial.h

rpmain.o rtmain.o rvmain.o rpict.o \
srcdraw.o:	../common/view.h ../common/resolu.h

rpict.o:	../common/hilbert.h

x11.o x11twind.o: x11twind.h

x11.o:	x11icon.h

ambient.o ambcomp.o ambio.o lookamb.o raycalls.o:	ambient.h

data.o rpmain.o rtmain.o rvmain.o rpict.o rtrace.o \
rv2.o:	../common/resolu.h

aniso.o func.o m_brdf.o m_direct.o mx_data.o mx_func.o p_data.o \
p_func.o t_data.o t_func.o:	func.h ../common/calcomp.h

preload.o:	data.h func.h ../common/object.h ../common/face.h \
../common/cone.h ../common/instance.h ../common/mesh.h \
../common/color.h ../common/bsdf.h ../common/otypes.h

rtmain.o rpmain.o rvmain.o persist.o duphead.o \
renderopts.o rpict.o:	../common/paths.h

freeobjmem.o raycalls.o text.o:	../common/font.h

raypcalls.o:	../common/selcall.h

o_mesh.o:	../common/mesh.h

noise3.o:	../common/calcomp.h

aniso.o ashikhmin.o dielectric.o freeobjmem.o glass.o initotypes.o \
m_alias.o m_brdf.o m_clip.o m_direct.o m_mirror.o m_mist.o \
mx_data.o mx_func.o normal.o o_cone.o o_face.o o_instance.o \
o_mesh.o p_data.o p_func.o source.o sphere.o t_data.o t_func.o \
srcobstr.o text.o:		rtotypes.h

m_bsdf.o:	ambient.h source.h func.h \
../common/calcomp.h ../common/bsdf.h ../common/random.h

rcmain.o rcontrib.o rc2.o rc3.o:	rcontrib.h \
../common/platform.h ../common/paths.h ../common/lookup.h \
func.h ../common/calcomp.h ../common/rtprocess.h

ambient.o rcmain.o:	source.h ambient.h

rcontrib.o:	source.h ../common/otypes.h

rc2.o:	../common/resolu.h

rc3.o:	../common/selcall.h

#
# Photon map include dependencies (via 'gcc -MM -I../common')
#
ambient.o: pmapparm.h pmaptype.h pmapamb.h pmapdata.h

dielectric.o glass.o normal.o m_brdf.o m_bsdf.o ashikhmin.o aniso.o: \
   pmapparm.h pmaptype.h pmapmat.h pmap.h pmapdata.h
   
raycalls.o rpmain.o rcmain.o rtmain.o rvmain.o: \
   pmapparm.h pmaptype.h pmapray.h
   
rcmain.o: pmapparm.h pmaptype.h pmapray.h pmapcontrib.h pmapdata.h
   
raytrace.o: pmapparm.h pmaptype.h pmap.h pmapdata.h

renderopts.o: pmapparm.h pmaptype.h pmapopt.h

rpict.o: pmapparm.h pmaptype.h pmapbias.h pmapdata.h pmapdiag.h

source.o: pmapparm.h pmaptype.h pmap.h pmapdata.h pmapsrc.h

pmapamb.o: pmapamb.c pmapamb.h pmapdata.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h ../common/lookup.h pmap.h

pmapbias.o: pmapbias.c pmapbias.h pmapdata.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h ../common/lookup.h pmap.h \
 pmaprand.h

pmap.o: pmap.c pmap.h pmapparm.h pmaptype.h pmapdata.h ray.h \
 ../common/standard.h ../common/copyright.h ../common/rtio.h \
 ../common/rtmisc.h ../common/rtmath.h ../common/tiff.h ../common/mat4.h \
 ../common/fvect.h ../common/rterror.h ../common/octree.h \
 ../common/object.h ../common/color.h ../common/paths.h \
 ../common/lookup.h pmapkdt.h pmapooc.h pmapmat.h pmapsrc.h source.h pmaprand.h \
 pmapio.h pmapbias.h pmapdiag.h ../common/platform.h ../common/otypes.h

pmapcontrib.o: pmapcontrib.c pmapcontrib.h pmapdata.h ray.h \
 ../common/standard.h ../common/copyright.h ../common/rtio.h \
 ../common/rtmisc.h ../common/rtmath.h ../common/tiff.h ../common/mat4.h \
 ../common/fvect.h ../common/rterror.h ../common/octree.h \
 ../common/object.h ../common/color.h pmapparm.h pmaptype.h \
 ../common/paths.h ../common/lookup.h pmapkdt.h pmapooc.h pmapmat.h pmap.h \
 pmapsrc.h source.h pmaprand.h pmapio.h pmapdiag.h ../common/platform.h \
 rcontrib.h ../common/rtprocess.h ../common/paths.h func.h \
 ../common/calcomp.h ../common/otypes.h

pmapdata.o: pmapdata.c pmapdata.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h ../common/paths.h \
 ../common/lookup.h pmapkdt.h pmapooc.h pmaprand.h pmapmat.h pmap.h \
 ../common/otypes.h source.h rcontrib.h ../common/platform.h \
 ../common/rtprocess.h ../common/paths.h func.h ../common/calcomp.h \
 ../common/random.h pmapkdt.c pmapooc.c

pmapdiag.o: pmapdiag.c pmapdiag.h ../common/platform.h pmapdata.h ray.h \
 ../common/standard.h ../common/copyright.h ../common/rtio.h \
 ../common/rtmisc.h ../common/rtmath.h ../common/tiff.h ../common/mat4.h \
 ../common/fvect.h ../common/rterror.h ../common/octree.h \
 ../common/object.h ../common/color.h pmapparm.h pmaptype.h \
 ../common/lookup.h

pmapdump.o: pmapdump.c pmapio.h pmapdata.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h ../common/lookup.h \
 ../common/rtio.h ../common/resolu.h

pmapio.o: pmapio.c pmapio.h pmapdata.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h ../common/paths.h \
 ../common/lookup.h pmapkdt.h pmapooc.h pmapdiag.h ../common/platform.h \
 ../common/resolu.h

pmapmat.o: pmapmat.c pmapmat.h pmap.h pmapparm.h pmaptype.h pmapdata.h \
 ray.h ../common/standard.h ../common/copyright.h ../common/rtio.h \
 ../common/rtmisc.h ../common/rtmath.h ../common/tiff.h ../common/mat4.h \
 ../common/fvect.h ../common/rterror.h ../common/octree.h \
 ../common/object.h ../common/color.h ../common/lookup.h pmaprand.h \
 ../common/otypes.h data.h func.h ../common/calcomp.h ../common/bsdf.h \
 ../common/ccolor.h

pmapopt.o: pmapopt.c pmapparm.h pmaptype.h ../common/rtio.h \
 ../common/rterror.h

pmapparm.o: pmapparm.c pmapparm.h pmaptype.h pmapdata.h ray.h \
 ../common/standard.h ../common/copyright.h ../common/rtio.h \
 ../common/rtmisc.h ../common/rtmath.h ../common/tiff.h ../common/mat4.h \
 ../common/fvect.h ../common/rterror.h ../common/octree.h \
 ../common/object.h ../common/color.h ../common/paths.h \
 ../common/lookup.h pmapkdt.h pmapooc.h

pmapray.o: pmapray.c pmapray.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h pmap.h pmapdata.h \
 ../common/lookup.h

pmapsrc.o: pmapsrc.c pmapsrc.h ray.h ../common/standard.h \
 ../common/copyright.h ../common/rtio.h ../common/rtmisc.h \
 ../common/rtmath.h ../common/tiff.h ../common/mat4.h ../common/fvect.h \
 ../common/rterror.h ../common/octree.h ../common/object.h \
 ../common/color.h pmapparm.h pmaptype.h source.h pmap.h pmapdata.h \
 ../common/lookup.h pmaprand.h ../common/otypes.h

pmutil.o:	pmap.h pmapio.h pmapdata.h pmapparm.h pmaptype.h pmapbias.h \
  ../common/otypes.h

pmaptype.o: pmaptype.c pmaptype.h

mkpmap.o: mkpmap.c pmap.h pmapparm.h pmaptype.h pmapdata.h ray.h \
 ../common/standard.h ../common/copyright.h ../common/rtio.h \
 ../common/rtmisc.h ../common/rtmath.h ../common/tiff.h ../common/mat4.h \
 ../common/fvect.h ../common/rterror.h ../common/octree.h \
 ../common/object.h ../common/color.h ../common/paths.h \
 ../common/lookup.h pmapkdt.h pmapooc.h pmapmat.h pmapcontrib.h pmaprand.h \
 ambient.h ../common/resolu.h source.h
      
oococt.o: oococt.c oococt.h oocsort.h ooccache.h \
 ../common/rtio.h ../common/fvect.h

ooccache.o: ooccache.c ooccache.h

oocsort.o: oocsort.c oocsort.h ../common/fvect.h

oocbuild.o: oocbuild.c oocbuild.h oocsort.h oococt.h

oocnn.o: oocnn.c oocnn.h oococt.h oocsort.h
