# Makefile for lptools; 93.05.08.
#
# You must be root to execute make install and
# the target directories must exist
#
# BINDIR should be in your $PATH
#
TOOLDIR = /usr/local/lib
BINDIR  = /usr/sbin

LPSHELLS = lp lpstat lpkill
HPSHELLS = hp hpstat hpkill

lpx:	lpx.c
	cc lpx.c
	strip lpx

clean:
	rm -f $(HPSHELLS) lpx fixdir.sed install 2>/dev/null

fixdir.sed: Makefile
	echo '/LPTOOLS=/c\\' >fixdir.sed
	echo ': $${LPTOOLS=$(TOOLDIR)}' >>fixdir.sed

install: lpx $(LPSHELLS) fixdir.sed
	cp lpx $(TOOLDIR)/lpjob
	chgrp daemon $(TOOLDIR)/lpjob
	chown daemon $(TOOLDIR)/lpjob
	chmod 4111 $(TOOLDIR)/lpjob
	ln -f $(TOOLDIR)/lpjob $(TOOLDIR)/lpcmd
	ln -f $(TOOLDIR)/lpjob $(TOOLDIR)/lpcan	
	ln -f $(TOOLDIR)/lpjob $(TOOLDIR)/lpid
	ln -f $(TOOLDIR)/lpjob $(TOOLDIR)/rmlpid
	cp lp $(BINDIR)
	sed -f fixdir.sed lpstat >$(BINDIR)/lpstat
	sed -f fixdir.sed lpkill >$(BINDIR)/lpkill
	chgrp bin $(BINDIR)/lp $(BINDIR)/lpstat $(BINDIR)/lpkill
	chown bin $(BINDIR)/lp $(BINDIR)/lpstat $(BINDIR)/lpkill
	chmod 555 $(BINDIR)/lp $(BINDIR)/lpstat $(BINDIR)/lpkill
	ln -f $(BINDIR)/lp $(BINDIR)/hp
	ln -f $(BINDIR)/lpstat $(BINDIR)/hpstat
	ln -f $(BINDIR)/lpkill $(BINDIR)/hpkill
	touch install

# I'm not sure if these are all that useful ? you'll have make explicitly
#
lpshed: 
	ln -f $(BINDIR)/lpkill $(BINDIR)/lpshed

lpshut:
	ln -f $(BINDIR)/lpkill $(BINDIR)/lpshut

hpshed: 
	ln -f $(BINDIR)/lpkill $(BINDIR)/hpshed

hpshut:
	ln -f $(BINDIR)/lpkill $(BINDIR)/hpshut
