##
##  vile.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  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 version
%define       V_base    9.8
%define       V_patch1  a
%define       V_patch2  b
%define       V_patch3  c
%define       V_patch4  d
%define       V_patch5  e
%define       V_patch6  f
%define       V_patch7  g
%define       V_patch8  h
%define       V_patch9  i
%define       V_patch10 j
%define       V_patch11 k
%define       V_patch12 l
%define       V_patch13 m
%define       V_patch14 n
%define       V_patch15 o
%define       V_patch16 p
%define       V_patch17 q
%define       V_patch18 r
%define       V_patch19 s
%define       V_patch20 t
%define       V_patch21 u
%define       V_patch22 v
%define       V_patch23 w
%define       V_patch24 x
%define       V_patch25 y
%define       V_patchL  %{V_patch25}

#   package information
Name:         vile
Summary:      Vi like Emacs
URL:          http://invisible-island.net/vile/vile.html
Vendor:       Thomas E. Dickey
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Editor
License:      GPL
Version:      %{V_base}%{V_patchL}
Release:      20230116

#   list of sources
Source0:      ftp://ftp.invisible-island.net/vile/vile-%{V_base}.tgz
Patch0:       vile.patch
Patch1:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch1}.patch.gz
Patch2:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch2}.patch.gz
Patch3:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch3}.patch.gz
Patch4:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch4}.patch.gz
Patch5:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch5}.patch.gz
Patch6:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch6}.patch.gz
Patch7:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch7}.patch.gz
Patch8:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch8}.patch.gz
Patch9:       ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch9}.patch.gz
Patch10:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch10}.patch.gz
Patch11:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch11}.patch.gz
Patch12:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch12}.patch.gz
Patch13:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch13}.patch.gz
Patch14:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch14}.patch.gz
Patch15:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch15}.patch.gz
Patch16:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch16}.patch.gz
Patch17:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch17}.patch.gz
Patch18:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch18}.patch.gz
Patch19:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch19}.patch.gz
Patch20:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch20}.patch.gz
Patch21:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch21}.patch.gz
Patch22:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch22}.patch.gz
Patch23:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch23}.patch.gz
Patch24:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch24}.patch.gz
Patch25:      ftp://ftp.invisible-island.net/vile/patches/vile-%{V_base}%{V_patch25}.patch.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, flex
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  ncurses
PreReq:       ncurses

%description
    Vile (Vi like Emacs) is a text editor which is extremely similar
    to Vi in terms of commonly used keyboard commands. Vile isn't Vi,
    however; many things are missing and the screen doesn't look the
    same. Vile includes the multiple buffer and multiple window features
    found in Emacs and other editors. In addition, it has extended
    capabilities in many areas, including key rebinding and real X
    Window System support.

%track
    prog vile = {
        version   = %{V_base}
        url       = ftp://ftp.invisible-island.net/vile/
        regex     = vile-(__VER__)\.tgz
    }
    prog vile:patches = {
        version   = %{V_base}%{V_patchL}
        url       = ftp://ftp.invisible-island.net/vile/patches/
        regex     = vile-(__VER__)\.patch\.gz
    }

%prep
    %setup -q -n vile-%{V_base}
    %patch -p1 -P 1
    %patch -p1 -P 2
    %patch -p1 -P 3
    %patch -p1 -P 4
    %patch -p1 -P 5
    %patch -p1 -P 6
    %patch -p1 -P 7
    %patch -p1 -P 8
    %patch -p1 -P 9
    %patch -p1 -P 10
    %patch -p1 -P 11
    %patch -p1 -P 12
    %patch -p1 -P 13
    %patch -p1 -P 14
    %patch -p1 -P 15
    %patch -p1 -P 16
    %patch -p1 -P 17
    %patch -p1 -P 18
    %patch -p1 -P 19
    %patch -p1 -P 20
    %patch -p1 -P 21
    %patch -p1 -P 22
    %patch -p1 -P 23
    %patch -p1 -P 24
    %patch -p1 -P 25
    find . -name "*.orig" -print | xargs rm -f
    %patch -p0 -P 0
    chmod u+w filters/sql-filt.l*
    %{l_shtool} subst \
        -e 's;= LEAD;= 0;' \
        filters/sql-filt.l

%build
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    ./configure \
        --prefix=%{l_prefix} \
        --with-screen=ncurses \
        --with-curses-dir=%{l_prefix} \
        --with-ncurses \
        --without-x \
        --without-iconv \
        --without-locale
    %{l_make} %{l_mflags}

%install
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
    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

