
#FILESUFFIXES 
CC=cc  
YACC=yacc -d
LEX=lex
L=a
O  = .o

#rpcgen available ?
RPCGEN=norpcgen
#RPCGEN=rpcgen

PROGRAM=-DRAYSHADE40
RPC=-DONCRPC
GRAPHIC=-DX11

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

LIBTEXTOBJ   = blotch.o bump.o checker.o cloud.o fbm.o fbmbump.o \
gloss.o  imagetex.o mapping.o marble.o mount.o noise.o \
sky.o    stripe.o textaux.o texture.o windy.o wood.o $(H_TEXOBJ)

LIBOBJOBJ    = blob.o bounds.o box.o cone.o csg.o cylinder.o disc.o \
grid.o hf.o instance.o list.o intersec.o geom.o       \
plane.o poly.o roots.o sphere.o torus.o triangle.o

LIBLIGHTOBJ  = light.o extended.o infinite.o jittered.o point.o       \
               shadow.o spot.o

LIBCOMMONOBJ = memory.o expr.o transfor.o rotate.o sampling.o scale.o \
               translat.o vecmath.o 
LIBSURFOBJ   = atmosphe.o fog.o fogdeck.o mist.o surface.o surfshad.o 

LIBSHADEOBJ  =setup.o viewing.o shade.o picture.o builtin.o symtab.o \
misc.o lightdef.o objdef.o options.o stats.o surfdef.o

LIBIMAGEOBJ  =image.o  u_vaxsho.o u_addhis.o u_f2exp.o u_putrow.o u_getraw.o \
u_row_al.o u_getrow.o u_global.o u_runput.o \
u_getcom.o u_putcom.o u_raw_al.o u_svlinb.o u_getski.o


RAYLIBS      =libshade.$(L) libtext.$(L) libtext.$(L) libobj.$(L) \
liblight.$(L) libcommon.$(L) libsurf.$(L) libimage.$(L) librr/libRR.$(L)
RUNLIBS      = -lc -lm -lX11 -ll


RAYOBJS = main.o raytrace.o ray40lex.o  ray40tab.o version.o machine.o  
RPCOBJS =    prog_xdr.o progspec.o 

DEB=-O
OPT=-O4
FLAGS= -c -I. #$(GRAPHIC) 
CFLAGS=  $(FLAGS) $(DEB) -D_BSD -I./librr
CFL=$(FLAGS)


ray: $(RPCOBJS) $(RAYOBJS) $(RAYLIBS)  
	$(CC) -o ray  $(RPCOBJS) $(RAYOBJS) $(RAYLIBS) $(RUNLIBS)

prog_xdr.c : prog.x progspec.h config.h
	$(RPCGEN) prog.x

prog_xdr.o : prog_xdr.c prog.h 

libRR.$(L): $(LIBRROBJ)
	ar  cur  libRR.$(L)  $(LIBRROBJ)   
	ranlib libRR.$(L)
	

libobj.$(L)    : $(LIBOBJOBJ) 
#	oml -v libobj.$(L) REPLACE $(LIBOBJOBJ)  
	 ar  cur  libobj.$(L)  $(LIBOBJOBJ)   
	ranlib libobj.$(L)
liblight.$(L)  : $(LIBLIGHTOBJ) 
#	oml -v liblight.$(L) REPLACE $(LIBLIGHTOBJ) 
	 ar  cur liblight.$(L)  $(LIBLIGHTOBJ)  
	ranlib liblight.$(L)

libcommon.$(L) : $(LIBCOMMONOBJ) 
#	oml -v libcommon.$(L) REPLACE $(LIBCOMMONOBJ) 
	 ar  cur libcommon.$(L)  $(LIBCOMMONOBJ)  
	ranlib libcommon.$(L)

libsurf.$(L)   : $(LIBSURFOBJ) 
#	oml -v libsurf.$(L) REPLACE $(LIBSURFOBJ) 
	 ar  cur libsurf.$(L)  $(LIBSURFOBJ)  
	ranlib libsurf.$(L)

libshade.$(L)  : $(LIBSHADEOBJ) 
#	oml -v libshade.$(L) REPLACE $(LIBSHADEOBJ) 
	 ar  cur libshade.$(L)  $(LIBSHADEOBJ)  
	ranlib libshade.$(L)

libimage.$(L)  : $(LIBIMAGEOBJ)
#	oml -v libimage.$(L) REPLACE $(LIBIMAGEOBJ)
	 ar  cur libimage.$(L)  $(LIBIMAGEOBJ)  
	ranlib libimage.$(L)

libtext.$(L)   : $(LIBTEXTOBJ)
#	oml -v libtext.$(L) REPLACE $(LIBTEXTOBJ)
	 ar  cur libtext.$(L)  $(LIBTEXTOBJ)  
	ranlib libtext.$(L)


rrpc_xdr.o : rrpc_xdr.c 

atmosphe.o : atmosphe.c atmosphe.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h
blob.o : blob.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h blob.h
blotch.o : blotch.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h blotch.h
bounds.o : bounds.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h
box.o : box.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h box.h
builtin.o : builtin.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h
bump.o : bump.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h bump.h
checker.o : checker.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h checker.h
cloud.o : cloud.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h cloud.h
cone.o : cone.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h cone.h
csg.o : csg.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h csg.h
cylinder.o : cylinder.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  cylinder.h
disc.o : disc.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h disc.h
expr.o : expr.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h
extended.o : extended.c light.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  sampling.h extended.h
fbm.o : fbm.c texture.h geom.h common.h  \
       config.h expr.h vector.h ray.h transfor.h error.h bounds.h \
  surface.h mapping.h fbm.h

fbmbump.o : fbmbump.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h fbm.h fbmbump.h
fog.o : fog.c atmosphe.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h fog.h
fogdeck.o : fogdeck.c atmosphe.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h fogdeck.h
geom.o : geom.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h list.h sampling.h
gloss.o : gloss.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h gloss.h
grid.o : grid.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h grid.h
hf.o : hf.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h hf.h
image.o : image.c  common.h  \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h image.h
imagetex.o : imagetex.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h image.h imagetex.h
infinite.o : infinite.c light.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  infinite.h
instance.o : instance.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  instance.h
intersec.o : intersec.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h
jittered.o : jittered.c light.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  jittered.h
lexray40.o : lexray40.c  config.h rayshade.h geom.h common.h \
  expr.h vector.h ray.h \
  color.h transfor.h error.h bounds.h funcdefs.h  \
  light.h atmosphe.h surface.h texture.h mapping.h symtab.h ray40.tab.h
light.o : light.c light.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h
lightdef.o : lightdef.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   options.h \
  light.h infinite.h jittered.h
list.o : list.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h list.h

main.o : main.c rayshade.h geom.h common.h config.h expr.h vector.h ray.h \
         color.h transfor.h error.h bounds.h funcdefs.h options.h stats.h \
         viewing.h picture.h 

mapping.o : mapping.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  mapping.h
marble.o : marble.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h marble.h
memory.o : memory.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h
misc.o : misc.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   \
  options.h stats.h
mist.o : mist.c atmosphe.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h mist.h
mount.o : mount.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h mount.h

noise.o : noise.c common.h config.h expr.h vector.h ray.h color.h \
          transfor.h error.h

objdef.o : objdef.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   options.h \
  stats.h
options.o : options.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   options.h \
  stats.h viewing.h
picture.o : picture.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   picture.h \
  viewing.h options.h stats.h
plane.o : plane.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h plane.h
point.o : point.c light.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h point.h
poly.o : poly.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h poly.h
raytrace.o : raytrace.c rayshade.h geom.h common.h  config.h \
  expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   atmosphe.h surface.h sampling.h options.h stats.h\
  raytrace.h picture.h viewing.h 
roots.o : roots.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h
rotate.o : rotate.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h rotate.h
sampling.o : sampling.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h sampling.h
scale.o : scale.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h scale.h
setup.o : setup.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   defaults.h \
  surface.h atmosphe.h light.h infinite.h list.h options.h stats.h \
  viewing.h picture.h
shade.o : shade.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   texture.h \
  surface.h mapping.h light.h atmosphe.h options.h stats.h
shadow.o : shadow.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h light.h
sky.o : sky.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h sky.h
sphere.o : sphere.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  sphere.h
spot.o : spot.c light.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h spot.h
stats.o : stats.c rayshade.h geom.h common.h \
     \
   config.h expr.h vector.h ray.h color.h \
  transfor.h error.h bounds.h funcdefs.h  \
   options.h stats.h
stripe.o : stripe.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h stripe.h
surface.o : surface.c atmosphe.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h surface.h
surfdef.o : surfdef.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   surface.h
surfshad.o : surfshad.c geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h
symtab.o : symtab.c rayshade.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   symtab.h \
  builtin.h
textaux.o : textaux.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h
texture.o : texture.c texture.h geom.h common.h  \
     \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  surface.h mapping.h
torus.o : torus.c geom.h common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h bounds.h torus.h
transfor.o : transfor.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h
translat.o : translat.c common.h   \
    config.h expr.h \
  vector.h ray.h color.h transfor.h error.h translat.h

triangle.o : triangle.c geom.h common.h config.h expr.h vector.h ray.h \
	    color.h transfor.h error.h bounds.h triangle.h
vecmath.o : vecmath.c common.h config.h expr.h vector.h ray.h color.h \
	    transfor.h error.h
version.o : version.c rayshade.h geom.h common.h config.h expr.h vector.h \
            ray.h color.h transfor.h error.h bounds.h funcdefs.h patchlev.h \
            stats.h

viewing.o : viewing.c rayshade.h geom.h common.h  \
       config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
       funcdefs.h   viewing.h  sampling.h options.h defaults.h picture.h \
       stats.h

windy.o : windy.c texture.h geom.h common.h  \
       config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
       surface.h mapping.h windy.h

wood.o : wood.c texture.h geom.h common.h  \
       config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
       surface.h mapping.h wood.h


machine.o : machine.c

u_vaxshow.o : u_vaxshow.c 
u_row_al.o  : u_row_al.c u_.h u_config.h 
u_getrow.o  : u_getrow.c u_.h u_config.h u_code.h 
u_svlinb.o  : u_svlinb.c 
u_f2exp.o   : u_f2exp.c  u_.h u_config.h  
u_addhis.o  : u_addhis.c u_.h u_config.h  
u_raw_al.o  : u_raw_al.c u_.h u_config.h u_raw.h u_code.h 
u_getraw.o  : u_getraw.c u_.h u_config.h u_raw.h u_code.h 
u_getski.o  : u_getski.c u_.h u_config.h u_code.h 
u_putcom.o  : u_putcom.c u_.h u_config.h 
u_runput.o  : u_runput.c u_.h u_config.h u_code.h u_put.h 
u_putrow.o  : u_putrow.c u_.h u_config.h u_put.h 
u_getcom.o  : u_getcom.c u_.h u_config.h 
u_global.o  : u_global.c u_.h u_config.h u_put.h 

rpcspec.o   : rpcspec.c rpcspec.h

ray40lex.c  : ray40.l config.h rayshade.h geom.h common.h expr.h \
              vector.h ray.h color.h transfor.h error.h bounds.h \
              funcdefs.h light.h atmosphe.h surface.h texture.h \
              mapping.h symtab.h ray40tab.c y.tab.h
	$(LEX)  ray40.l  
	echo >ray40lex.c
	rm ray40lex.c
	mv lex.yy.c ray40lex.c

ray40lex.o  : ray40lex.c 

ray40tab.c : ray40.y rayshade.h geom.h common.h  \
  config.h expr.h vector.h ray.h color.h transfor.h error.h bounds.h \
  funcdefs.h   symtab.h \
  builtin.h atmosphe.h surface.h texture.h mapping.h image.h light.h \
  options.h stats.h viewing.h blob.h box.h cone.h csg.h cylinder.h disc.h \
  grid.h hf.h instance.h list.h plane.h poly.h sphere.h torus.h triangle.h \
  point.h infinite.h spot.h jittered.h extended.h blotch.h bump.h checker.h \
  cloud.h fbm.h fbmbump.h gloss.h imagetex.h marble.h mount.h sky.h stripe.h \
  windy.h wood.h fog.h fogdeck.h mist.h rotate.h scale.h translat.h
	$(YACC) ray40.y
	mv y.tab.c ray40tab.c
clean:
	rm *.a *.o core ray prog.h prog_xdr.c prog_clnt.c prog_svc.c ray40tab.c ray40lex.c y.tab.h 
