# sliplogin 2.1.0 Makefile
#
# $Id: Makefile,v 1.1 1996/04/28 15:53:48 ping Exp ping $
#
# description of (hopefully) all options, see README*
#
# -DDYNAMIC_SERVER	always assume dynamic allocation of local (server) 
#			address (ignore contents of server field, replace 
#			 with the ip-address of the real hostname.)
# -DSLIPPATH=\"/etc\"	use /etc instead of /etc/slip for all config files
#
# -DFUNMESSAGE		Captain kirk's special message format
# -DOLDMESSAGE		realtivly old message format
# -DBSDMESSAGE		use old FreeBSD message format 'slip login for'
# -DCONFIGURE_MSG=1	report about dynamic configuration
# 
# -DESLIPLOGIN		to perform extended logins (see README.esliplogin)
#			 (without you may exclude sliplogin.o from binary)
# -DESLIP_AUTO		enable autocompression by default
# -DESLIP_TIMEOUT=#seconds	time for login (defaults to 180 seconds)
#
# -DLINE_ACCESS		special library to restrict the access to special 
#			lines (Phone - numbers) or a limited time.

# path for configuration files and to install binaries / manpages
SLIP	= /etc/slip
SBIN	= /usr/local/sbin
MAN	= /usr/local/man

VERSION	= 2.1.0

CC	= gcc
LINK	= $(CC)
CFLAGS	= -O2 -pipe -fomit-frame-pointer -m486 #-Wall
EFLAGS	= -DESLIPLOGIN -DESLIP_AUTO
DEFINES	= -DSLIPPATH=\"$(SLIP)\" $(EFLAGS)
LDFLAGS = -s

# if you want to use the access library just uncomment the following lines
#  and define -DLINE-ACCESS in EFLAGS above; 
#  than type 'make all', 'make install_all'
EACCESS	= -DLINE_ACCESS access.o
EOBJ	= access.o access_test express check_access watch_access

#SRC = sliplogin.c statistic.c scanfile.c translate.c
SRC = sliplogin.c statistic.c scanfile.c translate.c esliplogin.c
OBJ = $(SRC:.c=.o)
#LIBS = -lshadow	# for Linux with shadow passwd
#LIBS = -lutil		# for FreeBSD 1.x
#LIBS = -lkvm		# for FreeBSD 2.x

FILES	= README README.nis README.dynamic README.esliplogin \
	  CHANGES TODO TROUBLE_SHOOTING passwd.example \
	  Makefile sliplogin.h pathnames.h scanfile.h ${SRC} slip.* \
	  sliplogin.8

FACCESS = README.access access.c access.h todo.conf \
	  lines.conf linetest.conf waccess.c uucp ppp

#
#You should really edit /etc/group to limit access to sliplogin
#otherwise sliplogin has to be executable for the world.
#
SLIPGROUP = slip

TARGETS = access sliplogin

sliplogin: $(OBJ) 
	$(LINK) $(OBJ) $(EACCESS) $(LIBS) $(LDFLAGS) -o $@

all: $(TARGETS)
	@echo done

clean:
	rm -f *.o sliplogin $(EOBJ) core 

install: install_slip
	@true

install_all: install_slip install_access
	@true

#	if you get an error 'text file busy' while installing
#	move the old binary to another name

install_slip: sliplogin
	install -m4754 sliplogin $(SBIN)
	@if [ -f sliplogin.8 ]; then \
	   install -m644 sliplogin.8 $(MAN)/man8; fi
	chgrp $(SLIPGROUP) $(SBIN)/sliplogin
	touch $(SLIP)/.hushlogin
	@if [ ! -f $(SLIP)/slip.login ]; then \
	  echo install -m755 slip.login $(SLIP); \
	  install -m755 slip.login $(SLIP); \
	  ln -s slip.login $(SLIP)/slip.logout; \
	else \
	 echo "WARNING: with version $(VERSION) comes a new slip.login," 1>&2;\
	 echo "	because the argument list has been changed." 1>&2;\
	fi
	@echo "Don't forget to edit slip.hosts, slip.route, slip.passwd"
	@echo "and copy these files to the proper place ($(SLIP))."

# Line access (see README.access)
access:	$(EOBJ)
	@true

access_test: access.c
	gcc -o access_test $(CFLAGS) -DACCESS_MAIN -DSTDERR -DOUTPUT access.c

express: access.c
	gcc -o express $(CFLAGS) -DEXPRESS_TEST -DOUTPUT access.c

check_access: access.c
	gcc -o check_access $(CFLAGS) -DCHECK_ACCESS access.c

watch_access: waccess.c access.o
	gcc -o watch_access $(CFLAGS) waccess.c access.o

install_access: check_access watch_access
	install -c -m 4555 -o root check_access $(SBIN)/check_access
	install -c -m 4555 -o root watch_access $(SBIN)/watch_access

depend:
	makedepend $(SRC)

dist: sliplogin-$(VERSION).tgz

sliplogin-$(VERSION).tgz: $(FILES) $(FACCESS)
	tar -czf sliplogin-$(VERSION).tgz $(FILES) $(FACCESS)

ci:
	ci -m"I hate log messages!" -t-"I hate description prompts!" -l $(SRC) Makefile

co:
	co $(SRC) Makefile

.c.o: 
	$(CC) $(CFLAGS) $(DEFINES) -c $<

