#
# ADOBE SYSTEMS INCORPORATED
# Copyright 2002 Adobe Systems Incorporated. All Rights Reserved.
#
# NOTICE:  Notwithstanding the terms of the Adobe GoLive End User 
# License Agreement, Adobe permits you to reproduce and distribute this 
# file only as an integrated part of a web site created with Adobe 
# GoLive software and only for the purpose of enabling your client to 
# display their web site. All other terms of the Adobe license 
# agreement remain in effect.
#

$th = $ENV{TOMCAT_HOME} || die "TOMCAT_HOME must be set.";
$j = $ENV{JAVA_HOME} || die "JAVA_HOME must be set.";

#
# We try to figure out if we are on Windows or Unix by looking for
# C:\Program Files
# If found, we declare it as windows, else unix.
#
if (-d "C:\Program Files") {
	$win = 1;
	$path_delim = ";";
}
else {
	$win = "";
	$path_delim = ":";
}

$lh = '..';
$ch = '.';
if ($ENV{APP_HOME}) {
	$lh = $ENV{APP_HOME}.'/WEB-INF';
	$ch = $lh.'/classes';
}

@cp = (
	$ENV{CLASSPATH0} || '',
	$ch,

	"$lh/lib/altercast_sdk.jar",
	"$lh/lib/xalan.jar",
	"$lh/lib/xerces.jar",
	"$lh/lib/jakarta-regexp-1.2.jar",
	"$lh/lib/xsl.jar",

	"$th/lib/xalan.jar",
	"$th/lib/xerces.jar",
	"$th/lib/jakarta-regexp-1.2.jar",
	"$th/lib/xsl.jar",

	#### catalina (tomcat 4.0) library structure
	"$th/common/lib/servlet.jar",

	#### tomcat 3.2 library structure
	"$th/lib/ant.jar",
	"$th/lib/jasper.jar",
	"$th/lib/jaxp.jar",
	"$th/lib/parser.jar",
	"$th/lib/servlet.jar",
	"$th/lib/webserver.jar",

	"$j/lib/tools.jar",
	$ENV{CLASSPATH1} || ''
);

my(@p, %p);
my($sep) = $path_delim;  # : for Unix, ; for win

@p =		# strip duplicates and nonexistent dirs
	grep { $_ && !$p{$_}++ && -e $_ }
		# ':' so we can pass $PATH as an argument
	map { split /:/ }
	@cp;

$result = join $path_delim, @p;

# Windows only 
if ($win) {
	$result =~ s|//(.)/|$1:/