cd "$SOURCE_DIRECTORY/mozilla"  &&

FIREFOX_HOME="$INSTALL_ROOT/usr/lib/firefox" &&

if  spell_ok  Firebird;  then
  dispel Firebird
fi  &&

# Not recommended by http://www.mozilla.org/build to use
# make install.  Manually install the files.

mkdir -p $INSTALL_ROOT/usr/lib/firefox  &&
cp -RLv dist/bin/* $INSTALL_ROOT/usr/lib/firefox/  &&
mkdir -p $INSTALL_ROOT/usr/include/firefox/ &&
cp -LfRv dist/include/* $INSTALL_ROOT/usr/include/firefox/ &&
mkdir -p $INSTALL_ROOT/usr/share/idl/firefox/ &&
cp -LfRv dist/idl/* $INSTALL_ROOT/usr/share/idl/firefox/ &&

#
# Script to set MOZILLA_FIVE_HOME
#
cp -v $SPELL_DIRECTORY/$SPELL.sh  $INSTALL_ROOT/etc/profile.d &&

#
# Create symlink to mozilla for hardwired applications
# Only create if /usr/bin/mozilla does not exist or is
# already a symlink
#
if  [[ $FIREFOX_MOZLINK == y ]];  then
  if  !  test  -f   $INSTALL_ROOT/usr/bin/mozilla  ||
         test  -h   $INSTALL_ROOT/usr/bin/mozilla  ;  then
    ln -sf $TRACK_ROOT/usr/bin/firefox  /usr/bin/mozilla
  fi
fi  &&

#
# Create symlink from NSS Root CA store, if it exists.  NSS requires this
# to be in the same directory as the current application binary.  See:
# http://www.mozilla.org/projects/security/pki/nss/loadable_certs.html
# https://bugzilla.mozilla.org/show_bug.cgi?id=128290
# Only create if $MOZILLA_HOME/libnssckbi.so does not exist or is already a
# symlink.
#
if  test  -f   $INSTALL_ROOT/usr/lib/libnssckbi.so;  then
  if  !  test  -f   $FIREFOX_HOME/libnssckbi.so  ||
         test  -h   $FIREFOX_HOME/libnssckbi.so; then
    ln -sf $TRACK_ROOT/usr/lib/libnssckbi.so  $FIREFOX_HOME/libnssckbi.so
  fi
fi  &&
if [[ $FIREFOX_NULLPLUGIN == n ]]; then
   rm $FIREFOX_HOME/plugins/libnullplugin.so
fi &&

#
# install firefox script so it loads properly even if MOZILLA_FIVE_HOME is
# not set or set to a different mozilla/firefox directory
#
install  -m  755  -o  root  -g  root  $SPELL_DIRECTORY/firefox  \
         $INSTALL_ROOT/usr/bin  &&

# fix up permissions, firefox 2.0.0.8 installs stuff non-readable for
# anyone but root
chmod -R go+r /usr/lib/firefox  &&
chmod go+x /usr/lib/firefox/run-mozilla.sh
