$os_name = $^O;

if ($os_name =~ "linux") {
    my $home_dir = "/greenstone/gs-release-builder";
    print "Running linux setup from $home_dir/envi/etc/environment.pl\n";

    $ENV{'ANT_HOME'} = "$home_dir/packages/apache-ant-1.9.4";
    $ENV{'PATH'} = "$home_dir/packages/subversion/linux/bin:$ENV{'ANT_HOME'}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
    $ENV{'LANG'} = "en_NZ.UTF-8";
    $ENV{'SHELL'} = "bin/bash";
    $ENV{'TERM'} = "xterm";
    $ENV{'LC_ALL'} = "C";
}

if ($os_name =~ "MSWin32") {
    my $home_dir = "C:\\greenstone\\gs-release-builder";
    print "Running windows setup from $home_dir\\envi\\etc\\environment.pl\n";
    $ENV{'JAVA_HOME'} = "$home_dir\\packages\\jdk8.0.302";
    $ENV{'ANT_HOME'} = "$home_dir\\packages\\apache-ant-1.9.5";
    $ENV{'_PERL_TOPLEVEL'} = "$home_dir\\packages\\strawberry-perl-5.18";
    $ENV{'PERL_HOME'} = "$home_dir\\packages\\strawberry-perl-5.18\\perl";
    # path: add in java, ant, perl, svn, system32 for tar
    $ENV{'PATH'} = "$ENV{'JAVA_HOME'}\\bin;$ENV{'ANT_HOME'}\\bin;$ENV{'PERL_HOME'}\\bin;$ENV{'PERL_HOME'}\\site\\bin;$ENV{'_PERL_TOPLEVEL'}\\c\\bin;C:\\Program Files (x86)\\Subversion\\bin;C:\\Windows\\System32"; # do we need putty now we are not uploading in rk? ;C:\\Program Files\\PuTTY";

    source_batch_script("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvarsamd64_x86.bat");    
}

if($os_name =~ "darwin") {
    #$ENV{'OSTYPE'} = "darwin18"; #`echo $OSTYPE`;
    # find OSTYPE with uname -v and use major version number of kernel version
    # or use uname -r and get the kernel major version directly
    
    # svn is in /usr/bin
    $ENV{'RELEASES_DIR'}= "/Users/greenstone/RELEASES";
    #$ENV{'JAVA_HOME'} = "$ENV{'RELEASES_DIR'}/JDK7u80/Home";
    $ENV{'JAVA_HOME'} = "$ENV{RELEASES_DIR}/JDK8u301/Home";
    $ENV{'PATH'} = "$ENV{'JAVA_HOME'}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
    $ENV{'DATA_DIR'}="$ENV{'RELEASES_DIR'}/snapshots";
    $ENV{'LANG'} = "en_NZ.UTF-8";
    $ENV{'SHELL'} = "/bin/bash";
    $ENV{'TERM'} = "xterm-256color";
    #$ENV{'THIS_MACHINE'} = "macrocarpa";
}
