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

if  spell_ok  Firebird;  then
  dispel Firebird
fi  &&
#fix firefox-config file to match installed configuration
patch -p0 < $SCRIPT_DIRECTORY/firefox-config.patch &&

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

mkdir -p $INSTALL_ROOT/usr/lib/firefox  &&
cd $SOURCE_DIRECTORY   &&
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/ &&

#fix install directories in *.pc files.
sed -i s#usr/local#usr# build/unix/firefox-* &&
sed -i s#-${VERSION}## build/unix/firefox-* &&
cp build/unix/firefox*.pc $INSTALL_ROOT/usr/lib/pkgconfig &&


#
# Script to set MOZILLA_FIVE_HOME
#
cp  ${SCRIPT_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  $SCRIPT_DIRECTORY/firefox  \
         $INSTALL_ROOT/usr/bin  &&

# make the pkgconfig files reference the nspr from the standalone nspr spell
sedit "s/nspr/mozilla-nspr/" ${INSTALL_ROOT}/usr/lib/pkgconfig/firefox-nss.pc  &&
sedit "s/nspr/mozilla-nspr/" ${INSTALL_ROOT}/usr/lib/pkgconfig/firefox-js.pc  &&
sedit "s/nspr/mozilla-nspr/" ${INSTALL_ROOT}/usr/lib/pkgconfig/firefox-xpcom.pc &&
sedit "s/nspr/mozilla-nspr/" ${INSTALL_ROOT}/usr/lib/pkgconfig/firefox-plugin.pc
