# Copyright 1989, 1990 Michael DeCorte
#
# the following variable should be set by you.	
# See README.1ST to see what else you have to do 
#
# the maximum number of files that can be requested in any one mail message
MAXFILES=200
# the sum of the file sizes from any one request must be less than this
MAXSUM=3000000
# the load average as reported by uptime must be less than this
# number/100.  The reason for the divide by 100 is the shell doesn't do floats
# yes 1000 is rather large but I do a nice -19 later on so I don't
# feel very guilty.  But you might have to be a little nicer to
# your computer.
MAXLOAD=1000
# the name of your machine that will actually mail this file to the
# real world.  This is here so that you don't fill up your mail queue
# If you don't have a mail server then leave this line alone but
# do edit crontab.sh
MAIL_SERVER=omnigate.clarkson.edu
# the name of your machine for mail purposes
SITE=sun.soe.clarkson.edu
# where do the general purpose tmp files go.  There should be quite a bit
# of space in here as all archive, compressed files and encodes files
# go in here
TMP_DIR=/usr/tmp
# Where to put pending mail requests as well as completed mail requests
# It is handy to keep the completed one around as they are useful
# in case of problems and bounces.  Therefore this should be a good sized
# directory
QUEUE=/user/ftp/archive-server/requests
# The archive keeps a little bit of book keeping in the files incomming
# and outgoing.  They are stored in here.
ACCOUNTING=/user/ftp/archive-server/accounting
# where does all of the software you are advertizing for export reside?
ARCHIVE_DIR=/user/ftp/pub
# Where do you want to put all of the executables?
BIN_DIR=/user/ftp/archive-server/bin
# a few more executables go in here.  These are responsible for making
# binary files mailable.  Make sure that you can support everything
# in here.  
ENC_DIR=/user/ftp/archive-server/bin/encoder
# a few more executables.  These are responsible for taking multiple
# files and turning them into one file.  Again make sure that you
# can support everything in here.  You MUST have simple.arc and none.arc
ARC_DIR=/user/ftp/archive-server/bin/archiver
# the last of the executables.  These are responsible for packing (compressing)
# files before encoding them but after archiving them.  
PAC_DIR=/user/ftp/archive-server/bin/pack
# the path to a system 5 type shell. (needs to support the set -- option)
SHELL=/bin/sh
# some versions of mkdir don't support the -p flag
MKDIRFLAGS=-p
# you need a version of touch that lets you use: touch -c mmddhhmmyy file ...
# to be able to use index-touch.sh (a useful shell script but not necessary)
TOUCH=/usr/5bin/touch

# you probably shouldn't modify anything below this line unless
# you are sure that you know how everything works

DIRS=$(TMP_DIR)\
     $(ARCHIVE_DIR)\
     $(BIN_DIR)\
     $(ENC_DIR)\
     $(ARC_DIR)\
     $(PAC_DIR)\
     $(ARCHIVE_DIR)/docs\
     $(ARCHIVE_DIR)/tmp\
     $(QUEUE)\
     $(ACCOUNTING)

EXEFILES=$(BIN_DIR)/is_mailable

READMES=$(ENC_DIR)/README.ENCODER\
        $(ARC_DIR)/README.ARCHIVER\
        $(PAC_DIR)/README.PACK

ENCODERS=$(ENC_DIR)/btoa.enc\
         $(ENC_DIR)/rscs.enc\
	 $(ENC_DIR)/uuencode.enc

ARCHIVERS=$(ARC_DIR)/arc.arc\
	  $(ARC_DIR)/none.arc\
	  $(ARC_DIR)/shar.arc\
	  $(ARC_DIR)/simple.arc\
	  $(ARC_DIR)/tar.arc\
	  $(ARC_DIR)/zoo.arc

CSHSCRIPTS=$(ARC_DIR)/dclshar.arc

PACKERS=$(PAC_DIR)/compact.pac\
	$(PAC_DIR)/compress.pac\
	$(PAC_DIR)/none.pac

DOCS=$(ARCHIVE_DIR)/docs/archiver_wrong.eng\
     $(ARCHIVE_DIR)/docs/empty_request.eng\
     $(ARCHIVE_DIR)/docs/encoder_wrong.eng\
     $(ARCHIVE_DIR)/docs/help.eng\
     $(ARCHIVE_DIR)/docs/not_found.eng\
     $(ARCHIVE_DIR)/docs/packer_wrong.eng\
     $(ARCHIVE_DIR)/docs/to_big.eng\
     $(ARCHIVE_DIR)/docs/to_many.eng

BINFILES=$(BIN_DIR)/convert-message.sh\
	 $(BIN_DIR)/cronscript.sh\
	 $(BIN_DIR)/daily.sh\
	 $(BIN_DIR)/file-sizes.sh\
	 $(BIN_DIR)/file-split.sh\
	 $(BIN_DIR)/ftp-mirror.sh\
	 $(BIN_DIR)/get-body.sh\
	 $(BIN_DIR)/get-header.sh\
	 $(BIN_DIR)/incoming.sh\
	 $(BIN_DIR)/index-touch.sh\
	 $(BIN_DIR)/is_alive.sh\
	 $(BIN_DIR)/labrea.ftp\
	 $(BIN_DIR)/load-average.sh\
	 $(BIN_DIR)/long-lines.sh\
	 $(BIN_DIR)/mailer.sh\
	 $(BIN_DIR)/mail-to.sh\
	 $(BIN_DIR)/mkindex.sh\
	 $(BIN_DIR)/monthly.sh\
	 $(BIN_DIR)/parse-body.sh\
	 $(BIN_DIR)/parse-message.sh\
	 $(BIN_DIR)/prep.ftp\
	 $(BIN_DIR)/reports.sh\
	 $(BIN_DIR)/rotate.sh\
	 $(BIN_DIR)/search.sh\
	 $(BIN_DIR)/updateindex.sh\
	 $(BIN_DIR)/weekly.sh

all: header.sh

install: all $(DIRS) $(ENCODERS) $(ARCHIVERS) $(PACKERS) $(DOCS) $(BINFILES) $(EXEFILES) $(CSHSCRIPTS)

clean:
	rm -f header.sh \#*\# *~

$(DOCS): $(ARCHIVE_DIR)/docs
	cp `echo $@ | sed "s@^.*/@@"` $@

$(PACKERS) $(ARCHIVERS) $(ENCODERS) $(BINFILES): header.sh 
	cat header.sh `echo $@ | sed "s@^.*/@@""` > $@
	chmod 755 $@

$(CSHSCRIPTS):
	cat `echo $@ | sed "s@^.*/@@""` > $@
	chmod 755 $@

header.sh: Header Makefile
	echo "#!$(SHELL)" > header.sh
	echo "# Copyright 1989, 1990 Michael DeCorte" >> header.sh
	echo "# This is a computer generated file. Dont touch it" >> header.sh
	echo "SHELL=$(SHELL)" >> header.sh
	echo "touch=$(TOUCH)" >> header.sh
	echo "queue=$(QUEUE)" >> header.sh
	echo "accounting=$(ACCOUNTING)" >> header.sh
	echo "archive_dir=$(ARCHIVE_DIR)" >> header.sh
	echo "docs_dir=$(ARCHIVE_DIR)/docs" >> header.sh
	echo "work_dir=$(ARCHIVE_DIR)/tmp" >> header.sh
	echo "bin_dir=$(BIN_DIR)" >> header.sh
	echo "encoder_dir=$(ENC_DIR)" >> header.sh
	echo "archiver_dir=$(ARC_DIR)" >> header.sh
	echo "pack_dir=$(PAC_DIR)" >> header.sh
	echo "site=$(SITE)" >> header.sh
	echo "maxload=$(MAXLOAD)" >> header.sh
	echo "mail_server=$(MAIL_SERVER)" >> header.sh
	echo "maxfiles=$(MAXFILES)" >> header.sh
	echo "maxsum=${MAXSUM}" >> header.sh
	echo "TMPDIR=$(TMP_DIR)" >> header.sh
	cat Header >> header.sh

$(TMP_DIR) $(ARCHIVE_DIR) $(BIN_DIR) $(ARCHIVE_DIR)/docs $(ARCHIVE_DIR)/tmp:
	mkdir $(MKDIRFLAGS) $@

$(READMES):
	cp README.ENCODER $@/README.ENCODER

$(PAC_DIR) $(ENC_DIR) $(ARC_DIR): 
	mkdir $(MKDIRFLAGS) $@

$(QUEUE) $(ACCOUNTING):
	mkdir $(MKDIRFLAGS) $@
	chmod 777 $@

$(EXEFILES):
	$(CC) $(CFLAGS) `echo $@ | sed "s@^.*/@@"`.c -o $@

$(BIN_DIR)/is_mailable:                 is_mailable.c $(BIN_DIR)
$(BIN_DIR)/convert-message.sh:          convert-message.sh $(BIN_DIR)
$(BIN_DIR)/cronscript.sh:               cronscript.sh $(BIN_DIR)
$(BIN_DIR)/daily.sh:                    daily.sh $(BIN_DIR)
$(BIN_DIR)/file-sizes.sh:               file-sizes.sh $(BIN_DIR)
$(BIN_DIR)/file-split.sh:               file-split.sh $(BIN_DIR)
$(BIN_DIR)/ftp-mirror.sh:               ftp-mirror.sh $(BIN_DIR)
$(BIN_DIR)/get-body.sh:                 get-body.sh $(BIN_DIR)
$(BIN_DIR)/get-header.sh:               get-header.sh $(BIN_DIR)
$(BIN_DIR)/incoming.sh:                 incoming.sh $(BIN_DIR)
$(BIN_DIR)/index-touch.sh:              index-touch.sh $(BIN_DIR)
$(BIN_DIR)/is_alive.sh:                 is_alive.sh $(BIN_DIR)
$(BIN_DIR)/labrea.ftp:                  labrea.ftp $(BIN_DIR)
$(BIN_DIR)/load-average.sh:             load-average.sh $(BIN_DIR)
$(BIN_DIR)/long-lines.sh:               long-lines.sh $(BIN_DIR)
$(BIN_DIR)/mailer.sh:                   mailer.sh $(BIN_DIR)
$(BIN_DIR)/mail-to.sh:                  mail-to.sh $(BIN_DIR)
$(BIN_DIR)/mkindex.sh:                  mkindex.sh $(BIN_DIR)
$(BIN_DIR)/monthly.sh:                  monthly.sh $(BIN_DIR)
$(BIN_DIR)/parse-body.sh:               parse-body.sh $(BIN_DIR)
$(BIN_DIR)/parse-message.sh:            parse-message.sh $(BIN_DIR)
$(BIN_DIR)/prep.ftp:                    prep.ftp $(BIN_DIR)
$(BIN_DIR)/reports.sh:                  reports.sh $(BIN_DIR)
$(BIN_DIR)/rotate.sh:                   rotate.sh $(BIN_DIR)
$(BIN_DIR)/search.sh:                   search.sh $(BIN_DIR)
$(BIN_DIR)/updateindex.sh:              updateindex.sh $(BIN_DIR)
$(BIN_DIR)/weekly.sh:                   weekly.sh $(BIN_DIR)
$(ENC_DIR)/btoa.enc:                    btoa.enc $(ENC_DIR)
$(ENC_DIR)/rscs.enc:                    rscs.enc $(ENC_DIR)
$(ENC_DIR)/uuencode.enc:                uuencode.enc $(ENC_DIR)
$(ARC_DIR)/arc.arc:                     arc.arc $(ARC_DIR)
$(ARC_DIR)/dclshar.arc:                 dclshar.arc $(ARC_DIR)
$(ARC_DIR)/none.arc:                    none.arc $(ARC_DIR)
$(ARC_DIR)/shar.arc:                    shar.arc $(ARC_DIR)
$(ARC_DIR)/simple.arc:                  simple.arc $(ARC_DIR)
$(ARC_DIR)/tar.arc:                     tar.arc $(ARC_DIR)
$(ARC_DIR)/zoo.arc:                     zoo.arc $(ARC_DIR)
$(PAC_DIR)/compact.pac:                 compact.pac $(PAC_DIR)
$(PAC_DIR)/compress.pac:                compress.pac $(PAC_DIR)
$(PAC_DIR)/none.pac:                    none.pac $(PAC_DIR)
$(ARCHIVE_DIR)/docs/archiver_wrong.eng: archiver_wrong.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/empty_request.eng:  empty_request.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/encoder_wrong.eng:  encoder_wrong.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/help.eng:           help.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/not_found.eng:      not_found.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/packer_wrong.eng:   packer_wrong.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/to_big.eng:         to_big.eng $(ARCHIVE_DIR)/docs
$(ARCHIVE_DIR)/docs/to_many.eng:        to_many.eng $(ARCHIVE_DIR)/docs
$(ENC_DIR)/README.ENCODER:              README.ENCODER $(ENC_DIR)
$(ARC_DIR)/README.ARCHIVER:             README.ARCHIVER $(ARC_DIR)
$(PAC_DIR)/README.PACK:                 README.PACK $(PAC_DIR)
