#!/bin/bash

# We have a run-time dependency on java-common, enable it first
. scl_source enable rh-java-common

# The IDE has optional deps on other collections, so enable them if present
if test -e /opt/rh/devtoolset-6/enable ; then
  . scl_source enable devtoolset-6
fi
if test -e /opt/rh/python27/enable ; then
  . scl_source enable python27
fi
if test -e /opt/rh/python33/enable ; then
  . scl_source enable python33
fi
if test -e /opt/rh/rh-python34/enable ; then
  . scl_source enable rh-python34
fi
if test -e /opt/rh/rh-python35/enable ; then
  . scl_source enable rh-python35
fi

# General environment variables
export PATH=/opt/rh/rh-eclipse46/root/usr/bin:/opt/rh/rh-eclipse46/root/usr/lib/jvm/java/bin${PATH:+:${PATH}}
export MANPATH=/opt/rh/rh-eclipse46/root/usr/share/man:${MANPATH}

# Needed by Java Packages Tools to locate java.conf
export JAVACONFDIRS="/opt/rh/rh-eclipse46/root/etc/java:${JAVACONFDIRS:-/etc/java}"

# Required by XMvn to locate its configuration files
export XDG_CONFIG_DIRS="/opt/rh/rh-eclipse46/root/etc/xdg:${XDG_CONFIG_DIRS:-/etc/xdg}"
export XDG_DATA_DIRS="/opt/rh/rh-eclipse46/root/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"

# Some perl Ext::MakeMaker versions install things under /usr/lib/perl5
# even though the system otherwise would go to /usr/lib64/perl5.
export PERL5LIB=/opt/rh/rh-eclipse46/root//usr/lib64/perl5/vendor_perl:/opt/rh/rh-eclipse46/root/usr/lib/perl5:/opt/rh/rh-eclipse46/root//usr/share/perl5/vendor_perl${PERL5LIB:+:${PERL5LIB}}
# bz847911 workaround:
# we need to evaluate rpm's installed run-time % { _libdir }, not rpmbuild time
# or else /etc/ld.so.conf.d files?
rpmlibdir=$(rpm --eval "%{_libdir}")
# bz1017604: On 64-bit hosts, we should include also the 32-bit library path.
if [ "$rpmlibdir" != "${rpmlibdir/lib64/}" ]; then
  rpmlibdir32=":/opt/rh/rh-eclipse46/root${rpmlibdir/lib64/lib}"
fi
export LD_LIBRARY_PATH=/opt/rh/rh-eclipse46/root$rpmlibdir$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
