#! /bin/sh

# Arg 1 is a make target. One of: all (default), system, base, top

# If arg 2, use it as path to prolog. Otherwise, assume xsb is on PATH
if test "$2" = "" ; then
   PROLOG=xsb
else
   PROLOG=$2
fi

# Generate the files that contain the Prolog & Flora installation directories
# Generates runflora file that can be used to run flora
rm -fr .makeflora.tmp
(echo "['flrconfig.P']." | $PROLOG) \
    || (echo "Usage:  makeflora all full-path-to-prolog"; touch .makeflora.tmp)
if test -f .makeflora.tmp ; then
    rm -rf .makeflora.tmp
    exit 1
fi

chmod 700 ./runflora

touch flora2devel.P

# If $2 is not defined, we set PROLOG to the absolute path that was
# generated by flrconfig.P
PROLOG=`cat .prolog_path`/xsb

make $1 PROLOG=$PROLOG
