#!/bin/sh
##########################################################
#
#   Top level script to make the Varkon 1.17D binaries.
#
#   Compiles all C- and MBS-sources, links the 
#   binaries and installs in $VARKON_ROOT/bin
#   and $VARKON_ROOT/lib.
#
#   Note that before you run this script you must set
#   up the VARKON_ROOT variable in your environment
#   to point to the directory where your current
#   Varkon system is installed.
#
#   You may also have to edit the PLATFORM variable
#   defined below.
#
#  (C)rebro university 2003-03-13 J.Kjellander
#
##########################################################

# Uncomment the platform you are running on

PLATFORM=linux
#PLATFORM=crayT3E
#PLATFORM=sgi
#PLATFORM=aix
#PLATFORM=hpux
#PLATFORM=sun
#PLATFORM=FreeBSD

#
# Compile the C-source modules IG, DB, GP, EX, GE
# PM, GM and WP and make the xvarkon binary.
#

module=IG
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

module=DB
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

module=GP
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

module=EX
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

module=GE
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

module=PM
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

module=WP
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

if [ -d $VARKON_ROOT/bin ]; then
 echo "$VARKON_ROOT/bin exists" 
else
  echo "Creating $VARKON_ROOT/bin"
  mkdir $VARKON_ROOT/bin
fi
echo "Making the main executable xvarkon"
make -f Makefile.$PLATFORM

#
# Make sure the tmp directory exists.
#
if [ -d $VARKON_ROOT/tmp ]; then
 echo "$VARKON_ROOT/tmp exists" 
else
  echo "Creating $VARKON_ROOT/tmp"
  mkdir $VARKON_ROOT/tmp
fi

#
# Compile the AN module and make the MBS compiler mbsc.
#

module=AN
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM
cd ../..

#
# Compile the PL module and make the plotter programs.
#

module=PL
echo " "
echo "Making $module"
if [ -d $VARKON_ROOT/sources/$module/lib ]; then
 echo "./$module/lib exists" 
else
  echo "Creating ./$module/lib"
  mkdir ./$module/lib
fi
cd ./$module/src
make -f Makefile.$PLATFORM all
cd ../..

#
# Compile the MBS source modules and install the
# MBO-files in $VARKON_ROOT/lib
#

if [ -d $VARKON_ROOT/lib ]; then
 echo "$VARKON_ROOT/lib exists" 
else
  echo "Creating $VARKON_ROOT/lib"
  mkdir $VARKON_ROOT/lib
fi

echo " "
echo "Making the Varkon library"
echo "analysis"
cd Vlib/analysis
make
cd ../..

echo "dxf"
cd Vlib/dxf
make
cd ../..

echo "edit"
cd Vlib/edit
make
cd ../..

echo "fedit"
cd Vlib/fonts/fedit
make
cd ../../..

echo "iges"
cd Vlib/iges
make
cd ../..

echo "macro"
cd Vlib/macro
make
cd ../..

echo "plott"
cd Vlib/plott
make
cd ../..

echo "stl"
cd Vlib/stl
make
cd ../..

################################################################
