#!/bin/ksh
#
#	CMS.KSH
#
#		New changes  1991/1/10 S. Ono
#		New changes  1999/5/18 S. Ono
#		New changes  2000/11/16 S. Ono

MainDir=${CMSPATH}/siten
SourceDir=${CMSPATH}/src
DiffDir=${CMSPATH}/diff
Tabfile=${CMSPATH}/diff/tabs/${TABFILE}
Version=${KEIVER}

if [ x${Tabfile} = x"" -o x${SYSNAME} = x"" -o x${KEIVER} = x"" ]
then
	errmsg "CMS Environments TABFILE SYSNAME KEIVER not found"
	exit
fi
BaseDir=`basename ${PWD}`
if [ x${BaseDir} != x${SYSNAME} ]
then
	errmsg "CMS not a dirctory"
	exit
fi
if [ ! -f ${Tabfile} ]
then
	errmsg "CMS  はソースファイルテーブルが必要です"
	exit
fi
if [ ! -d ${DiffDir}/lock/${SYSNAME} ]
then
	dialogmsg "mkdir2 ${DiffDir}/lock/${SYSNAME}"
	mkdir2 ${DiffDir}/lock/${SYSNAME}
fi
#for i in `sed 's/.*\///' "${Tabfile}"|sed 's/\.[a-z]*$//'|sed 's/\/$//'|sort -u`
#for i in `cat -s "${Tabfile}" | sed -e 's/\.c$/_c/g' -e 's/\.h$/_h/g' -e 's/\/$//g' | sort -u`
for i in `cat -s "${Tabfile}" | sed -f ${CMSPATH}/bin/suffixes.sed | sort -u`
do
	if [ ! -d ${DiffDir}/ver_${KEIVER}/${SYSNAME} ]
	then
		dialogmsg "mkdir2 ${DiffDir}/ver_${KEIVER}/${SYSNAME}"
		mkdir2 ${DiffDir}/ver_${KEIVER}/${SYSNAME}
	fi
	if [ ! -d ${DiffDir}/ver_${KEIVER}/${SYSNAME}/${i} ]
	then
	#	echo "MAKE a dirctory ${DiffDir}/ver_${KEIVER}/${SYSNAME}/${i} ??\c"
	#	read resp
	#	if [ x$resp = x"y" ]
	#	then
		dialogmsg "mkdir2 ${DiffDir}/ver_${KEIVER}/${SYSNAME}/${i}"
			mkdir2 ${DiffDir}/ver_${KEIVER}/${SYSNAME}/${i}
			if [ ! -d ${MainDir}/${SYSNAME}/${i} ]
			then
				if [ ! -d ${MainDir}/${SYSNAME} ]
				then
				dialogmsg "mkdir2 ${MainDir}/${SYSNAME}"
					mkdir2 ${MainDir}/${SYSNAME}
				fi
			dialogmsg "mkdir2 ${MainDir}/${SYSNAME}/${i}"
				mkdir2 ${MainDir}/${SYSNAME}/${i}
			fi
	#	fi
	fi
done
