##
##  ex-vi.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 information
Name:         ex-vi
Summary:      Traditional Unix Ex and Vi Editors
URL:          http://ex-vi.sourceforge.net/
Vendor:       Caldera, Gunnar Ritter
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Editor
License:      BSD
Version:      050325
Release:      20080101

#   list of sources
Source0:      http://download.sourceforge.net/ex-vi/ex-%{version}.tar.bz2

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

%description
    The vi editor is one of the most common text editors on Unix. It
    was developed starting around 1976 by Bill Joy at UCB, who was
    tired of the ed editor. But since he used ed as a code base, access
    to the original sources has required a commercial Unix Source
    Code License for more than twenty years. In January 2002, Caldera
    was so kind to remove usage restrictions to the Ancient Unix Code
    by a BSD-style license and thus vi is now finally free. Compared
    to most of its many clones, the traditional vi is a rather small
    program (the binary size is approximately 160 kBytes on i386)
    just with its extremely powerful editing interface, but lacking
    fancy features like multiple undo, multiple screens, or syntax
    highlighting. This port of vi has generally preserved the original
    style, terminal control, and feature set. It adds support for
    international character sets, including multibyte encodings such as
    UTF-8, and some minor enhancements that were not present in BSD vi
    3.7, but had been included in later vi versions for System V or in
    POSIX.2.

%track
    prog ex-vi = {
        version   = %{version}
        url       = http://sourceforge.net/projects/ex-vi/files/
        regex     = ex-(__VER__)\.tar\.bz2
    }

%prep
    %setup -q -n ex-%{version}
    %{l_shtool} subst \
        -e 's;-m 1755;-m 755;' \
        -e 's;ln -s;ln;' \
        Makefile

%build
    %{l_make} %{l_mflags} \
        CC="%{l_cc}" \
        CFLAGS="%{l_cflags -O} -I. %{l_cppflags ncurses .}" \
        CPPFLAGS="%{l_cppflags ncurses .}" \
        LDFLAGS="%{l_ldflags}" \
        PREFIX=%{l_prefix} \
        LIBEXECDIR='$(PREFIX)/libexec/ex-vi' \
        MANDIR='$(PREFIX)/man' \
        TERMLIB=ncurses

%install
    %{l_make} %{l_mflags} install \
        DESTDIR=$RPM_BUILD_ROOT \
        PREFIX=%{l_prefix} \
        LIBEXECDIR='$(PREFIX)/libexec/ex-vi' \
        MANDIR='$(PREFIX)/man' \
        INSTALL="%{l_shtool} install -c" \
        LNS="ln"
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

