mk_source_dir  $SOURCE_DIRECTORY  &&
cd  $SOURCE_DIRECTORY             &&
unpack_file  ''                   &&
cd  mozilla*                       &&

# Archlinux patch to drop release point from install path
# http://projects.archlinux.org/svntogit/packages.git/plain/trunk/firefox-install-dir.patch?h=packages/firefox
patch -p1 < $SPELL_DIRECTORY/install_dir.patch &&

cp -v $SPELL_DIRECTORY/mozconfig .mozconfig &&

if [[ "$FIREFOX_SAFE" == "y" ]]; then
   sed -i '27iac_add_options --enable-safe-browsing' .mozconfig
else
   sed -i '27iac_add_options --disable-safe-browsing' .mozconfig
fi &&

if [[ "$FIREFOX_STRIP" == "y" ]]; then
   sed -i '27iac_add_options --enable-strip' .mozconfig
fi &&


if [[ $FIREFOX_OFFICIAL == y ]]; then
  sed -i '27iac_add_options --enable-official-branding' .mozconfig || return 1
fi &&

if [[ $FIREFOX_PGO == y ]]; then
  echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> .mozconfig &&
  patch -p0 < ${SPELL_DIRECTORY}/Makefile.in-pgo.patch
fi
