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

VERSION=2.8.5rel.1
PROGNAME="lynx $VERSION"
DESC="\
Lynx (text mode browser)                                               \n\
                                                                       \n\
Lynx is a distributed hypertext browser with full World Wide Web       \n\
capabilities.  Lynx can be used to access information on the World     \n\
Wide Web, or to build information systems intended primarily for local \n\
access.  For example, Lynx has been used to build several Campus Wide  \n\
Information Systems (CWIS).                                            \n\
                                                                       \n\
Lynx's authors include Lou Montulli, Garrett Blythe, Craig Lavender,   \n\
Michael Grobe, and Charles Rezac."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.lynx.browser.org
PKGNAME=lynx-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   # There's something odd about the way lynx does its configuring.  If I
   # run this prototype twice, I get a compile error in src/LYUtils.c.  IF
   # I wipe out the source tree and re-run it, it compiles fine.  So, here
   # we go...
   rm -rf $TMP/lynx2-8-5/*

   tar -yxvf $CWD/lynx$VERSION.tar.bz2
   cd lynx2-8-5/

   # Fix /usr/local paths:
   zcat $CWD/lynx.path.diff.gz | patch -p1 --verbose # --backup
   # Apply recolorizing patch:
   zcat $CWD/lynx.cfg.diff.gz | patch -p1 --verbose --backup
   find . -name "*~" | xargs rm
   chown -R root.root .

   ./configure --prefix=/usr \
               --libdir=/usr/lib/lynx \
               --enable-default-colors \
               --sysconfdir=/etc \
               --with-screen=ncurses \
               --enable-gzip-help \
               --with-zlib \
               --enable-read-eta \
               --enable-scrollbar \
               --with-ssl \
               --enable-color-style \
               --enable-prettysrc \
               --enable-source-cache \
               --enable-nsl-fork \
               --enable-nls \
               --enable-persistent-cookies \
               --enable-vertrace \
               --disable-full-paths \
               --enable-addrlist-page \
               --enable-charset-choice \
               --enable-cjk \
               --enable-htmlized-cfg \
               --enable-justify-elts \
               --enable-locale-charset \
               --enable-externs \
               --enable-cgi-links \
               --enable-change-exec \
               --enable-exec-links \
               --enable-exec-scripts \
               --enable-internal-links \
               --with-bzlib
   make
}

install() {
   make install DESTDIR=/package-lynx
   make install-help DESTDIR=/package-lynx
   make install-doc DESTDIR=/package-lynx

   mkdir -p /package-lynx/usr/doc
   ( cd /package-lynx/usr/doc
     rm -rf lynx-$VERSION ; ln -sf /usr/lib/lynx lynx-$VERSION )

   ( cd /package-lynx/usr/lib/lynx/lynx_help
     rm -rf COPYING ; ln -sf ../lynx_doc/COPYING COPYING
     rm -rf COPYHEADER ; ln -sf ../lynx_doc/COPYHEADER COPYHEADER
   )

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

attributes() {
   chown -R root.bin $PKG/package-lynx/usr/bin
   chmod 775 $PKG/package-lynx/usr/lib/lynx/lynx_doc/docs/ \
             $PKG/package-lynx/usr/lib/lynx/lynx_doc/samples/ \
             $PKG/package-lynx/usr/lib/lynx/lynx_doc/test/
}

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

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

   sed -e 's%package-lynx/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

