#!/usr/bin/env bash

# This file is part of Megatest.
# 
#     Megatest is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     Megatest is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.

# Run your step here

cksetupsh=$PREFIX/setup-chicken4x.sh
cksetupcsh=$PREFIX/setup-chicken4x.csh
setupsh=$PREFIX/buildsetup.sh

# make a cache dir
mkdir -p $DOWNLOADS
mkdir -p $PREFIX

# File for users to source to run chicken
echo "# Source me to setup to to run chicken" > $cksetupsh
echo "export PATH=$PREFIX/bin:\$PATH" > $cksetupsh
echo "export LD_LIBRARY_PATH=$PREFIX/lib" >> $cksetupsh

# tcsh version
echo "setenv PATH $PREFIX/bin:\$PATH" > $cksetupcsh
echo "setenv LD_LIBRARY_PATH $PREFIX/lib" >> $cksetupcsh

# File to source for build process
echo "export PATH=$PREFIX/bin:\$PATH" > $setupsh
echo "export LD_LIBRARY_PATH=$PREFIX/lib" >> $setupsh

if [[ $proxy == "" ]]; then 
  echo 'Please set the environment variable "proxy" to host.com:port (e.g. foo.com:1234) to use a proxy'
else
  echo "export http_proxy=http://$proxy" >> $setupsh
  echo "export PROX=\"-proxy $proxy\""   >> $setupsh
fi

echo "export PREFIX=$PREFIX" >> $setupsh

echo ALL DONE
