#!/bin/sh
set -e

. kumatux.org-vars

for SEARCH in lib/ruby/1.8 lib/site_ruby/1.8
do
    ROOTDIR=$KUMATUXROOTRUBYLIB
    ETCDIR=$KUMATUXETCRUBYLIB
    ## check whether app already linked
    LINKED=`$KUMATUXFIND/linked-allready.sh $1 $ROOTDIR $SEARCH`
    if [ "$LINKED" ]
    then
	## don't link
	echo "$1/$SEARCH linked already in $LINKED"
    else
	## link
	$KUMATUXLINK/link-line.sh $1 $SEARCH $ETCDIR $ROOTDIR
    fi
    for ARCHOS in x86_64-linux arm-linux-eabi i386-linux ppc-linux sparc-solaris arm-linux
    do
	SEARCH1=$SEARCH/$ARCHOS
        ## check whether app already linked
	LINKED=`$KUMATUXFIND/linked-allready.sh $1 $ROOTDIR $SEARCH1`
        if [ "$LINKED" ]
	    then
	    ## don't link
	    echo "$1/$SEARCH1 linked already in $LINKED"
	else
	    ## link
	    $KUMATUXLINK/link-line.sh $1 $SEARCH1 $ETCDIR $ROOTDIR
	fi
    done
done