$os_name = $^O;
$bitness = 64; # change to 32 on 32 bit linux

if ($os_name =~ "linux") {
    my $home_dir = "/greenstone/gs-release-builder";
    print "Running linux setup from $home_dir/envi/etc/tasks/snapshot/environment.pl\n";
    #Where to keep snapshots
    $ENV{'DATA_DIR'} = "$home_dir/snapshots";
    
    #Where to find release kits 
    $ENV{'PATH'} = "$home_dir/release-kits/bin:$ENV{'PATH'}";
    
    #Setting JAVA_HOME
    $ENV{'JAVA_HOME'} = "$home_dir/packages/jdk1.8.0_301";
    
    #Adding JAVA_HOME to PATH
    $ENV{'PATH'} = "$ENV{'JAVA_HOME'}/bin:$ENV{'PATH'}";

    if ($bitness == 32) {
	print "32 bit\n";
	$ENV{'LD_LIBRARY_PATH'} = "$ENV{'JAVA_HOME'}/jre/lib/i386/jli:$home_dir/packages/subversion/linux/lib:$ENV{'LD_LIBRARY_PATH'}";
	# to force openssl to be 32 bit (otherwise it will test the machine, and be 64 bit)
	$ENV{'x32'}="true";
	$ENV{'GS_OPENSSL_HOST'} = "linux-generic32";
    } else {
	print "64bit\n";
	$ENV{'LD_LIBRARY_PATH'} = "$ENV{'JAVA_HOME'}/jre/lib/amd64/jli:$home_dir/packages/subversion/linux/lib:$ENV{'LD_LIBRARY_PATH'}";
    }
     #PYTHON - 2.7+ needed to compile gnome-lib's glib-2.54.x
     $ENV{'PATH'} = "$home_dir/packages/python2.7/bin:$ENV{'PATH'}";

}

if ($os_name =~ "MSWin32") {
    my $home_dir = "C:\\greenstone\\gs-release-builder";
    print "Running windows setup from envi\\bin\\tasks\\snapshot\\environment.pl\n";
    
    # where to put shapshots
    $ENV{'DATA_DIR'} = "$home_dir\\snapshots";

    # where to find release kits
    $ENV{'PATH'} = "$home_dir\\release-kits\\bin;$ENV{'PATH'}";

    # this was on akapuka - what is it?
    $ENV{'munges'} = "";

}

if ($os_name =~ "darwin") {
    $ENV{'RELEASES_DIR'}="/Users/greenstone/RELEASES";
    #$ENV{'ANT_HOME'}="$ENV{'RELEASES_DIR'}/ant-1.8.3";
    $ENV{'ANT_HOME'}="$ENV{RELEASES_DIR}/ant-1.9.4";
    #$ENV{'PATH'} = "$ENV{'ANT_HOME'}/bin:$ENV{'JAVA_HOME'}/bin:$ENV{'RELEASES_DIR'}/release-kits/bin:$ENV{'PATH'}";
    $ENV{'PATH'} = "$ENV{'ANT_HOME'}/bin:$ENV{'RELEASES_DIR'}/release-kits/bin:$ENV{'PATH'}";
    
    # Need the following to run the PDFBox binary as nzdl user 
    # necessary for doing diffcol of PDFBox tutorial
    # http://stackoverflow.com/question/10627405/how-to-set-java-system-properties-globally-on-os-x
    #$ENV{'_JAVA_OPTIONS'} = "-Djava.awt.headless=true";
    
    
    # Need this to compile jni stuff on ElCapitan, along with change in 
    # http://trac.greenstone.org/changeset/30751 (greenstone3/src/packages/javagdbm/configure)
    # to preserve the JNICFLAGS set here
    $ENV{'CFLAGS'} = "-I$ENV{'JAVA_HOME'}/include -I$ENV{'JAVA_HOME'}/include/darwin";
    $ENV{'CXXFLAGS'} = $ENV{'CFLAGS'};
    $ENV{'JNICFLAGS'} = $ENV{'CFLAGS'};
    $ENV{'JAVAC'} = "$ENV{'JAVA_HOME'}/bin/javac";
    $ENV{'JAVA'} = "$ENV{'JAVA_HOME'}/bin/java";    
}

# common settings

# setting javacflags - needed for release kit to target java classes
$ENV{'JAVACFLAGS'} = "-source 1.8 -target 1.8";
    
# Need to set -fPIC (for generating position independent code) among the CFLAGS
# in order to get Expat to compile up on bedrock
#$ENV{'CFLAGS'}="-fPIC $ENV{'CFLAGS'}";
### do we need this??


