#!/bin/sh
# $URL:$
# $Rev:$
# $Date:$



_process () {
	# 1 = directory name
	# 2 = command line specified target

	CWD=`pwd`

	if [ -d ./${1} ]
	then

		echo -e "======================================================================\r${1} "

		cd ./${1}

		if [ -e ./sources ]
		then
			# The above named file is present at GSC for development purposes only
			# and is not distributed in driver archives.

			D2U=`which dos2unix 2>/dev/null | wc -l`
			if [ "${D2U}" != "1" ]
			then
			D2U=~/c/gsc/sio4/linux/d2u
			else
			D2U=dos2unix
			fi

			chmod +w ./sources
			${D2U} ./sources	 2>/dev/null  1>/dev/null
			chmod +x ./sources
			./sources

			if [ "${2}" != "sources" ]
			then
				make -f _sources ${2}
			else
				make -f _sources
			fi

			rm -f _sources

		fi

		if [ "${2}" != "sources" ]
		then

			if [ -e ./makefile ]
			then

				make -f ./makefile ${2}

			elif [ -e ./Makefile ]
			then

				make -f ./Makefile ${2}

			fi

		fi

		cd ${CWD}

	fi
}



#==============================================================================

_process driver	${1}

if [ ! "${1}" != "" ]
then
./driver/start
fi

_process lib	${1}
_process docsrc	${1}
_process utils	${1}
_process din	${1}
_process dout	${1}
_process led	${1}
_process sbtest	${1}
