#
# ~ppr/src/responders/Makefile
# Copyright 1995, 1996, 1997, Trinity College Computing Center.
# Written by David Chappell.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation.  This software is provided "as is" without express or
# implied warranty.
#
# Last modified 31 January 1997.
#

include ../include/global.mk

all: time_elapsed$(DOTEXE)

install: $(HOMEDIR)/responders/write $(HOMEDIR)/responders/netsend \
	$(HOMEDIR)/responders/mail $(HOMEDIR)/responders/samba \
	$(HOMEDIR)/responders/xwin $(INSTALLATALK) \
	$(HOMEDIR)/responders/pprpopup $(HOMEDIR)/responders/audio \
	$(HOMEDIR)/lib/respond.sh $(HOMEDIR)/lib/respond.ph \
	$(HOMEDIR)/lib/time_elapsed$(DOTEXE)

# Shell script which calls write and mail.
$(HOMEDIR)/responders/write: write.sh
	$(INSTALLSCRIPT) write.sh $(HOMEDIR)/responders/write

# Shell script for LAN Manager for Unix.
$(HOMEDIR)/responders/netsend: netsend.sh
	$(INSTALLSCRIPT) netsend.sh $(HOMEDIR)/responders/netsend

# Shell script which calls mail.
$(HOMEDIR)/responders/mail: mail.sh
	$(INSTALLSCRIPT) mail.sh $(HOMEDIR)/responders/mail
	$(RMF) $(HOMEDIR)/responders/errmail
	ln $(HOMEDIR)/responders/mail $(HOMEDIR)/responders/errmail

# Shell script which calls Samba's smbclient.
$(HOMEDIR)/responders/samba: samba.sh
	$(INSTALLSCRIPT) samba.sh $(HOMEDIR)/responders/samba

# This one shouldn't have the suid bit set.
$(HOMEDIR)/responders/xwin: xwin.sh
	$(INSTALLSCRIPT) xwin.sh $(HOMEDIR)/responders/xwin

# Target to install ATALK support.  This is included in "install" above
# if $(INSTALLATALK) is defined as "installatalk".  This target in turn
# depends on the AppleTalk type defined by $(ATALKTYPE).
installatalk: atalk-$(ATALKTYPE)

# Target to install ALI AppleTalk responder.  We don't 
# have one so this target is empty.
atalk-ali:

# Target to install CAP AppleTalk responder
atalk-cap: $(HOMEDIR)/responders/atalk $(HOMEDIR)/bin/atalkmapd \
	$(CONFDIR)/atalk.conf

# CAP AppleTalk responder
$(HOMEDIR)/responders/atalk: atalk.perl
	$(INSTALLSCRIPT) atalk.perl $(HOMEDIR)/responders/atalk

# CAP daemon to build an AppleTalk map for the AppleTalk responder
$(HOMEDIR)/bin/atalkmapd: atalkmapd.perl
	$(INSTALLSCRIPT) atalkmapd.perl $(HOMEDIR)/bin/atalkmapd

# Configuration file for atalkmapd and atalk
$(CONFDIR)/atalk.conf: atalk.conf
	$(CP) atalk.conf $(CONFDIR)/atalk.conf

# Perl script to send the the Tcl/Tk program pprpopup:
$(HOMEDIR)/responders/pprpopup: pprpopup.perl
	$(INSTALLSCRIPT) pprpopup.perl $(HOMEDIR)/responders/pprpopup

# Perl script to give a spoken response:
$(HOMEDIR)/responders/audio: audio.perl
	$(INSTALLSCRIPT) audio.perl $(HOMEDIR)/responders/audio

# Shell version of respond.h
$(HOMEDIR)/lib/respond.sh: ../include/respond.h
	echo "# Bourne shell translation of respond.h" >$(HOMEDIR)/lib/respond.sh
	sed -n -e 's/^#define \([^ ]*\) \([^ 	]*\)\([	]*\)\(.*\)$$/\1=\2\3#\4/p' \
		<../include/respond.h >>$(HOMEDIR)/lib/respond.sh

# Perl version of respond.h
$(HOMEDIR)/lib/respond.ph: ../include/respond.h
	echo "# Perl translation of respond.h" >$(HOMEDIR)/lib/respond.ph
	sed -n -e 's/^#define \([^ ]*\) \([^ 	]*\)\([ 	]*\)\(.*\)$$/$$\1=\2;\3#\4/p' \
		<../include/respond.h >>$(HOMEDIR)/lib/respond.ph

# Elapsed time computer
time_elapsed$(DOTEXE): time_elapsed.c
	$(CC) $(CFLAGS) -o time_elapsed$(DOTEXE) time_elapsed.c

$(HOMEDIR)/lib/time_elapsed$(DOTEXE): time_elapsed$(DOTEXE)
	$(RMF) $(HOMEDIR)/lib/time_elapsed$(DOTEXE)
	$(CP) time_elapsed$(DOTEXE) $(HOMEDIR)/lib/time_elapsed$(DOTEXE)
	chmod 755 $(HOMEDIR)/lib/time_elapsed$(DOTEXE)

# clean up
clean:
	rm -f *.$(OBJ) *.bak *~ time_elapsed$(DOTEXE)

# end of file
