#!/usr/bin/ksh
#
#  Partner: INETSVCS
#  Script: build
#
#  Usage: INETSVCS/bin/build
#         (Note: you must be cd'd to the top level of the desired chroot
#                directory.  Ex. cd /source_code/10_MLP
#
# setup symlinks of BE+ files.
PATH=$PATH:/usr/ccs/bin:/opt/ansic/bin:/opt/langtools/bin:/INETSVCS/src/gated3.0/dev_kit/bin
export PATH

/usr/sbin/chroot . /usr/bin/ksh <<-END-of-FILE 
	cd /INETSVCS/BE+
	for FILE in \`find * -type f\`
	do
	  # make sure the directories exist ahead of time
	  DIR=\`dirname \$FILE\`
	  if [ ! -d /\$DIR ] ; then
		mkdir -p /\$DIR
	  fi

	  # do the actual link
	  ln -s /INETSVCS/BE+/\$FILE /\$FILE
	done
	END-of-FILE

# do build
/usr/sbin/chroot . /usr/bin/ksh <<-END-of-FILE 
	export LOGNAME=indnetwk
        cd /source/INETSVCS/indnetwk
        make build
	END-of-FILE

# remove symlinks of BE+ files.
/usr/sbin/chroot . /usr/bin/ksh <<-END-of-FILE 
	cd /INETSVCS/BE+
	for FILE in \`find * -type f\`
	do
	  rm -f /\$FILE
	done
	END-of-FILE
