#!/bin/sh
set -e

. $KUMATUXBIN/kumatux.org-vars

SEARCH=share/aclocal
ROOTDIR=$KUMATUXROOTACLOCAL
ETCDIR=$KUMATUXETCACLOCAL

## check whether app already linked
LINKED=`$KUMATUXFIND/linked-allready.sh $1 $ROOTDIR $SEARCH`
if [ "$LINKED" ]
## don't link
then
    echo "$1/$SEARCH linked already in $LINKED"
## link
else
    $KUMATUXLINK/link-line-colonless.sh $1 $SEARCH $ETCDIR $ROOTDIR
fi

APPNAME=`$KUMATUXBASENAME $1 | sed 's/_.*//'`
if [ $APPNAME = "automake" ]
then
    echo "Updating $1/share/aclocal/dirlist..."
    if [ -e $1/share/aclocal/dirlist ]
    then
	cp $1/share/aclocal/dirlist $1/share/aclocal/dirlist.bak
    fi
    mkdir -p $1/share/aclocal
    echo "$KUMATUXROOT/$ROOTDIR/*" >> $1/share/aclocal/dirlist
    echo "Updated."
fi
