#!/bin/csh -f
# Set up SWI-Prolog for a new architecture

if ( $#argv != 2 ) then
    echo "Usage: setup name architecture"
    exit 1
endif

set name=$1
set arch=$2

if ( -e $name ) then
    echo "Directory $name already exists; setup aborted"
    exit 1
endif

if ( ! -e src/md-$arch.h ) then
    echo "Machine description file md-$arch.h does not exists."
    echo "I will copy the generic md file into md-$arcg.h"
    (cd src; cp md-gener.h md-$arch)
endif

mkdir $name
cd $name
ln -s ../src/pl-*.[ch] .
ln -s ../src/pl-*.i[ch] .
ln -s ../src/{ATOMS,defatom,gnu,dump} .

if ( -e ../src/Makefile.$arch ) then
    ln -s ../src/Makefile.$arch Makefile
else
    ln -s ../src/Makefile Makefile
endif

ln -s ../src/md-$arch.h md.h

echo "Setup for $arch completed in directory $name"
