##
##  elinks.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:         elinks
Summary:      Interactive Full-Screen Client for HTTP/HTTPS/FTP Protocols
URL:          http://elinks.cz/
Vendor:       Stranka Mikulase Patocky, Jonas Fonseca
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Web
License:      GPL
Version:      0.12pre6
Release:      20121031

#   package options
%option       with_ssl   yes
%option       with_idn   yes
%option       with_js    yes
%option       with_cgi   no

#   list of sources
Source0:      http://elinks.cz/download/elinks-%{version}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  expat, zlib, bzip2, libiconv, libexecinfo
PreReq:       expat, zlib, bzip2, libiconv, libexecinfo
%if "%{with_ssl}" == "yes"
BuildPreReq:  openssl
PreReq:       openssl
%endif
%if "%{with_js}" == "yes"
BuildPreReq:  js
PreReq:       js
%endif
%if "%{with_idn}" == "yes"
BuildPreReq:  libidn
PreReq:       libidn
%endif

%description
    ELinks is an advanced and well-established feature-rich text mode
    web browser. ELinks can render both frames and tables, is highly
    customizable and can be extended via Lua or Guile scripts. It is
    very portable and runs on a variety of platforms.

%track
    prog elinks = {
        version   = %{version}
        url       = http://elinks.cz/download/
        regex     = elinks-(__VER__)\.tar\.gz
    }

%prep
    %setup -q

%build
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags -O}"
    export CPPFLAGS="%{l_cppflags}"
    export LDFLAGS="%{l_ldflags}"
    export LIBS="-lexecinfo"
    CFLAGS="$CFLAGS `pkg-config libidn js --cflags-only-other`"
    CPPFLAGS="$CPPFLAGS `pkg-config libidn js --cflags-only-I`"
    LDFLAGS="$LDFLAGS `pkg-config libidn js --libs-only-other`"
    LIBS="$LIBS `pkg-config libidn js --libs-only-l`"
    export TERM=vt100
    ./configure \
        --prefix=%{l_prefix} \
        --libdir=%{l_prefix}/lib/elinks \
        --enable-html-highlight \
        --enable-css \
        --enable-cookies \
        --enable-ftp \
        --with-libiconv=%{l_prefix} \
%if "%{with_idn}" == "yes"
        --with-idn=%{l_prefix} \
%else
        --without-idn \
%endif
%if "%with_ssl}" == "yes"
        --with-openssl=%{l_prefix} \
%else
        --without-openssl \
%endif
        --without-gnutls \
%if "%{with_js}" == "yes"
        --enable-sm-scripting \
        --with-spidermonkey=%{l_prefix} \
%else
        --disable-sm-scripting \
%endif
%if "%with_cgi}" == "yes"
        --enable-cgi \
%else
        --disable-cgi \
%endif
        --with-zlib \
        --with-bzlib \
        --disable-nls
    %{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
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/locale
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

