# Makefile for remote troff stuff
# Steven D. Miller (steve@maryland.ARPA)
# 
# To make the remote troff execution package:
#
# (1) Install a "rtroff" account on your machines.  This account should
# 	live in its own group and have an asterisk in the password field
#	for security reasons.
#
# (2) Install the configuration files for rtroff and rcatdvi to use.  These
#	files are used when these two programs search for hosts to run
#	remote troffs on.  These files just look like a list of host-
#	names; one of ours is, for example,
#
#		gymble
#		gyre
#		tove
#		mimsy
#
#	Note that if a config file is on machine foo, foo should be
#	in that config file; if it is not, rtroff et al will *never*
#	run locally.  The config file for rtroff is /etc/rtrhosts,
#	and the one for rcatdvi is /etc/rcathosts; these might do
#	better living in /usr/local/lib or somewhere like that...
#
#	At the same time, the loadd configuration file (/etc/loadd.conf)
#	should be created.  Included is the one we use; look inside
#	it for details.
#
# (3) Add a line to /etc/rc.local so that the load daemon will be
#	started on the machines in /etc/rtrhosts at boot time.
#	Also, add the following line to your /etc/services file
#	on all those machines so that the daemon will run OK:
#	"load		701/udp				# load status daemon"
#	Note that the daemon uses syslog() to do its error logging;
#	I don't know how well syslog() works in 4.2, so you might
#	consider changing that (loadd is pretty much a hybrid 4.2/4.3
#	program, and seems to work OK on our 4.2 machines...)
#
# (4) We run MDQS as our printer spooler; if you are using the ltroff
#	shell script and are not running MDQS, you will need to change
#	the "qpr -q imagen-imp" stuff so that it spools to your imagen
#	in whatever way necessary.  Note also that we have some
#	security hacks in ltroff (users can't print on our imagens
#	unless they are listed in /etc/restrict/mdqs/ltroff_users)
#	that you may want to toss.  The other tuneable parameter in
#	the ltroff shell script is the "load" variable; this specifies
#	the load cutoff below which jobe will not be considered for
#	remote processing.  The "load" program is used to make
#	this decision; see its man entry for details.
#
# (5) Do a "make all" followed by a "make install" to compile everything
#	and put it into place.  Note that you should define BIN and ETC
#	to be something appropriate for your site.  There is conditional
#	code for Sun workstations in load and loadd; add a "-Dsun" to
#	the CFLAGS line below to use it.

CFLAGS = -O
LINTFLAGS = -hbux
SCRIPT = README Makefile getloads.c loadd.8l loadd.c ltroff ltroff.1 \
	rcatdvi.c rload.h rtroff.1l rtroff.c load.c load.1l loadd.conf

# BIN is the place you want these programs to live
BIN = /usr/local/bin

# ETC is the place you want the load daemon to live.
ETC = /etc

SRC = loadd.c rtroff.c rcatdvi.c getloads.c load.c

# MANS are the full pathnames for the installed man entries; if you want
# them to reside somewhere else, you'll have to change the names...
MANS  = /usr/man/man1/ltroff.1 /usr/man/man1/rtroff.1l \
	/usr/man/man1/load.1l /usr/man/man8/loadd.8l
MAN1DIR = /usr/man/man1
MAN8DIR = /usr/man/man8

PROGS = loadd rtroff rcatdvi ltroff load

# KMEM is a group id that can open /dev/kmem; the load program
# needs to be able to access /dev/kmem to do its stuff.
KMEM = bin


default: all

install: ${ETC}/loadd ${BIN}/rtroff ${BIN}/rcatdvi ${BIN}/ltroff \
	${BIN}/load man

${ETC}/loadd: loadd
	@echo "Don't forget to make the /etc/services entry for loadd"
	cp loadd ${ETC}/loadd
	chown root ${ETC}/loadd

${BIN}/rtroff: rtroff
	cp rtroff ${BIN}/rtroff
	chown root ${BIN}/rtroff
	chmod 4775 ${BIN}/rtroff
	-ln -s ${BIN}/rtroff ${BIN}/rnroff

${BIN}/rcatdvi: rcatdvi
	cp rcatdvi ${BIN}/rcatdvi
	chown root ${BIN}/rcatdvi
	chmod 4775 ${BIN}/rcatdvi

${BIN}/ltroff: ltroff
	cp ltroff ${BIN}/ltroff

${BIN}/load: load
	cp load ${BIN}/load
	chgrp ${KMEM} ${BIN}/load
	chmod g+s ${BIN}/load

loadd: loadd.o
	cc ${CFLAGS} -o loadd loadd.o

rtroff: rtroff.o getloads.o
	cc ${CFLAGS} -o rtroff rtroff.o getloads.o

rcatdvi: rcatdvi.o getloads.o
	cc ${CFLAGS} -o rcatdvi rcatdvi.o getloads.o

load: load.o
	cc ${CFLAGS} -o load load.o

getloads.o: rload.h

man: ${MANS}

${MAN1DIR}/ltroff.1: ltroff.1
	cp ltroff.1 ${MAN1DIR}

${MAN1DIR}/load.1l: load.1l
	cp load.1l ${MAN1DIR}

${MAN1DIR}/rtroff.1l: rtroff.1l
	cp rtroff.1l ${MAN1DIR}
	-ln -s ${MAN1DIR}/rtroff.1l ${MAN1DIR}/rnroff.1l

${MAN8DIR}/loadd.8l: loadd.8l
	cp loadd.8l ${MAN8DIR}

all: loadd rtroff rcatdvi load

clean:
	-rm *.o loadd rcatdvi rnroff rtroff load

shar: ${SCRIPT}
	makescript -t  -o rtroff.sh ${SCRIPT}

lint:
	lint ${LINTFLAGS} loadd.c
	lint ${LINTFLAGS} rtroff.c getloads.c
	lint ${LINTFLAGS} rcatdvi.c getloads.c
	lint ${LINTFLAGS} load.c

ci:
	ci ${VERSION} ${SCRIPT}

co:
	co ${VERSION} ${SCRIPT}
