
#
#	Author	: Sreedhar Sivakumaran
#	Purpose	: Build dtm modules for various targets.
#	Notes	:
#
#		Environment variable(s) to be pre-defined -  
#
#		1. DTMRCS - should be defined as the RCS library
#		   for the DTM files.
#
#		2. DTMSRC - should be defined as the directory 
#		   where all the dtm source files are to be available
#		   on being fetched from DTMRCS. 
#
#		3. DTMMOD - should be defined as the directory where
#		   the DTM module(s) should be built for the given node.
#
#		Associated files are makedtm and getdtm.
#		A typical dtm module generation sequence would be -
#
#		1. Fetch builddtm, makedtm, getdtm from the library 
#		   DTMRCS into the directory DTMSRC.
#
#		2. Execute getdtm in the directory DTMSRC - it
#		   will fetch all other files from DTMRCS.
#
#		3. At each target node, copy builddtm, makedtm and source
#		   files and execute builddtm in the DTMMOD directory, after
#		   chmod +x builddtm makedtm.
#
#		Other points -
#	
#		1. -DSUN is flag for sun machines. Similarly -DSGI, -DDEC and so on.
#		   However, flag is -DRS6000 for ibm machine.
#
#		2. For Cray, both libdtm.a and libdtmf77.a are built.
#

OBJ="dtminit.o dtm.o dtmmisc.o socket.o rwrtns.o fatal.o sds.o sdl.o ris.o dtmnserv.o ninit.o nmsg.o"

echo "			Building module for" $1

chmod +x makedtm

case $1 in
	sun)
		make -f makedtm libdtm.a "CFLAGS = -DSUN" "OBJECTS = $OBJ convert.o mdd.o" \
		"ARCHIVE = ar cr" "DTMK = $DTMSRC" ;
		ranlib libdtm.a ;;
	convex)
		make -f makedtm "CFLAGS = -DCONVEX -fi" "OBJECTS = $OBJ mdd.o convert.o" "ARCHIVE = ar cr" \
		"DTMK = $DTMSRC" ;;
	ibm)	
		make -f makedtm "CFLAGS = -DRS6000" "OBJECTS = $OBJ mdd.o convert.o" "ARCHIVE = ar cr" "DTMK = $DTMSRC" ;;
	sgi)	
		make -f makedtm "CFLAGS = -DSGI -I/usr/include/sun -I/usr/include/bsd" "OBJECTS = $OBJ convert.o" \
		"ARCHIVE = ar cr" "DTMK = $DTMSRC" ;;
	dec)
		make -f makedtm "CFLAGS = -DDEC" "OBJECTS = $OBJ mdd.o deccvt.o" "ARCHIVE = ar cr" "DTMK = $DTMSRC" ;;
	vax)
		make -f makedtm "CFLAGS = -DVAX" "OBJECTS = $OBJ mdd.o vaxcvt.o" "ARCHIVE = ar cr" "DTMK = $DTMSRC" ;;
	cray)	
		make -f makedtm "CFLAGS = -DCRAY" "CFT = cft77" "OBJECTS = $OBJ craycvt.o crayrtns.o" \
		"ARCHIVE = bld q" "DTMK = $DTMSRC" ; 
		make -f makedtm libdtmf77.a "CFLAGS = -DCRAY" "CFT = cft77" "OBJECTS = $OBJ craycvt.o crayrtns.o" \
		"ARCHIVE = bld q" "DTMK = $DTMSRC" ;; 
	*)
		echo "Unknown node" $1 ;;  
esac
