#
#	Makefile for layers 1.30
#

#	This software is 
#		Copyright (C) 1989-1993 by Eric C. Rosen and David W. Trissel.
#
#	Permission is granted to freely use, copy, modify, and redistribute
#	this software, provided that no attempt is made to gain profit from it,
#	the author is not construed to be liable for any results of using the
#	software, alterations are clearly marked as such, and this notice is
#	not modified.
#
#	The author makes no claims as to the fitness or correctness of this software
#	for any use whatsoever, and it is provided as is. Any use of this software
#	is at the user's own risk.

SHELL  = /bin/sh
MAKE   = /bin/make

#	If you want to use gcc, uncomment the following line:
# CC	   = gcc -pipe -g

BIN    = /usr/local
MANDIR = /usr/local/man/manl

MS     = l
CFLAGS = -O

default:
	@echo "                     MacLayers Unix-Side Installation"
	@echo "                              layers v1.30"
	@echo ""
	@echo "To build the Unix side of MacLayers in the current directory:"
	@echo ""
	@echo 'For SunOS prior to 4.1 and'
	@echo '      other BSD hosts:       % make oldsun'
	@echo 'For SunOS 4.1 and later:     % make sun'
	@echo 'For Sequent hosts:           % make sequent'
	@echo 'For Apple A/UX hosts:        % make aux'
	@echo 'For SGI/IRIX hosts:          % make irix'
	@echo 'For IBM RS/6000/AIX hosts:   % make rs6000'
	@echo 'For SVR4 hosts:              % make svr4'
	@echo 'For DEC/ULTRIX hosts:        % make ultrix'
	@echo 'For NeXT hosts:              % make NeXT'
	@echo ""
	@echo "To install MacLayers: (for system administrators or others who are"
	@echo "   [after building]    making layers available to a group of users)"
	@echo ""
	@echo "For setuid installation:     % make installsetuid"
	@echo "For non-setuid installation: % make installnosetuid"
	@echo "For an explanation of the major caveats of a non-setuid"
	@echo "installation:                % make installhelp"

installhelp:
	@echo "Implications of non-setuid installation are:"
	@echo ""
	@echo "1) As with any socket allocating utility your system may be"
	@echo "   *less* secure with this option if your kernel does not protect"
	@echo "   virtual tty's from cross user allocation and access. One"
	@echo "   hole is where the undead program of a disconnected user can be"
	@echo "   left attached to a socket and a later user allocate the same"
	@echo "   socket and receive continued output. Another is that any user"
	@echo "   can read/write to the virtual control terminals of a"
	@echo "   MacLayers user. (The reason for all this is that the layers"
	@echo "   utility cannot set the pseudo tty owner to the user.)"
	@echo ""
	@echo "2) If your utmp file is protected from user writes then"
	@echo "   users will not be able to do login shell windows (write and"
	@echo "   talk-like facilities will be unavailable and who-like commands"
	@echo "   may give inaccurate details.)"

all: layers layersize layertitle macbput

layers : layers.o protocol.o
	$(CC) $(CFLAGS) -o layers layers.o protocol.o $(LIBS)

layersize : layersize.o
	$(CC) $(CFLAGS) -o layersize layersize.o $(LIBS)

layertitle : layertitle.o
	$(CC) $(CFLAGS) -o layertitle layertitle.o $(LIBS)

macbput : macbput.o
	$(CC) $(CFLAGS) -o macbput macbput.o $(LIBS)

layers.o: layers.c layers.h
	$(CC) $(CFLAGS) $(FLAGS) -c layers.c

protocol.o: protocol.c layers.h
	$(CC) $(CFLAGS) $(FLAGS) -c protocol.c

layersize.o: layersize.c
	$(CC) $(CFLAGS) $(FLAGS) -c layersize.c

layertitle.o: layertitle.c
	$(CC) $(CFLAGS) $(FLAGS) -c layertitle.c

macbput.o: macbput.c macbput.h
	$(CC) $(CFLAGS) $(FLAGS) -c macbput.c

installsetuid: layers layersize layertitle macbput
	rm -f $(BIN)/layers
	rm -f $(BIN)/layersize
	rm -f $(BIN)/layertitle
	rm -f $(BIN)/macbput
	install -c -s -o root -g daemon -m 4711 layers $(BIN)/layers
	install -c -s layersize $(BIN)/layersize
	install -c -s layertitle $(BIN)/layertitle
	install -c -s macbput $(BIN)/macbput

installnosetuid: $(PGM) $(PGM2) $(PGM3) $(PGM4)
	rm -f $(BIN)/layers
	rm -f $(BIN)/layersize
	rm -f $(BIN)/layertitle
	rm -f $(BIN)/macbput
	install -c -s layers $(BIN)/layers
	install -c -s layersize $(BIN)/layersize
	install -c -s layertitle $(BIN)/layertitle
	install -c -s macbput $(BIN)/macbput

manpage: layers.1
	rm -f $(MANDIR)/layers.$(MS)
	rm -f $(MANDIR)/macbput.$(MS)
	cp layers.1 $(MANDIR)/layers.$(MS)
	cp macbput.1 $(MANDIR)/macbput.$(MS)
	chmod 664 $(MANDIR)/layers.$(MS)
	chmod 664 $(MANDIR)/macbput.$(MS)

clean:
	rm -f a.out core layers layersize layertitle macbput *.o

shar:
	mkdir 1.30
	cp	layers.c \
		protocol.c \
		layertitle.c \
		layersize.c \
		macbput.c \
		layers.h \
		macbput.h \
		layers.1 \
		layertitle.1 \
		layersize.1 \
		macbput.1 \
		MacLayers.doc \
		layersrc.doc \
		README \
		layersrc \
		macmouse.el \
		makefile	1.30
	shar -o layers130.shar `find 1.30 -print` 
	rm -r 1.30

#
# Make compiling easy on following systems:
#

oldsun:
	${MAKE} all

sun:
	${MAKE} FLAGS=-DPOSIXTTY all

aux:
	${MAKE} CC=gcc all

irix:
	${MAKE} FLAGS="-cckr -DSYSV -DIRIX" all

rs6000:
	${MAKE} FLAGS="-cckr -DSYSV -D_BSD -DAIX" all

svr4:
	${MAKE} FLAGS=-DSVR4 LIBS="-lsocket -lnsl" all	

ultrix:
	${MAKE} FLAGS=-DULTRIX all

sequent:
	${MAKE} FLAGS=-DSEQUENT all

NeXT:
	${MAKE} CC=gcc FLAGS=-bsd all
