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

VERSION=6.3
PATCHVER=007
CTAGSVER=5.5.2
DIRVER=63
PROGNAME="Vi IMproved $VERSION"
DESC="\
vim (Vi IMproved)                                                      \n\
                                                                       \n\
Vim is an almost compatible version of the UNIX editor vi.  Many new   \n\
features have been added:  multi level undo, command line history,     \n\
filename completion, block operations, and more."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://vim.sourceforge.net/sources.php
SOURCE1=ftp://ftp.vim.org/pub/vim/unix/
PKGNAME=vim-$VERSION.$PATCHVER-s390-$BUILD
TAG=REC

compile() {
   # ctags was once a part of vim,
   # but now we have to bundle it in
   cd $TMP
   tar -zxvf $CWD/ctags-$CTAGSVER.tar.gz
   cd ctags-$CTAGSVER/
   chown -R root.root .
   CFLAGS=-O2 \
   ./configure --prefix=/usr \
               --build=s390-slackware-linux \
               --host=s390-slackware-linux \
               --target=s390-slackware-linux
   make
 
   #
   # build vim
   #
   cd $TMP 
   tar -yxvf $CWD/vim-$VERSION.tar.bz2
   tar -yxvf $CWD/vim-$VERSION-lang.tar.bz2
   cd vim$DIRVER/
   chown -R root.root .

   # apply patches
   for file in $CWD/patches/* ; do
      zcat $file | patch -p0 --batch # --verbose --batch
   done

   CFLAGS=-O2 \
   ./configure --prefix=/usr \
               --without-x \
               --disable-gui \
               --with-features=big \
               --build=s390-slackware-linux \
               --host=s390-slackware-linux \
               --target=s390-slackware-linux
   make
}

install() {
   #
   # install ctags
   #
   cd $TMP/ctags-$CTAGSVER/
   make install prefix=/package-vim/usr
   mkdir -p /package-vim/usr/doc/ctags-$CTAGSVER
   cp -a COPYING EXTENDING.html FAQ INSTALL INSTALL.oth NEWS README \
      /package-vim/usr/doc/ctags-$CTAGSVER

   #
   # install vim
   #
   cd $TMP/vim$DIRVER/
   make install prefix=/package-vim/usr

   ( cd /package-vim/usr/bin
     # Pat doesn't have this symbolic link
     rm -rf etags
     rm -rf eview ; ln -sf vim eview
     rm -rf evim  ; ln -sf vim evim
   )

   mkdir -p /package-vim/usr/doc/vim-$VERSION
   cp -a README.txt /package-vim/usr/doc/vim-$VERSION
   ( cd /package-vim/usr/doc/vim-$VERSION ; ln -sf /usr/share/vim/vim$DIRVER doc )

   ( cd /package-vim/usr/man/man1
     find . -type l -exec rm {} \;
     rm -f *.gz
     gzip -9 *.1
   )

   ( cd /package-vim/usr/man/man1
     rm -rf ex.1.gz    ; ln -sf vim.1.gz ex.1.gz
     rm -rf rview.1.gz ; ln -sf vim.1.gz rview.1.gz
     rm -rf rvim.1.gz  ; ln -sf vim.1.gz rvim.1.gz
     rm -rf view.1.gz  ; ln -sf vim.1.gz view.1.gz
   )
}

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

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

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

   zcat $CWD/doinst.sh.gz >> doinst.sh
}

