#!/bin/sh
# shell script to help make to build GWM
# necessary for the bugged BSD make

# usage: Kl_util function args...

set -x

case $1 in

klone.shar)
    cat FILES FILES_KIT | fshar >klone.shar
    ;;

install)	# install bin-dir lib-dir
    if test ! -f .rootdir
    then echo "please create this directory with the \"make dir\" command!"
	exit 1
    fi
    mv $2/klone $2/klone.old
    install -c -s klone $2		# cp klone $2
    mkdir $3
    cd `cat .rootdir`/data
    for ff in .*.kl *.kl *.xbm *.xpm
    do
	install -c $ff $3
    done
    ;;

dir|sdir)		# sdir dirname
    if test -z "$2";then echo "USAGE: make DIR=mach sdir";exit 1;fi
    ND="$2"
    case "$ND" in */*);;*)ND=../$ND;;esac
    mkdir $ND
    pwd >$ND/.rootdir
    NDB=`basename $ND`
    echo  "$NDB">$ND/.dir
    if test ! -f Configs/"$NDB"
    then cp Configs/TEMPLATE Configs/"$NDB"
    fi
    Pwd=`pwd`
    if test "0" = `expr match "$ND" '^[.][.][/][^/]*$'`
    then ln -s $Pwd $ND/SRC
    else ln -s ../`basename $Pwd` $ND/SRC
    fi
    if cd $ND;then :;else exit;fi
    ln -s SRC/Configs/"$NDB" Config."$NDB"
    ln -s SRC/amiga .
    for i in `cat $Pwd/FILES` kl tests
    do ln -s SRC/$i .;done
    cd $Pwd
    echo "Now, go in $ND and edit Config.$NDB"
    ;;

esac
