##
##  ispell.spec -- OpenPKG RPM Specification
##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         ispell
Summary:      Interactive Spell Checker
URL:          http://fmg-www.cs.ucla.edu/geoff/ispell.html
Vendor:       R.E. Gorin, Pace Willisson, Geoff Kuenning
Packager:     The OpenPKG Project
Distribution: OpenPKG [BASE]
Group:        Text
License:      BSD
Version:      3.2.06
Release:      20021116

#   list of sources
Source0:      http://fmg-www.cs.ucla.edu/geoff/tars/ispell-%{version}.tar.gz
Source1:      ftp://ftp.informatik.uni-kiel.de/pub/kiel/dicts/hk-deutsch.tar.gz
Source2:      http://lisa.goe.net/~bjacke/igerman98/dict/igerman98-20021114.tar.bz2
Source3:      ftp://ftp.openpkg.org/DST/ispell/words.gz
Patch0:       ispell.patch

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 20020206, make, bison
PreReq:       OpenPKG, openpkg >= 20020206
AutoReq:      no
AutoReqProv:  no

%description
    Ispell is a fast screen-oriented spelling checker that shows you
    your errors in the context of the original file, and suggests
    possible corrections when it can figure them out. Compared to UNIX
    spell, it is faster and much easier to use. Ispell can also handle
    languages other than English.

%prep
    %setup -q
    %patch -p0
    %{l_gzip} -d -c %{SOURCE words.gz} >$RPM_BUILD_DIR/words
    mkdir hk-deutsch
    (cd hk-deutsch; %{l_gzip} -d -c %{SOURCE hk-deutsch.tar.gz} | %{l_tar} xf -)
    %{l_bzip2} -d -c %{SOURCE igerman98-20001109.tar.bz2} | %{l_tar} xf -

%build
    ( echo "#define MINIMENU"
      echo "#undef  NO8BIT"
      echo "#define MASKBITS 64"
      echo "#define CC         \"%{l_cc}\""
      echo "#define CFLAGS     \"%{l_cflags -O}\""
      echo "#define BINDIR     \"%{l_prefix}/bin\""
      echo "#define LIBDIR     \"%{l_prefix}/share/ispell\""
      echo "#define MAN1DIR    \"%{l_prefix}/man/man1\""
      echo "#define MAN4DIR    \"%{l_prefix}/man/man4\""
      echo "#define WORDS      \"$RPM_BUILD_DIR/words\""
      echo "#define YACC       \"%{l_prefix}/bin/bison -y\""
      case "%{l_target}" in
          *-linux* | *-solaris* ) echo "#define USG" ;;
      esac
      #echo "#define LANGUAGES \"{american,MASTERDICTS=american.med+,HASHFILES=americanmed+.hash,EXTRADICT=$RPM_BUILD_DIR/words}\""
    ) >local.h
    %{l_make} %{l_mflags}
    ( cd hk-deutsch
      cat worte.txt verben.txt \
          adjektive.txt klein.txt geographie.txt vornamen.txt \
          abkuerz.txt imperat.txt latein.txt informatik.txt \
          infoabk.txt elektronik.txt orgabk.txt marken.txt \
          alphabeta.txt roemisch.txt zusammen.txt | \
          sort -u >all.words
      ../buildhash all.words deutsch.aff deutsch.hash
    )
    ( cd igerman98-20001109
      %{l_make} %{l_mflags} \
          UNSQ=cat BUILDHASH=`pwd`/../buildhash \
          german.hash 2>/dev/null
    )

%install
    rm -rf $RPM_BUILD_ROOT
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/man \
        $RPM_BUILD_ROOT%{l_prefix}/share/ispell
    ( echo "#define MINIMENU"
      echo "#undef  NO8BIT"
      echo "#define MASKBITS 64"
      echo "#define CC         \"%{l_cc}\""
      echo "#define CFLAGS     \"%{l_cflags -O}\""
      echo "#define BINDIR     \"$RPM_BUILD_ROOT%{l_prefix}/bin\""
      echo "#define LIBDIR     \"$RPM_BUILD_ROOT%{l_prefix}/share/ispell\""
      echo "#define MAN1DIR    \"$RPM_BUILD_ROOT%{l_prefix}/man/man1\""
      echo "#define MAN4DIR    \"$RPM_BUILD_ROOT%{l_prefix}/man/man4\""
      echo "#define WORDS      \"$RPM_BUILD_DIR/words\""
      #echo "#define LANGUAGES \"{american,MASTERDICTS=american.med+,HASHFILES=americanmed+.hash,EXTRADICT=$RPM_BUILD_DIR/words}\""
    ) >local.h
    %{l_make} %{l_mflags} config.sh install-basic install-deformatters install-dictbuild install-languages
    rm -f $RPM_BUILD_ROOT%{l_prefix}/share/ispell/american*
    ( cd hk-deutsch
      %{l_shtool} install -c -m 644 \
          deutsch.aff $RPM_BUILD_ROOT%{l_prefix}/share/ispell/deutsch-old.aff
      %{l_shtool} install -c -m 644 \
          deutsch.hash $RPM_BUILD_ROOT%{l_prefix}/share/ispell/deutsch-old.hash
    )
    ( cd igerman98-20001109
      %{l_shtool} install -c -m 644 \
          german.aff $RPM_BUILD_ROOT%{l_prefix}/share/ispell/deutsch.aff
      %{l_shtool} install -c -m 644 \
          german.hash $RPM_BUILD_ROOT%{l_prefix}/share/ispell/deutsch.hash
    )
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean
    rm -rf $RPM_BUILD_ROOT

