#
#  cad/rt -- Example Ray-Tracing Programs, with Lighting Models
#
#  Source -
#	SECAD/VLD Computing Consortium, Bldg 394
#	The U. S. Army Ballistic Research Laboratory
#	Aberdeen Proving Ground, Maryland  21005
#  
#  Copyright Notice -
#	This software is Copyright (C) 1985 by the United States Army.
#	All rights reserved.

PRODUCT=rt rtray rtpp

#
#  Compiler flags.  Optimization ("-O") suggested all the time.
#  For benchmarks, include "-DBENCHMARK" to supress penumbra, etc.
CFLAGS=-O	### -DBENCHMARK

#
#  Frame buffer library.  Choose one of:
#	libfb-ik.o /usr/brl/lib/libik.a		Compat. with old IK library
#	/usr/brl/lib/libfb.a			Current FB library
#	/usr/brl/lib/librfb.a			Remote network FB library
#	libfb-dummy.o				Stub for no FB at all
#	libfb-iris.o				SGI IRIS FB library
FBLIB=libfb-dummy.o

# Place RT library is found
RTLIB=../librt/librt.a 

LIBS=-lm

# Place programs get installed
BINDIR=/usr/brl/bin

# Place to find #include <> files
INCLUDE=/usr/include

CAD_HDRS =	../h/machine.h ../h/db.h ../h/mater.h \
		../h/raytrace.h ../h/vmath.h

APPL_SRCS = text.c cloud.c rt.c view.c viewpp.c viewray.c \
	material.c plastic.c

all:	$(PRODUCT)

$(RTLIB):
	cd ../librt; make

rt:	Makefile rt.o text.o cloud.o view.o wray.o \
		material.o plastic.o \
		$(RTLIB_HDRS) $(RTLIB)
	$(CC) $(CFLAGS) text.o cloud.o rt.o view.o wray.o \
		material.o plastic.o \
		$(RTLIB) $(LIBS) $(FBLIB) -o rt

rtray:	Makefile rt.o viewray.o wray.o $(RTLIB_HDRS) $(RTLIB)
	$(CC) $(CFLAGS) rt.o viewray.o wray.o $(RTLIB) $(LIBS) -o rtray

rtpp:	Makefile rt.o viewpp.o wray.o $(RTLIB_HDRS) $(RTLIB)
	$(CC) $(CFLAGS) rt.o viewpp.o wray.o $(RTLIB) $(LIBS) -o rtpp

lint:	$(CAD_HDRS) $(RTLIB_HDRS) $(APPL_SRCS)
#	lint -haxc 	$(APPL_SRCS)  >rt.lint
	/usr/5bin/lint 	$(APPL_SRCS)  >rt.lint

install: $(PRODUCT)
	-mv -f $(BINDIR)/rt $(BINDIR)/rt.bak
	mv rt $(BINDIR)
	-mv -f $(BINDIR)/rtray $(BINDIR)/rtray.bak
	mv rtray $(BINDIR)
	-mv -f $(BINDIR)/rtpp $(BINDIR)/rtpp.bak
	mv rtpp $(BINDIR)
	chmod 644 ../dist/h/*.h
	cp $(CAD_HDRS) ../dist/h/.
	cp Makefile *.h *.c ../dist/rt/.

print: $(CAD_HDRS) $(APPL_SRCS)
	pr $(CAD_HDRS) $(APPL_SRCS) | qpr

tags:	$(APPL_SRCS)
	ctags $(APPL_SRCS)

clean:
	rm -f *.o *~ core

clobber: clean
	rm -f $(PRODUCT)

#
#  #include dependencies
#
depend:
	for k in $(RTLIB_SRCS) $(APPL_SRCS); do \
		i=`basename $$k .c`; \
		(echo $$i.o: $$i.c >>makedep; \
		grep '^#include' /dev/null $$i.c | sed \
			-e 's,c:[^"]*"\./\([^"]*\)".*,o: \1,' \
			-e 's,c:[^"]*"/\([^"]*\)".*,o: /\1,' \
			-e 's,c:[^"]*"\([^"]*\)".*,o: \1,' \
			-e '/debug.h/d' \
			-e "s,c:[^<]*<\(.*\)>.*,o: $(INCLUDE)/\1," \
			>>makedep); done
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	echo '# see make depend above' >> Makefile

# DO NOT DELETE THIS LINE  -- make depend uses it
# DEPENDENCIES MUST END AT END OF FILE
text.o: text.c
text.o: /usr/include/stdio.h
text.o: ../h/machine.h
text.o: ../h/vmath.h
text.o: ../h/raytrace.h
cloud.o: cloud.c
cloud.o: /usr/include/stdio.h
cloud.o: /usr/include/math.h
cloud.o: ../h/machine.h
cloud.o: ../h/vmath.h
cloud.o: ../h/raytrace.h
rt.o: rt.c
rt.o: /usr/include/stdio.h
rt.o: ../h/machine.h
rt.o: ../h/vmath.h
rt.o: ../h/raytrace.h
view.o: view.c
view.o: /usr/include/stdio.h
view.o: /usr/include/math.h
view.o: ../h/machine.h
view.o: ../h/vmath.h
view.o: ../h/mater.h
view.o: ../h/raytrace.h
viewpp.o: viewpp.c
viewpp.o: /usr/include/stdio.h
viewpp.o: ../h/machine.h
viewpp.o: ../h/vmath.h
viewpp.o: ../h/raytrace.h
viewray.o: viewray.c
viewray.o: /usr/include/stdio.h
viewray.o: ../h/machine.h
viewray.o: ../h/vmath.h
viewray.o: ../h/raytrace.h
material.o: material.c
material.o: /usr/include/stdio.h
material.o: ../h/machine.h
material.o: ../h/vmath.h
material.o: ../h/raytrace.h
plastic.o: plastic.c
plastic.o: /usr/include/stdio.h
plastic.o: /usr/include/math.h
plastic.o: ../h/machine.h
plastic.o: ../h/vmath.h
plastic.o: ../h/mater.h
plastic.o: ../h/raytrace.h
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
