#!/bin/sh
# for lib4th/test4th, 6/2000 by h-peter recktenwald <phpr@snafu.de>

# test only & kill 
#			$1="t"
# force lib4th & test4th compiling
#			$1="n"
# compile and, if ok
# 	do test 	$1=/="s"
# 	test & kill	$1=/="k"

cd ..

RM="/usr/local/bin/rm -f"
CP="/usr/local/bin/cp --backup=t"
MV="/usr/local/bin/mv --backup=t"
ST=$(which strace)
[ -n "${ST}" ]||ST=util/strace

kn kill-f8
${RM} ./${0}-*.log

export PATH=.:$PATH
k=${1}
[ -z "${1}" ]||{ { [ "${k}" == "k" ]&&shift; }||{ [ "${k}" == "n" ]&&shift; }; }

v=$(./relse.sh)

(
    [ "${k}" == "t" ]||{
	n=-1
	false
        while [ "$?" != "0" ]
        do
	    n=$(($n+1))
	    make uninstall new install 2>&1|tee ${0}-${n}.log
	done;wait
    }
    [ "$?" != "0" -o "${k}" == "s" ]||{
        echo
	[ "${k}" == "k" ]||(./kill-f8 20 "./test4th")&
	${CP} ./test4th-${v}.t||true
	sync
	[ "${k}" == "t" ]&&./test4th ${k} k 2>&1|tee ./test4th-${v}.t||${ST} ./test4th ${k} k 2>&1|tee ./test4th-${v}.t
	echo
    }
    [ "$?" != "0" ]&&echo $?||{ echo "test4th-${v} make & test OK"; }
)
# MK-lib4th <eof>
