#!/bin/sh
#
# Constructs a makefile using the files within the RCS
# subdirectory as a baseline.
#
# Author: Jack C Lipton liptonsoup1951@yahoo.com
#
# Inputs:
#
# RCS/*,v files within RCS
# .suppress list of files to ignore
# from the RCS directory
# .poems list of files for poetry
# processing (formatting)
#
#
AUTHOR=CupaSoup # I'm being nice by having this tunable
#
# Publishing via FTP: the ncftpput utility will, with the
# use of -y and -z, not upload a file that hasn't changed
# on the sourcing end. This keeps us from pushing ALL of
# the files each time. I have the "trace" output sent to
# stdout since I like to know how things are progressing.
# The account connection information is retained in the
# home directory for security (and it damn well better be
# chmod'd to 600).
#
WEBLOC="-f $HOME/.asstr.acct -z -y -d - /pub/Authors/$AUTHOR/www"
FTPLOC="-f $HOME/.asstr.acct -z -y -d - /pub/Authors/$AUTHOR"
#
# #################### Main #####################
#
#
# Get a list of RCS'd file from the subdir:
#
# Note the presences of a .suppress file intended
# to reserve files from publishing...
#
FILES=`ls -1 RCS/* | grep -v -f .suppress | sed 's/RCS\///' | sed 's/,v//' | grep '\.x$'`
#
# Strip off the extension.
#
# (Note: I use .x as my text extension since it's easier
# to type. This file is written around .x not .txt so it
# will require attention to change this...)
#
BASES=`echo $FILES | sed 's/\.x//g'`
#
# Let the poor b@stard running this know what files have
# been selected for processing.
#
echo $FILES
#
# Start construction of the new makefile by genning a list
# of files for it's own use. This is needed for dependancies
#
echo -e "\nFILES = \\" >makefile+
for F in $BASES
do
echo " $F.html \\" >>makefile+
done
echo " " >>makefile+
#
# OK, the targets are now known, now we'll plug in the core
# utilizations...
#
cat >>makefile+ <<MAKEPROTO
#
#
#
all: index.html affinity.html affinity2.html squick.html # default targets
#
# asstr is the "publish" target
#
asstr: index.html affinity.html affinity2.html squick.html # transfers the files up
ncftpput $WEBLOC *.html *.jpg *.html .*.sh .mkmk .squick*
ncftpput $FTPLOC *.x
index.html: \$(FILES) .mkindex.sh .hide
sh .mkindex.sh # construct the file from the list
affinity.html: .mkaff.sh .squicks
sh .mkaff.sh
affinity2.html: .mkaff2.sh .squicks
sh .mkaff2.sh
squick.html: .mksquick.sh .squicks
sh .mksquick.sh
clean: # blows everything away so we can re-extract
rm -f *.html
rm -f *.txt
rm -f *.x
MAKEPROTO
#
# In case we've got an SCP transfer (secure copy) capability, we
# want to allow publishing there. If the PUBLISH_TO shell variable
# is not set to anything, this section will not be generated.
#
if [ ! -z "$PUBLISH_TO" ]
then
cat >>makefile+ <<MAKEPROTO
publish: # write to the target (this may need tuning)
scp .*.sh .hide makefile *.html *.x $PUBLISH_TO
MAKEPROTO
fi
#
# Now we build the transitions for the text files to be turned
# into .html files. Note that the ".x" suffix is used here and
# would need tuning if there's a difference.
#
# I've copied it so that it's a matter of adjusting commenting
# to switch it around.
#
echo -e "\n\n#\n#\n#\n" >>makefile+
for F in $BASES
do
HTMLOPT=
POEM=`grep $F .poems | grep $F | wc -l`
[ $POEM != 0 ] && HTMLOPT=-2
echo -e "$F.html:\t$F.x .txt2html.sh" >>makefile+
echo -e "\t./.txt2html.sh\t$HTMLOPT\t$F.x" >>makefile+
echo -e "\tchmod 644\t$F.html\t$F.x" >>makefile+
#echo -e "\tncftpput $WEBLOC \t$F.html" >>makefile+
echo "" >>makefile+
# echo -e "$F.html:\t$F.txt .txt2html.sh" >>makefile+
# echo -e "\t./.txt2html.sh\t$F.txt" >>makefile+
# echo -e "\tchmod 644\t$F.html\t$F.txt\n" >>makefile+
done
echo -e "\n\n#\n#\n#\n" >>makefile+
#echo -e "squick.html:\tRCS/squick.html,v" >>makefile+
#echo -e "\t-[ -f squick.html ] && chmod 444\tsquick.html" >>makefile+
#echo -e "\tco\tsquick.html" >>makefile+
##echo -e "\tncftpput $FTPLOC \tsquick.html" >>makefile+
#echo "" >>makefile+
#
# Here's the portion that'll extract the file from RCS for processing
#
for F in $BASES
do
echo -e "$F.x:\tRCS/$F.x,v" >>makefile+
echo -e "\t-[ -f $F.x ] && chmod 444\t$F.x" >>makefile+
echo -e "\tco\t$F.x" >>makefile+
#echo -e "\tncftpput $FTPLOC \t$F.x" >>makefile+
echo "" >>makefile+
# echo -e "$F.txt:\tRCS/$F.txt,v" >>makefile+
# echo -e "\t-[ -f $F.txt ] && chmod 444\t$F.txt" >>makefile+
# echo -e "\tco\t$F.txt\n" >>makefile+
done
#
# We wrote the makefile+ file, now we'll stage it to be "makefile":
#
cutover makefile
exit 0