# setup-lps.sh 
# Purpose: sets all the environment variables needed to build, install, and run
# OpenLaszlo, from an svn repository at http://svn.openlaszlo.org/openlaszlo 
# 
# Before running this script, probably in your .bashrc, set up environment 
# variables which you do not want this script to modify: 
# these variables will not be modified if they are already set:
# JAVA_HOME, ANT_HOME, JAVACC_HOME, JYTHON_HOME, TOMCAT_HOME, CATALINA_HOME,
# EDITOR
#
# usage: 
# . setup-lps.sh [dev_home [branch [vendor_home [tools_home [installs_home] ] ] ] ] 
# 
# Simple usage:
# . setup-lps.sh
# will set everything up properly if your Open Laszlo source lives in 
# "${HOME}/Source/svn/openlaszlo"
# 
# If you want to configure things at a more detailed level, do
# specify parameters on the command line. Note that these are *positional*. In 
# order to specify a tools_home, you must have also specified a dev_home, a 
# branch, and a vendor_home. 
# For example, 
# . /Users/ben/Source/svn/openlaszlo/tools/trunk/env/setup-lps.sh /Users/ben/Source/svn/openlaszlo branches/seaswirl
# sets me up to code using the seaswirl branch of OpenLaszlo. 
# 
# dev_home corresponds to where you checked out http://svn.openlaszlo.org/openlaszlo 
# and branch is the branch of openlaszlo you want to use. Usually this will just 
# be trunk. To use a branch other than trunk, set branch to "branches/seaswirl"
# To use a tag, pass in an argument of "tags/3.2.1" as the second argument. 
# LZ_VENDOR_HOME should be where you checked out http://svn.openlaszlo.org/vendor
# LZ_TOOLS_HOME should be the branch or trunk where you checked out 
# http://svn.openlaszlo.org/tools/trunk, or, if you're using a branch or tag of
# tools, set TOOLS_HOME to where you checked out 
# http://svn.openlaszlo.org/tools/tags/mytag
# LZ_INSTALLS_HOME is where you put the installed applications which were installed
# from $LZVENDOR_HOME. 

export LZ_DEV_HOME=${1:-"${HOME}/Source/svn/openlaszlo"}
export LZ_OL_BRANCH=${2:-"trunk"}
export LZ_VENDOR_HOME=${3:-"${LZ_DEV_HOME}/vendor"}
export LZ_TOOLS_HOME=${4:-"${LZ_DEV_HOME}/tools/trunk"}
export LZ_INSTALLS_HOME=${5:-"${LZ_DEV_HOME}/installs"}

# If these are defined, don't redefine them. They must have these well-known
# names in order for the tools which use them to know where their config files
# etc live. 
export JAVA_HOME=${JAVA_HOME:-"/Library/Java/Home"}
export ANT_HOME=${ANT_HOME:-"${LZ_VENDOR_HOME}/jakarta-ant-1.5.1"}
export JAVACC_HOME=${JAVACC_HOME:-"${LZ_INSTALLS_HOME}/javacc2.1"}
export JYTHON_HOME=${JYTHON_HOME:-"${LZ_INSTALLS_HOME}/jython"}
export TOMCAT_HOME=${TOMCAT_HOME:-"${LZ_INSTALLS_HOME}/jakarta-tomcat-5.0.24"}
export CATALINA_HOME=$TOMCAT_HOME
export EDITOR=${EDITOR:-"vim"}

# Redefine these variables based on the LPS branch. 
export LPS_HOME=${LZ_DEV_HOME}/${LZ_OL_BRANCH}
export LPS_BIN=${LPS_HOME}/WEB-INF/lps/server/bin
export LPS_PATHS=${JAVA_HOME}/bin:${ANT_HOME}/bin:${JAVACC_HOME}/bin:${JYTHON_HOME}:${TOMCAT_HOME}/bin:$LPS_BIN
export PATH=${LPS_PATHS}:$PATH

