# @(#) Makefile 1.1 91/01/06 22:30:21
#	Original by: Wietse Venema
#	Modified by:
#	     31-Jan-91 by Willem Jan Withagen (wjw@eb.ele.tue.nl)
#		On Apollo systems it is possible to have three possible
#		environments. To have the program work, some compiler switches
#		are required. 
#		(Thanks are also due to Charles Fuller,csfst1@unix.cis.pitt.edu)

SHELL	= /bin/sh
## Begin configuration options

# If you want to enable host access control, define the HOST_ACCESS macro
#
ACCESS_DEF = -DHOSTS_ACCESS
#
# Note: host access control requires the strtok() and strchr() routines.
# Include the file strcasecmp.o if it is not provided by your C library.

AUX_OBJ	= # strcasecmp.o

# Some System-V versions require that you explicitly specify the networking
# libraries.
LIBS	=

#  Sun intricacies
#CFLAGS		= -O $(ACCESS_DEF)

#  Some of the Apollo specifics.
#  Apollo does not have /usr/etc, so we create /etc/org-daemons
#  WjW
DESTDIR		= /etc
DAEMON_DIR 	= $(DESTDIR)/org-daemons
DEFINES		=  -DHOSTS_ACCESS -DREAL_DAEMON_DIR='"$(DAEMON_DIR)"'
APOLLO_FLAGS 	= -A run,any -A sys,any -L/bsd4.3/usr/include
CFLAGS		= -O $(DEFINES) $(APOLLO_FLAGS)
ARCH	  	= frontd.10.3.tar
FTP	  	= /usr/user/ftp/pub/apollo

# Some generic definitions which can be used throughout the makefile
ARCHFILES = README README.APOLLO tcpd.c fromhost.c hosts_access.c Makefile \
	    hosts_access.5 strcasecmp.c BLURB

## End configuration options

TCPD_OBJ= tcpd.o fromhost.o hosts_access.o

all:	
	@echo "To create the initial version type: 'make first'"
	@echo "To update the current version type: 'make update'"
	@echo "To start the logging type: 'make activate'"

first:  frontd install activate

tcpd:	$(TCPD_OBJ) $(AUX_OBJ)
	$(CC) $(CFLAGS) -o $@ $(TCPD_OBJ) $(AUX_OBJ) $(LIBS)

# Apollo has already a tcpd, so we need another name.
frontd: tcpd
	mv tcpd frontd

lint:
	lint -DHOSTS_ACCESS tcpd.c fromhost.c hosts_access.c
	lint -DHOSTS_ACCESS miscd.c fromhost.c hosts_access.c

install:
	@cp frontd $(DESTDIR)/frontd
	@echo "*.info			/usr/adm/info" >> /etc/syslog.conf
	@touch /usr/adm/info
	@mkdir /etc/org-daemons
	mv /etc/ftpd 	$(DAEMON_DIR); ln -s /etc/frontd /etc/ftpd
	mv /etc/telnetd $(DAEMON_DIR); ln -s /etc/frontd /etc/telnetd
	mv /etc/rexecd 	$(DAEMON_DIR); ln -s /etc/frontd /etc/rexecd
	mv /etc/rshd 	$(DAEMON_DIR); ln -s /etc/frontd /etc/rshd
	mv /etc/rlogind $(DAEMON_DIR); ln -s /etc/frontd /etc/rlogind
	mv /etc/fingerd $(DAEMON_DIR); ln -s /etc/frontd /etc/fingerd
	
activate:
	@kill -1 `cat /etc/syslog.pid` 
	@echo "syslogd reconfigured"

update: frontd
	cp frontd $(DESTDIR)/frontd

archive:
	tar cvf $(ARCH) $(ARCHFILES)
	compress $(ARCH)
	cp $(ARCH).Z $(FTP)
	chmod 644 $(FTP)/$(ARCH).Z
clean:
	rm -f frontd tcpd miscd *.o core *.bak

	## end of Makefile ##
	
