Name:             elinks
Version:          0.12
Release:          2
Summary:          A text-mode Web browser
License:          GPLv2
URL:              http://elinks.or.cz
Source:           http://elinks.or.cz/download/elinks-%{version}pre6.tar.bz2
Source2:          elinks.conf

BuildRequires:    automake bzip2-devel expat-devel gpm-devel krb5-devel libidn2-devel
BuildRequires:    libidn2-devel lua-devel openssl-devel pkgconfig zlib-devel
Requires(preun):  chkconfig
Requires(post):   coreutils
Requires(post):   chkconfig
Requires(postun): coreutils
Requires(postun): chkconfig
Provides:         webclient links = 1:0.97-1 text-www-browser


Patch0000:        elinks-0.11.0-ssl-noegd.patch
Patch0001:        elinks-0.10.1-utf_8_io-default.patch
Patch0002:        elinks-0.11.0-getaddrinfo.patch
Patch0003:        elinks-0.11.0-sysname.patch
Patch0004:        elinks-0.10.1-xterm.patch
Patch0005:        elinks-0.11.3-macropen.patch
Patch0006:        elinks-scroll.patch
Patch0007:        elinks-0.12pre5-ddg-search.patch
Patch0008:        elinks-0.12pre6-autoconf.patch
Patch0009:        elinks-0.12pre6-ssl-hostname.patch
Patch0010:        elinks-0.12pre6-list_is_singleton.patch
Patch0011:        elinks-0.12pre6-lua51.patch
Patch0012:        elinks-0.12pre6-libidn2.patch
Patch0013:        elinks-0.12pre6-recent-gcc-versions.patch
Patch0014:        elinks-0.12pre6-openssl11.patch

%description
ELinks is a free text-based console web browser,
Elinks does not display any images,but it does support frames,
tables and most other HTML tags.

%package help
Summary:   Introduce how to use elinks

%description help
Introduce how to use elinks

%prep
%autosetup -p1 -n %{name}-%{version}pre6

mv -v configure.in configure.ac
sed -e 's/configure\.in/configure.ac/' -i Makefile* acinclude.m4 doc/man/man1/Makefile

sed -i 's/^# *serial [AM0-9]*$//' acinclude.m4 config/m4/*.m4

aclocal -I config/m4
autoconf
autoheader

%build
export CFLAGS="$RPM_OPT_FLAGS $(getconf LFS_CFLAGS) -D_GNU_SOURCE -DLUA_COMPAT_5_3"
%configure %{?rescue:--without-gpm} \
    --enable-256-colors --enable-bittorrent --with-gssapi \
    --with-lua --with-openssl --without-gnutls \
    --without-spidermonkey --without-x

%make_build V=1

%install
%make_install V=1
install -d %{buildroot}%{_sysconfdir}
install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/elinks.conf
touch %{buildroot}%{_bindir}/links
true | gzip -c > %{buildroot}%{_mandir}/man1/links.1.gz
%find_lang elinks

%postun
if [ "$1" -ge "1" ]; then
        links=`readlink %{_sysconfdir}/alternatives/links`
        if [ "$links" == "%{_bindir}/elinks" ]; then
              %{_sbindir}/alternatives --set links %{_bindir}/elinks
        fi
fi
exit 0

%post
%{_sbindir}/alternatives --install %{_bindir}/links links %{_bindir}/elinks 90 \
  --slave %{_mandir}/man1/links.1.gz links-man %{_mandir}/man1/elinks.1.gz
links=`readlink %{_sysconfdir}/alternatives/links`
if [ "$links" == "%{_bindir}/elinks" ]; then
      %{_sbindir}/alternatives --set links %{_bindir}/elinks
fi


%preun
if [ $1 = 0 ]; then
        %{_sbindir}/alternatives --remove links %{_bindir}/elinks
fi
exit 0

%files -f elinks.lang
%doc COPYING README
%ghost %verify(not md5 size mtime) %{_bindir}/links
%{_bindir}/elinks
%ghost %verify(not md5 size mtime) %{_mandir}/man1/links.1.gz
%config(noreplace) %{_sysconfdir}/elinks.conf
%exclude %{_datadir}/locale/locale.alias

%files help
%{_mandir}/man1/elinks.1*
%{_mandir}/man5/*

%changelog
* Thu Aug 06 2020 lingsheng<lingsheng@huawei.com> - 0.12-2
- Fix build with lua 5.4

* Wed Nov 13 2019 yangjian<yangjian79@huawei.com> - 0.12-1
- Package init
