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

VERSION=8.4.4
PROGNAME="Tk $VERSION"
DESC="\
tk (Tk toolkit for Tcl)                                                \n\
                                                                       \n\
Tk is an extension to Tcl that allows you to quickly and easily build  \n\
X11 applications that have the look and feel of Motif apps."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://dev.scriptics.com/software/tcltk
PKGNAME=tk-$VERSION-s390-$BUILD
TAG=REC

compile() {
   tar -zxvf $CWD/tk$VERSION-src.tar.gz
   rm -rf tk.shared
   cp -a tk$VERSION tk.shared/

   #
   # build the static version
   # 
   cd $TMP/tk$VERSION/unix/
   ./configure --prefix=/usr --disable-shared --enable-man-symlinks
   make

   #
   # build the shared version
   #
   cd $TMP/tk.shared/
   cd unix/
   ./configure --prefix=/usr --enable-shared --enable-man-symlinks
   make
}

install() {

   #
   # install the static version
   #
   cd $TMP/tk$VERSION/
   mkdir -p /package-tk/usr/doc/tk$VERSION
   cp -a README changes license.terms /package-tk/usr/doc/tk$VERSION

   cd unix/
   make install INSTALL_ROOT=/package-tk

   #
   # install the shared version
   #
   cd $TMP/tk.shared/unix
   make install INSTALL_ROOT=/package-tk

   # Make a script to produce symlinks to gzipped man pages (used when packing later):
   cat mkLinks | perl -pi -e 's|\.3|foo3foo3|' | perl -pi -e 's|\.3|foo3foo3|' | \
       perl -pi -e 's|foo3foo3|.3.gz|' | perl -pi -e 's|foo3foo3|.3.gz|' | \
       perl -pi -e 's|\.n|foonfoon|' | perl -pi -e 's|\.n|foonfoon|' | \
       perl -pi -e 's|foonfoon|.n.gz|' | perl -pi -e 's|foonfoon|.n.gz|' | \
       perl -pi -e 's|ln |ln -sf |' > $CWD/mkgzLinks.sh.new

   ( cd /package-tk/usr/man
     for dir in 1 3 n; do
       ( cd man$dir
         rm -f *.gz
         find . -type l | xargs rm
         gzip -9 *
         sh $CWD/mkgzLinks.sh .
       )
     done
   )

   ( cd /package-tk/usr/bin
     rm -rf wish ; ln -sf wish8.4 wish
   )
   ( cd /package-tk/usr/lib
     rm -rf libtk.a     ; ln -sf libtk8.4.a libtk.a
     rm -rf libtk.so    ; ln -sf libtk8.4.so libtk.so
     rm -rf libtkstub.a ; ln -sf libtkstub8.4.a libtkstub.a
   )
}

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

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

   cd $CTL
   cat $CWD/slack-desc > slack-desc
   sed -e 's%package-tk/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

