##
##  w3m.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:         w3m
Summary:      Interactive Full-Screen Client for HTTP/HTTPS/FTP Protocols
URL:          http://w3m.sourceforge.net/
Vendor:       Akinori Ito
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        Web
License:      BSD
Version:      0.5.3
Release:      20220918

#   list of sources
Source0:      http://download.sourceforge.net/w3m/w3m-%{version}.tar.gz
Patch0:       w3m.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  ncurses, openssl10, zlib, gc >= 7.2
PreReq:       ncurses, openssl10, zlib, gc >= 7.2

%description
    W3M is a text-based web browser as well as a pager like `more'
    or `less'. With W3M you can browse web pages through a terminal
    emulator window (xterm, rxvt or something like that). Moreover, W3M
    can be used as a text formatting tool which typesets HTML into plain
    text.

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

%prep
    %setup -q
    %patch -p0

%build
    CC="%{l_cc}" \
    CFLAGS="%{l_cppflags openssl10 .} %{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags openssl10 .}" \
    LDFLAGS="%{l_ldflags openssl10 .}" \
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
        --libdir=%{l_prefix}/libexec/w3m \
        --sysconfdir=%{l_prefix}/etc \
        --with-termlib=ncurses \
        --with-editor=%{l_prefix}/bin/vim \
        --with-mailer=%{l_prefix}/bin/mutt \
        --with-browser=%{l_prefix}/bin/mozilla \
        --with-gc=%{l_prefix} \
        --with-ssl=%{l_prefix} \
        --enable-sslverify \
        --enable-w3mmailer \
        --disable-external-uri-loader \
        --without-migemo \
        --disable-gopher \
        --disable-ipv6 \
        --disable-nntp \
        --disable-dict \
        --disable-alarm \
        --disable-xface \
        --enable-history \
        --enable-keymap=w3m \
        --enable-menu \
        --enable-mouse \
        --enable-cookie \
        --enable-digest-auth \
        --enable-image=no \
        --enable-color \
        --disable-ansi-color \
        --disable-bgcolor \
        --disable-japanese \
        --disable-unicode \
        --disable-m17n \
        --disable-nls
    %{l_make} %{l_mflags}

%install
    %{l_make} %{l_mflags} install install-helpfile \
        INSTALL="%{l_shtool} install -c" \
        DESTDIR=$RPM_BUILD_ROOT
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/ja
    rm -f $RPM_BUILD_ROOT%{l_prefix}/share/w3m/*.ja.pl
    rm -f $RPM_BUILD_ROOT%{l_prefix}/share/w3m/*_ja.html
    rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/w3m/xface2xpm
    rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/w3m/w3mimgdisplay
    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/w3m
    echo "color 1" >$RPM_BUILD_ROOT%{l_prefix}/etc/w3m/config
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/w3m/*'

%files -f files

%clean

