#!c:sksh

# --*-sh-*---------------------------------------------------------------
#
# configure - PLplot configuration for the Amiga using SKsh.
#
# Maurice LeBrun, 8/94.
#
# For SAS/C 6.x.
#
# -----------------------------------------------------------------------

# Defaults

math="ieeef"
enable_f77="no"
enable_tcl="no"
enable_tk="no"

plcf_dist=../cf
plcf_amiga=../sys/amiga/cf

if [ ! -d $plcf_dist -o ! -d $plcf_amiga ]; then
    echo "Must be run from tmp subdirectory of main distribution"
    return
fi

echo "creating Makefile"

# -----------------------------------------------------------------------
# Makefile initialization

cat $plcf_amiga/init.in		>Makefile 

# Math settings

echo "# Math settings"  	>>Makefile

if [ "$math" = "ffp" ]; then
    echo '
MATHFLAGS	= math=ffp
LIBM		= lib:scmffp.lib
PLLIB		= $(PLLIB_PATH)plplotffp.lib
' >>Makefile
fi

if [ "$math" = "ieeef" ]; then
    echo '
MATHFLAGS	= math=ieee
LIBM		= lib:scmieee.lib
PLLIB		= $(PLLIB_PATH)plplotf.lib
' >>Makefile
fi

if [ "$math" = "ieeed" ]; then
    echo '
MATHFLAGS	= math=ieee
LIBM		= lib:scmieee.lib
DBL_FLAG_C	= -DDOUBLE
PLLIB		= $(PLLIB_PATH)plplotd.lib
' >>Makefile
fi

# Default target, core source and object file lists

cat $plcf_dist/dist.in		>>Makefile 

# Optional packages

if [ "$enable_f77" = "yes" ]; then
    cat $plcf_dist/pkg_f77.in	>>Makefile 
fi
if [ "$enable_tcl" = "yes" ]; then
    cat $plcf_dist/pkg_tcl.in	>>Makefile 
fi
if [ "$enable_tk" = "yes" ]; then
    cat $plcf_dist/pkg_tk.in 	>>Makefile 
fi

# Library targets

cat $plcf_amiga/initlib.in	>>Makefile
cat $plcf_amiga/lib.in		>>Makefile

# Program and demo file dependencies, targets

cat $plcf_dist/exes.in		>>Makefile 
cat $plcf_dist/demos.in		>>Makefile 

# Installation and miscellaneous.

cat $plcf_amiga/install.in	>>Makefile 
cat $plcf_amiga/misc.in		>>Makefile 

# Object file dependencies

cat $plcf_dist/objs.in	>>Makefile 

# -----------------------------------------------------------------------
# Now build Makedemo.in.
# Makedemo is a stand-alone makefile for the demo programs.
# Note: it links against the installed PLplot library.
# -----------------------------------------------------------------------

echo "creating Makedemo"

cat $plcf_amiga/init.in		>Makedemo
cat $plcf_amiga/initdemo.in	>>Makedemo

cat $plcf_dist/demos.in		>>Makedemo
cat $plcf_dist/miscdemo.in	>>Makedemo

# -----------------------------------------------------------------------
# Now set everything up for build
# -----------------------------------------------------------------------

if [ ! -f makelinks ]; then
    echo "Setting up utilities for build"
    cp ../sys/amiga/sksh/* .
    chmod +s lnsoft makelinks
    chmod +x sksh_join
fi

if [ ! -f plcore.c ]; then
    echo "Creating links.."
    ./makelinks
fi

return

