case $CONFIG in
'')
	if test -f config.sh; then TOP=.;
	elif test -f ../config.sh; then TOP=..;
	elif test -f ../../config.sh; then TOP=../..;
	elif test -f ../../../config.sh; then TOP=../../..;
	elif test -f ../../../../config.sh; then TOP=../../../..;
	else
		echo "Can't find config.sh."; exit 1
	fi
	. $TOP/config.sh
	;;
esac
: This forces SH files to create target in same directory as SH file.
: This is so that make depend always knows where to find SH derivatives.
case "$0" in
*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
esac
echo "Extracting updatepages (with variable substitutions)"
: This section of the file will have variable substitutions done on it.
: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
: Protect any dollar signs and backticks that you do not want interpreted
: by putting a backslash in front.  You may delete these comments.
$spitshell >updatepages <<!GROK!THIS!
#!$perlpath
#
# updatepages: Build new chXX.html files from chXXmaster.html files
#
# Usage: updatepages <pbemname>
# Example: updatepages mage
#
# # Copyright 1998 Alan Schwartz
# # 
# # This file is part of pbemtools.
# # 
# # pbemtools is free software; you can redistribute it and/or modify
# # it under the terms of the GNU General Public License as published by
# # the Free Software Foundation; either version 2, or (at your option)
# # any later version.
# # 
# # pbemtools is distributed in the hope that it will be useful,
# # but WITHOUT ANY WARRANTY; without even the implied warranty of
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# # GNU General Public License for more details.
# # 
# # You should have received a copy of the GNU General Public License
# # along with pbemtools; see the file COPYING.
# # If not, write to the Free Software Foundation,
# # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# # 
# # Report problems and direct all questions to:
# # 
# #     alansz@pennmush.org
# # 

use lib qw($installperllib .);
require 'pbemtools.pl';
use Getopt::Std;

my \$tail = "$tail";

!GROK!THIS!

: In the following dollars and backticks do not need the extra backslash.
$spitshell >>updatepages <<'!NO!SUBS!'

&getopts('q');

die "Usage: updatepages <pbemname>\n" unless $#ARGV == 0;
my $pbem = shift(@ARGV);
&parseconfig("$pbem.config") or die "No config file $pbem.config\n";
unless ($Cgiurl) {
 warn "Cgiurl is not set, updatepages has nothing to do!\n" unless $opt_q;
 exit 0;
}
for ($chapter = 1; $chapter <= $Chapter; $chapter++) {
  print "Updating ch$chapter.html from ch${chapter}master.html\n" unless $opt_q;
  system("$Cgipath/expand.cgi $ENV{'LOGNAME'} $pbem $chapter nobody | $tail +2 > $Webdir/ch$chapter.html");
}

!NO!SUBS!
chmod 755 updatepages
$eunicefix updatepages
