#!/bin/sh
if [ $# -lt 2 ]
then
  echo usage: CONF platform site >&2
  exit 1
fi
for i in pg_config.h config.mk pg_site.h site.mk
do
  if [ -f $i ]
  then
    if [ -h $i ]
    then
      rm -f $i
    else
      echo "$i is not a link (you might want to save your changes first)." >&2
      exit 1
    fi
  else
    rm -f $i
  fi
done
if [ "$1" = "-u" ]
then
  echo Configuration files unlinked
  exit 0
else
  ln -s ./config/$1.h pg_config.h
  ln -s ./config/$1.mk config.mk
  ln -s ./config/$2-site.h pg_site.h
  ln -s ./config/$2-site.mk site.mk
  echo Configuration linked for $1/$2
  exit 0
fi
