#!/bin/sh
#191026

[ -d seamonkey-2.49.5 ] && rm -rf seamonkey-2.49.5
tar -xf seamonkey-2.49.5.source.tar.xz 
[ $? -ne 0 ] && exit
sync
cd seamonkey-2.49.5

export CC=gcc
export CXX=g++
export CFLAGS+=' -fno-delete-null-pointer-checks'
export CXXFLAGS+=' -fno-delete-null-pointer-checks'

cd mozilla
patch -p3 < ../../patches-fedora/28-seamonkey-2.49.5-crmf.patch
cd ..

# Retain GTK+ v2 scrolling behavior:
patch -p1 < ../patches-slackware/sm.ui.scrollToClick.diff

# Don't complain if Rust is i686:
patch -p1 < ../patches-slackware/seamonkey.i686.triplet.fix.diff

# Clear some variables that could break the build
unset DBUS_SESSION_BUS_ADDRESS ORBIT_SOCKETDIR SESSION_MANAGER \
  XDG_SESSION_COOKIE XAUTHORITY MAKEFLAGS

cp -f ../mozconfig ./
## Mozilla devs enforce using an objdir for building
## https://developer.mozilla.org/en/Configuring_Build_Options#Building_with_an_objdir
#mkdir obj
#echo "mk_add_options MOZ_OBJDIR=$(pwd)/obj" >> mozconfig
## This directory is also needed or the build will fail:
#mkdir -p mozilla/obj

echo -n 'Press ENTER to compile: '
read goforit
make -f client.mk

#to install:
echo -n 'Press ENTER to install: '
[ -d /usr/lib/seamonkey-2.49.5 ] && rm -rf /usr/lib/seamonkey-2.49.5
make -f client.mk install
sync
ln -snf seamonkey-2.49.5 /usr/lib/seamonkey

###end###
