goto _
	@(#)makeKER.sh	1.3
	Kernel builder
	Created 22 Oct 1980 by R. B. Neely
:    _

echo "Kernel Builder V1.3(hacked for /misc/newKernel"

= k /misc/KSOS11/Kconf

: sources
echo "\nType  e  to build a Kernel from existing source files"
echo "      r  to retrieve source files from a previous version"
echo "      i  to integrate two versions"
echo "     [ ]\c"
= m </dev/tty
if "$m" = e goto endget
if "$m" != r -a "$m" != i then
    echo "Entry r or i or n required"
    goto sources
endif
ls >/tmp/KB$$
grep -c "." /tmp/KB$$ >/dev/null
if $r -eq 0 then
    echo "The current directory is non-empty.\nIn order to rebuild a version, you must start with an empty directory."
    rm /tmp/KB$$
    exit 1
endif
rm /tmp/KB$$

if $m = i then
    echo "Two Kernel version numbers are required."
    echo "  First version number: \c"
    = i </dev/tty
    echo "  Second version number: \c"
    = j </dev/tty
    igepl -r$i -r$j /misc/newKernel/udf/s.KER.epl >/tmp/KB$$
    getgen /misc/newKernel/udf/KER.gsh /tmp/KB$$ >_gets_
    sh -v _gets_
else
    echo "Type the version number of the Kernel to rebuild: \c"
    = i </dev/tty
    KERge -r$i >_gets_
    = a $r
    if $a -ne 0 then
	echo "Failure in KERge: $a"
	exit 1
    endif
    sh -v _gets_
    get -r$i /misc/newKernel/udf/s.KER.epl
endif
: endget

if $m = e then
    echo "\nAre you changing the target configuration? (y or n) \c"
    = a </dev/tty
    if "$a" != y goto endcnfg
else
    if "$m" = r then
	echo "\nYou must now confirm/modify the target configuration..."
    else
	echo "\nYou must now create a target configuration..."
	rm -f KER.epl
	echo " " >KER.epl
	chmod 444 KER.epl
    endif
endif
rm -f KERconf.mod IODconf.mod
$k KER.epl <--
= c $r
if $c -eq 2 then
    echo "Error in Kconf: $r"
    exit 1
endif
: endcnfg

if $m = e then
	echo "Do want a new EPL version? \c"
	= a </dev/tty
	if "$a" = n goto comp
endif

if $m != r goto epl

if $c -eq 0 goto comp

: epl
echo "\nSpecify EPL version (or carriage return for default): \c"
= a </dev/tty
if "{$a}" != {} = a -r$a
KERse "$a" <--
if $r -ne 0 then
    echo "Error in KERse: $r"
    exit 1
endif

: comp
echo "\nOK to continue with compilation? (y or n) \c"
= a </dev/tty
if "$a" != y then
    exit 1
endif
rm -f a.tlog
nohup Kmod >a.tlog&
echo "Compilation begun."
