IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=1.4.4
PROGNAME="Mozilla $VERSION"
DESC="\
mozilla (an open-source web browser)                                   \n\
                                                                       \n\
The Mozilla web browser.  Mozilla is a cousin to Netscape              \n\
Communicator that is being developed by the Free Software Community    \n\
with the cooperation and support of Netscape.  Mozilla uses a next-    \n\
generation browser engine known as Gecko."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
PKGNAME=mozilla-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   tar -yxvf $CWD/mozilla-source-${VERSION}.tar.bz2
   cd mozilla/
   chown -R root.root .

   BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 \
   ./configure --prefix=/usr \
     --enable-optimize=-O2 \
     --disable-debug \
     --with-default-mozilla-five-home=/usr/lib/mozilla-${VERSION} \
     --enable-strip \
     --disable-tests \
     --disable-short-wchar \
     --enable-nspr-autoconf \
     --enable-calendar \
     --enable-extensions=default,irc \
     --enable-crypto \
     --disable-xprint \
     --without-system-nspr \
     --with-system-zlib \
     --enable-default-toolkit=gtk2 \
     --disable-freetype2 \
     --enable-xft
#     --disable-debug

   BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 make -s export
   BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 make -s libs
}

install() {
   cd $TMP/mozilla/

   BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 make install DESTDIR=/package-mozilla

   mkdir -p /package-mozilla/usr/doc/mozilla-$VERSION
   cp -a LEGAL LICENSE README.txt \
       /package-mozilla/usr/doc/mozilla-$VERSION

   mkdir -p /package-mozilla/usr/share/gnome/apps/Internet
   cp -a $CWD/*.desktop /package-mozilla/usr/share/gnome/apps/Internet

   mkdir -p /package-mozilla/usr/share/pixmaps
   cp -a $CWD/*.gif $CWD/*.png /package-mozilla/usr/share/pixmaps

   # Install nss headers.
   mkdir -p /package-mozilla/usr/include/mozilla-${VERSION}/nss
   find security/nss/lib -name "*.h" -type f \
      -exec cp -a {} /package-mozilla/usr/include/mozilla-${VERSION}/nss \; 

   # Pat says:
   # Move nss libraries into /usr/lib.  Unless this is done, some things (like gaim's
   # plugin for MSN) will be unable to load them, even if they linked with them
   # successfully.  AFAIKT, these other things are at fault, but since this little
   # trick fixes the problem we'll do it.  BTW, Red Hat started this lib moving mess
   # for unknown reasons (didn't know how to link properly?), so that's why other
   # programs now expect to find things arranged other than a standard "make install" layout...
   ( cd /package-mozilla/usr/lib/mozilla-${VERSION}
     for nsslib in libnspr4.so libnss3.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so ; do
       # Move library:
       mv $nsslib ..
       # Link to it... you don't just go messing with stuff without leaving it "clean"
       ln -sf ../$nsslib .
     done
   )

   ( cd /package-mozilla/usr/man/man1
     rm -f *.gz
     gzip -9 *.1
   )
}

attributes() {
   chown -R root.bin $PKG/package-mozilla/usr/bin
}

special() {
   cd $PKG
   mv package-mozilla/* ./
   rmdir package-mozilla

   cd $CTL
   cat $CWD/slack-desc > slack-desc

#  zcat $CWD/moz-1.4-kludge-doinst.sh.gz >> doinst.sh
   sed -e 's%package-mozilla/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

