#!/bin/bash
#
# IBM Omni driver
# Copyright (c) International Business Machines Corp., 2000
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
# the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

#
# Set the DEVICES variable either from devices.mak or from the arguments
#
if (($# == 0)) ;
then
	. ./devices.mak
	DEVICES=$DEVICELIST
else
	DEVICES="$@"
fi

#
# Setup the library path
#
unset LD_LIBRARY_PATH

LD_LIBRARY_PATH=`pwd`/.libs

#
# Add the devices to the library path
#
for i in $DEVICES ;
do
	#
	# Figure out the directory
	#
	DIR="`echo ${i} | sed -e 's/~//g' -e 's/_/ /g'`"

	#
	# Add the built directory for this device
	#
	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/"${DIR}/.libs"

	#
	# Does it have a VendorSupplied equivalent as well?
	#
	if test -d "VendorSupplied/${DIR}"; then
		#
		# Append it
		#
		LD_LIBRARY_PATH=`pwd`/"VendorSupplied/${DIR}":$LD_LIBRARY_PATH
		PATH=`pwd`/"VendorSupplied/${DIR}":$PATH
	fi
done

export LD_LIBRARY_PATH
export PATH=`pwd`:$PATH

echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
echo PATH=$PATH
