#!/bin/sh

SRCNAM=xulrunner-1.9.1.7.source.tar.bz2
WRKDIR=mozilla-1.9.1
TMPDIR=/tmp/xulrunner

rm -r -f $WRKDIR

rm -r -f $TMPDIR

mkdir -p $TMPDIR

export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/share/pkgconfig

tar -xf $SRCNAM

cd $WRKDIR

./configure --prefix=/usr/local --with-system-nspr --with-system-nss --with-system-zlib --with-system-jpeg \
--with-system-bz2=/usr/local --enable-application=xulrunner --enable-startup-notification \
--disable-crashreporter --disable-javaxpcom --disable-installer --disable-updater \
--disable-mochitest --disable-accessibility --disable-tests --enable-safe-browsing  --enable-strip \
--enable-system-cairo --enable-optimize --enable-system-sqlite

make

make install DESTDIR=$TMPDIR

cd ..

rm -r -f $WRKDIR

find $TMPDIR/ -type d | xargs chmod -v 755

cd $TMPDIR

find . | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

find . | xargs file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip -g 2> /dev/null
