#!/bin/sh -e
# Public domain.

umask 022
test -d package || { echo 'Wrong working directory.'; exit 100; }
test -d src || { echo 'Wrong working directory.'; exit 100; }
test -d conf-compile || { echo 'Wrong working directory.'; exit 100; }

spr=`cat compile/export/conf-sp_root`
category=`cat compile/export/conf-category`
name=`cat compile/export/conf-name`

exportit()
{
  dir="$1"
  test -f "package/$dir.exported" &&
  {
    echo "Making links in $spr/$dir..."
    mkdir -p "$spr/$dir"
    for i in `cat "package/$dir.exported"`
    do
      rm -f "$spr/$dir/$i"'{new}'
      ln -s "../package/$category/$name/$dir/$i" "$spr/$dir/$i"'{new}'
      mv -f "$spr/$dir/$i"'{new}' "$spr/$dir/$i"
    done
  } || true
}

exportit command
exportit library
exportit library.so
exportit include
exportit man
exportit doc
